X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/803491dc568d2994745c3c4359f68053f7261658..6dcae298f972eb20223838f0e1dc376c44bc9cc3:/cmdline/apt-key.in diff --git a/cmdline/apt-key.in b/cmdline/apt-key.in index 80eee6265..b309142cf 100644 --- a/cmdline/apt-key.in +++ b/cmdline/apt-key.in @@ -191,6 +191,10 @@ remove_key_from_keyring() { for KEY in "$@"; do local FINGERPRINTS="${GPGHOMEDIR}/keyringfile.keylst" get_fingerprints_of_keyring "$KEYRINGFILE" > "$FINGERPRINTS" + + # strip leading 0x, if present: + KEY="${KEY#0x}" + # check if the key is in this keyring if ! grep -iq "^[0-9A-F]*${KEY}$" "$FINGERPRINTS"; then continue @@ -489,8 +493,21 @@ create_gpg_home() { } prepare_gpg_home() { + # crude detection if we are called from a maintainerscript where the + # package depends on gnupg or not. We accept recommends here as + # well as the script hopefully uses apt-key optionally then like e.g. + # debian-archive-keyring for (upgrade) cleanup did + if [ -n "$DPKG_MAINTSCRIPT_PACKAGE" ]; then + if ! dpkg-query --show --showformat '${Pre-Depends}${Depends}${Recommends}\n' "$DPKG_MAINTSCRIPT_PACKAGE" 2>/dev/null | grep -q gnupg; then + cat >&2 <