summaryrefslogtreecommitdiff
path: root/cmdline/apt-key.in
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-01-26 18:28:50 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-09-27 00:12:14 +0200
commit93d0d08cdd6854f9bfb779c13b5b78cd6ed263aa (patch)
tree6b7d5a4f313fc2fe90a25b6aa517ce50635703bb /cmdline/apt-key.in
parent059911800900a42c4246f1e209b51656055215b2 (diff)
support gnupg2 as drop-in replacement for gnupg
If both are available APT will still prefer gpg over gpg2 as it is a bit more lightweight, but it shouldn't be a problem to use one or the other (at least at the moment, who knows what will happen in the future).
Diffstat (limited to 'cmdline/apt-key.in')
-rw-r--r--cmdline/apt-key.in17
1 files changed, 13 insertions, 4 deletions
diff --git a/cmdline/apt-key.in b/cmdline/apt-key.in
index b8fdfe121..12aee9750 100644
--- a/cmdline/apt-key.in
+++ b/cmdline/apt-key.in
@@ -303,13 +303,22 @@ fi
shift
if [ "$command" != "help" ]; then
- if ! which gpg >/dev/null 2>&1; then
- echo >&2 "Warning: gnupg does not seem to be installed."
- echo >&2 "Warning: apt-key requires gnupg for most operations."
+ eval $(apt-config shell GPG_EXE Apt::Key::gpgcommand)
+
+ if [ -n "$GPG_EXE" ] && which "$GPG_EXE" >/dev/null 2>&1; then
+ true
+ elif which gpg >/dev/null 2>&1; then
+ GPG_EXE="gpg"
+ elif which gpg2 >/dev/null 2>&1; then
+ GPG_EXE="gpg2"
+ else
+ echo >&2 "Error: gnupg or gnupg2 do not seem to be installed,"
+ echo >&2 "Error: but apt-key requires gnupg or gnupg2 for operation."
echo >&2
+ exit 255
fi
- GPG_CMD="gpg --ignore-time-conflict --no-options --no-default-keyring"
+ GPG_CMD="$GPG_EXE --ignore-time-conflict --no-options --no-default-keyring"
# gpg needs (in different versions more or less) files to function correctly,
# so we give it its own homedir and generate some valid content for it