post_upgrade() {
	if [ -x usr/bin/pacman-key ]; then
		usr/bin/pacman-key --populate archlinux32

		# When the expiry of a master key is extended, its new
		# self-signature supersedes the one our local signature was made
		# over, so that local signature stops counting and every key
		# certified by this master shows up as "marginal trust".
		# Re-signing alone does not help: gpg refuses to add a second
		# local signature to a key it considers signed, and pacman-key's
		# "locally signed" test only looks for any local signature. So
		# the stale one has to go: delete the trusted masters and let the
		# populate below import and sign them anew from the shipped
		# keyring. Only the keys listed as trusted are touched, the rest
		# of the keyring is left alone.
		keyids=$(cut -d: -f1 usr/share/pacman/keyrings/archlinux32-trusted 2>/dev/null)
		if [ -n "$keyids" ]; then
			for keyid in $keyids; do
				if usr/bin/pacman-key --list-keys "$keyid" >/dev/null 2>&1; then
					(
						usr/bin/pacman-key --delete "$keyid" >/dev/null 2>&1
					) || :
				fi
			done
			usr/bin/pacman-key --populate archlinux32
		fi
	fi
}

post_install() {
	if [ -x usr/bin/pacman-key ]; then
		usr/bin/pacman-key --populate archlinux32
	fi
}
