#!/bin/sh
# postinst script for d7031-archive-keyring
#
# see: dh_installdeb(1)

set -e

# keyrings
KEYRING_ADD=/usr/share/keyrings/d7031-archive-keyring.gpg
KEYRING_DEL=/usr/share/keyrings/d7031-archive-removed-keys.gpg

# add the keys in the keyring and remove the keys found in the other
# from the apt-secure gpg keyring.
if [ -x "`which apt-key 2>/dev/null`" ]; then
	apt-key add $KEYRING_ADD > /dev/null
	
	keys=`gpg --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring $KEYRING_DEL --with-colons --list-keys | grep ^pub | cut -d: -f5`
	for key in $keys; do
		apt-key del ${key} > /dev/null || true
	done
fi

#DEBHELPER#

exit 0
