Imported Upstream version 1.4.19
[platform/upstream/m4.git] / build-aux / gnupload
index 8d0299d..6283aa7 100755 (executable)
@@ -1,9 +1,9 @@
 #!/bin/sh
 # Sign files and upload them.
 
-scriptversion=2016-01-11.22; # UTC
+scriptversion=2021-04-11.09; # UTC
 
-# Copyright (C) 2004-2016 Free Software Foundation, Inc.
+# Copyright (C) 2004-2021 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@ scriptversion=2016-01-11.22; # UTC
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # Originally written by Alexandre Duret-Lutz <adl@gnu.org>.
 # The master copy of this file is maintained in the gnulib Git repository.
@@ -24,7 +24,30 @@ scriptversion=2016-01-11.22; # 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.:
@@ -78,7 +101,7 @@ in the current working directory, its contents are prepended to the
 actual command line options.  Use this to keep your defaults.  Comments
 (#) and empty lines in $conffile are allowed.
 
-<http://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html>
+<https://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html>
 gives some further background.
 
 Examples:
@@ -93,12 +116,22 @@ Examples:
            --symlink-regex \\
            foobar-1.0.tar.gz foobar-1.0.tar.xz
 
-4. Upload foobar-0.9.90.tar.gz to two sites:
+4. Create a symbolic link foobar-latest.tar.gz -> foobar-1.0.tar.gz
+   and likewise for the corresponding .sig file:
+  gnupload --to ftp.gnu.org:foobar \\
+           --symlink foobar-1.0.tar.gz     foobar-latest.tar.gz \\
+                     foobar-1.0.tar.gz.sig foobar-latest.tar.gz.sig
+  or (equivalent):
+  gnupload --to ftp.gnu.org:foobar \\
+           --symlink foobar-1.0.tar.gz     foobar-latest.tar.gz \\
+           --symlink foobar-1.0.tar.gz.sig foobar-latest.tar.gz.sig
+
+5. Upload foobar-0.9.90.tar.gz to two sites:
   gnupload --to alpha.gnu.org:foobar \\
            --to sources.redhat.com:~ftp/pub/foobar \\
            foobar-0.9.90.tar.gz
 
-5. Delete oopsbar-0.9.91.tar.gz and upload foobar-0.9.91.tar.gz
+6. Delete oopsbar-0.9.91.tar.gz and upload foobar-0.9.91.tar.gz
    (the -- terminates the list of files to delete):
   gnupload --to alpha.gnu.org:foobar \\
            --to sources.redhat.com:~ftp/pub/foobar \\
@@ -108,10 +141,16 @@ Examples:
 gnupload executes a program ncftpput to do the transfers; if you don't
 happen to have an ncftp package installed, the ncftpput-ftp script in
 the build-aux/ directory of the gnulib package
-(http://savannah.gnu.org/projects/gnulib) may serve as a replacement.
+(https://savannah.gnu.org/projects/gnulib) may serve as a replacement.
 
 Send patches and bug reports to <bug-gnulib@gnu.org>."
 
+copyright_year=`echo "$scriptversion" | sed -e 's/[^0-9].*//'`
+copyright="Copyright (C) ${copyright_year} Free Software Foundation, Inc.
+License GPLv2+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law."
+
 # Read local configuration file
 if test -r "$conffile"; then
   echo "$0: Reading configuration file $conffile"
@@ -125,7 +164,7 @@ while test -n "$1"; do
   -*)
     collect_var=
     case $1 in
-    --help)
+    -h | --help)
       echo "$usage"
       exit $?
       ;;
@@ -171,12 +210,13 @@ while test -n "$1"; do
     --symlink)
       collect_var=symlink_files
       ;;
-    --dry-run|-n)
+    -n | --dry-run)
       dry_run=:
       ;;
     --version)
       echo "gnupload $scriptversion"
-      exit $?
+      echo "$copyright"
+      exit 0
       ;;
     --)
       shift
@@ -432,7 +472,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"