+merge_all_trusted_keyrings_into_pubring() {
+ # does the same as:
+ # foreach_keyring_do 'import_keys_from_keyring' "${GPGHOMEDIR}/pubring.gpg"
+ # but without using gpg, just cat and find
+ local PUBRING="${GPGHOMEDIR}/pubring.gpg"
+ # if a --keyring was given, just use this one
+ if [ -n "$FORCED_KEYRING" ]; then
+ if [ -s "$FORCED_KEYRING" ]; then
+ cp --dereference "$FORCED_KEYRING" "$PUBRING"
+ fi
+ else
+ # otherwise all known keyrings are merged
+ local TRUSTEDPARTS="/etc/apt/trusted.gpg.d"
+ eval $(apt-config shell TRUSTEDPARTS Dir::Etc::TrustedParts/d)
+ if [ -d "$TRUSTEDPARTS" ]; then
+ # ignore errors mostly for non-existing $TRUSTEDFILE
+ cat /dev/null "$TRUSTEDFILE" $(find -L "$TRUSTEDPARTS" -type f -name '*.gpg') > "$PUBRING" 2>/dev/null || true
+ elif [ -s "$TRUSTEDFILE" ]; then
+ cp --dereference "$TRUSTEDFILE" "$PUBRING"
+ fi
+ fi
+
+ if [ ! -s "$PUBRING" ]; then
+ touch "$PUBRING"
+ fi
+}
+