New upstream version 1.10
[debian/gzip] / build-aux / gnupload
index 90b8c4e6e637c3616ccee72e618056a8d12c9314..8f05700814f2ee30430d2fe8c5eeae5b9c881025 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Sign files and upload them.
 
-scriptversion=2017-09-13.06; # UTC
+scriptversion=2018-05-19.18; # UTC
 
 # Copyright (C) 2004-2018 Free Software Foundation, Inc.
 #
@@ -24,7 +24,30 @@ scriptversion=2017-09-13.06; # 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 3 but gpg is still version 1.
+# FIXME-2020: remove, once all major distros ship gpg version 3 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
@@ -54,10 +77,10 @@ Options:
   --user NAME              sign with key NAME
   --replace                allow replacements of existing files
   --symlink-regex[=EXPR]   use sed script EXPR to compute symbolic link names
-  --dry-run                do nothing, show what would have been done
+  -n, --dry-run            do nothing, show what would have been done
                            (including the constructed directive file)
   --version                output version information and exit
-  --help                   print this help text and exit
+  -h, --help               print this help text and exit
 
 If --symlink-regex is given without EXPR, then the link target name
 is created by replacing the version information with '-latest', e.g.:
@@ -125,7 +148,7 @@ while test -n "$1"; do
   -*)
     collect_var=
     case $1 in
-    --help)
+    -h | --help)
       echo "$usage"
       exit $?
       ;;
@@ -171,7 +194,7 @@ while test -n "$1"; do
     --symlink)
       collect_var=symlink_files
       ;;
-    --dry-run|-n)
+    -n | --dry-run)
       dry_run=:
       ;;
     --version)
@@ -432,7 +455,7 @@ done
 exit 0
 
 # Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
 # time-stamp-time-zone: "UTC0"