#!/bin/bash -e
EPREFIX=$(portageq envvar EPREFIX)
tempdir=$(mktemp -d)

cleanup() {
	gpgconf --kill gpg-agent
	rm -rf "${tempdir}"
}

trap cleanup EXIT
export GNUPGHOME=${tempdir}
echo trust-model always > "${tempdir}/gpg.conf"
echo disable-scdaemon > "${tempdir}/gpg-agent.conf"
gpg --import <(cat "${EPREFIX}/var/lib/gentoo/gkeys/keyrings/gentoo/release/pubring.gpg")
gpg --refresh-keys
