]> Savannah Git Hosting - gnulib.git/commitdiff
gnupload: Fix "gpg-agent is not available in this session" error.
authorBruno Haible <bruno@clisp.org>
Sat, 19 May 2018 11:00:16 +0000 (13:00 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 19 May 2018 11:00:16 +0000 (13:00 +0200)
* build-aux/gnupload (GPG): Pick the right GNUPG executable to use.

ChangeLog
build-aux/gnupload

index dd479f783f29b912e4f7e65fea4b0d1bfcf58333..047dadf65706a7baabe4bef383068b41c9dfbb5f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-05-19  Bruno Haible  <bruno@clisp.org>
+
+       gnupload: Fix "gpg-agent is not available in this session" error.
+       * build-aux/gnupload (GPG): Pick the right GNUPG executable to use.
+
 2018-05-16  Paul Eggert  <eggert@cs.ucla.edu>
 
        crypto/af_alg: fix --help
index 2a0bfa3b5198d0f59f8a0cfb3f0e727394dd5e5e..0d92923eaf66e08b4995d69f075c2080950f312d 100755 (executable)
@@ -24,7 +24,31 @@ scriptversion=2018-03-07.03; # UTC
 
 set -e
 
-GPG='gpg --batch --no-tty'
+GPG=gpg
+# Choose the proper version of gpg, so as to avoid a
+# "gpg-agent is not available in this session" error
+# when gpg-agent is version 2 but gpg is still version 1.
+# This code can go away once all major distributions ship gpg version 2
+# as /usr/bin/gpg.
+gpg_agent_version=`(gpg-agent --version) 2>/dev/null | sed -e '2,$d' -e 's/^[^0-9]*//'`
+case "$gpg_agent_version" in
+  2.*)
+    gpg_version=`(gpg --version) 2>/dev/null | sed -e '2,$d' -e 's/^[^0-9]*//'`
+    case "$gpg_version" in
+      1.*)
+        if (type gpg2) >/dev/null 2>/dev/null; then
+          # gpg2 is present.
+          GPG=gpg2
+        else
+          # gpg2 is missing. Ubuntu users should install the package 'gnupg2'.
+          echo "WARNING: Using 'gpg', which is too old. You should install 'gpg2'." 1>&2
+        fi
+        ;;
+    esac
+    ;;
+esac
+
+GPG="${GPG} --batch --no-tty"
 conffile=.gnuploadrc
 to=
 dry_run=false