[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnupload and gpg2

From: Bruno Haible
Subject: gnupload and gpg2
Date: Thu, 17 May 2018 22:46:57 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-119-generic; KDE/5.18.0; x86_64; ; )

Reviving this thread from

The problem is explained in

Namely, when gpg-agent is of version 2, and gpg is of version 1,
one MUST use 'gpg2', not 'gpg'.

Jim Meyering's solution was:
> You should be able to get the desired effect without changing the
> tool: instead, create a symlink in a directory that is earlier than
> that of gpg (e.g., in your ~/bin directory) that is named "gpg" and
> that points to the program you want to use in its place.  Then it
> should just work.

The problem is that not everyone has `gpg --version` = 2.x.

In particular, Ubuntu 2016.04 (which is supported until April 2021,
that is, 3 years from now), has `gpg --version` = 1.x.

And in particular, the "solution" to place a symlink is one that
was effective for Phillip Lord, but every user of 'gnupload' has to
repeat the same experience and lose half an hour of time searching
for the solution.

Here's a proposed patch to reduce the friction:

2018-05-17  Bruno Haible  <address@hidden>

        gnupload: Fix "gpg-agent is not available in this session" error.
        * build-aux/gnupload (GPG): Pick the right GNUPG executable to use.

diff --git a/build-aux/gnupload b/build-aux/gnupload
index 2a0bfa3..21927ee 100755
--- a/build-aux/gnupload
+++ b/build-aux/gnupload
@@ -24,7 +24,31 @@ scriptversion=2018-03-07.03; # UTC
 set -e
-GPG='gpg --batch --no-tty'
+# 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_version=`(gpg --version) 2>/dev/null | sed -e '2,$d' -e 's/^[^0-9]*//'`
+gpg_agent_version=`(gpg-agent --version) 2>/dev/null | sed -e '2,$d' -e 
+case "$gpg_agent_version" in
+  2.*)
+    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
+    ;;
+GPG="${GPG} --batch --no-tty"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]