Fix autoheader 2.62 regression on AC_DEFINE([__EXTENSIONS__]).
[autoconf.git] / build-aux / gnupload
blob6621ebd8b7f6e52596b85c7e260fff256e3603e6
1 #!/bin/sh
2 # Sign files and upload them.
4 scriptversion=2008-04-02.19
6 # Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3, or (at your option)
11 # any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # Originally written by Alexandre Duret-Lutz <adl@gnu.org>.
23 set -e
25 GPG='gpg --batch --no-tty'
26 to=
28 usage="Usage: $0 [OPTIONS]... FILES...
30 Sign all FILES, and upload them to selected destinations, according to
31 <http://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html>.
33 Options:
34 --help print this help text and exit
35 --to DEST specify one destination for FILES
36 (multiple --to options are allowed)
37 --user NAME sign with key NAME
38 --version output version information and exit
40 Recognized destinations are:
41 alpha.gnu.org:DIRECTORY
42 savannah.gnu.org:DIRECTORY
43 savannah.nongnu.org:DIRECTORY
44 ftp.gnu.org:DIRECTORY
45 build directive files and upload files by FTP
46 [user@]host:DIRECTORY upload files with scp
48 Example:
49 gnupload --to sources.redhat.com:~ftp/pub/automake \\
50 --to alpha.gnu.org:automake \\
51 automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
53 Report bugs to <bug-automake@gnu.org>.
54 Send patches to <automake-patches@gnu.org>."
56 while test -n "$1"; do
57 case $1 in
58 --help)
59 echo "$usage"
60 exit $?
62 --to)
63 if test -z "$2"; then
64 echo "$0: Missing argument for --to" 1>&2
65 exit 1
66 else
67 to="$to $2"
68 shift 2
71 --user)
72 if test -z "$2"; then
73 echo "$0: Missing argument for --user" 1>&2
74 exit 1
75 else
76 GPG="$GPG --local-user $2"
77 shift 2
80 --version)
81 echo "gnupload $scriptversion"
82 exit $?
84 -*)
85 echo "$0: Unknown option \`$1', try \`$0 --help'" 1>&2
86 exit 1
89 break
91 esac
92 done
94 if test $# = 0; then
95 echo "$0: No file to upload" 1>&2
96 exit 1
97 else
101 # Make sure all files exist. We don't want to ask
102 # for the passphrase if the script will fail.
103 for file
105 if test ! -f $file; then
106 echo "$0: Cannot find \`$file'" 1>&2
107 exit 1
108 else
111 done
113 # Make sure passphrase is not exported in the environment.
114 unset passphrase
116 # Reset PATH to be sure that echo is a built-in. We will later use
117 # `echo $passphrase' to output the passphrase, so it is important that
118 # it is a built-in (third-party programs tend to appear in `ps'
119 # listings with their arguments...).
120 # Remember this script runs with `set -e', so if echo is not built-in
121 # it will exit now.
122 PATH=/empty echo -n "Enter GPG passphrase: "
123 stty -echo
124 read -r passphrase
125 stty echo
126 echo
128 for file
130 echo "Signing $file..."
131 rm -f $file.sig
132 echo $passphrase | $GPG --passphrase-fd 0 -ba -o $file.sig $file
133 done
135 for dest in $to
137 for file
139 echo "Uploading $file to $dest..."
140 files="$file $file.sig"
141 destdir=`echo $dest | sed 's/[^:]*://'`
142 case $dest in
143 alpha.gnu.org:*)
144 rm -f $file.directive $file.directive.asc
145 cat >$file.directive<<EOF
146 version: 1.1
147 directory: $destdir
148 filename: `basename -- "$file"`
150 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
151 ncftpput ftp-upload.gnu.org /incoming/alpha $files $file.directive.asc
152 rm -f $file.directive $file.directive.asc
154 ftp.gnu.org:*)
155 rm -f $file.directive $file.directive.asc
156 cat >$file.directive<<EOF
157 version: 1.1
158 directory: $destdir
159 filename: `basename -- "$file"`
161 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
162 ncftpput ftp-upload.gnu.org /incoming/ftp $files $file.directive.asc
163 rm -f $file.directive $file.directive.asc
165 savannah.gnu.org:*)
166 ncftpput savannah.gnu.org /incoming/savannah/$destdir $files
168 savannah.nongnu.org:*)
169 ncftpput savannah.nongnu.org /incoming/savannah/$destdir $files
172 scp $files $dest
174 esac
175 done
176 done
178 # Local variables:
179 # eval: (add-hook 'write-file-hooks 'time-stamp)
180 # time-stamp-start: "scriptversion="
181 # time-stamp-format: "%:y-%02m-%02d.%02H"
182 # time-stamp-end: "$"
183 # End: