Change GPLv2+ to GPLv3+.
[shishi.git] / build-aux / gnupload
bloba8e6d66e3863b1be0762456bb5915aadd0e750e5
1 #!/bin/sh
2 # Sign files and upload them.
4 scriptversion=2006-11-12.11
6 # Copyright (C) 2004, 2005, 2006 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 2, 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, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 # 02110-1301, USA.
23 # Originally written by Alexandre Duret-Lutz <adl@gnu.org>.
25 set -e
27 GPG='/usr/bin/gpg --batch --no-tty'
28 to=
30 usage="Usage: $0 [OPTIONS]... FILES...
32 Sign all FILES, and upload them to selected destinations, according to
33 <http://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html>.
35 Options:
36 --help print this help text and exit
37 --to DEST specify one destination for FILES
38 (multiple --to options are allowed)
39 --user NAME sign with key NAME
40 --version output version information and exit
42 Recognized destinations are:
43 alpha.gnu.org:DIRECTORY
44 savannah.gnu.org:DIRECTORY
45 savannah.nongnu.org:DIRECTORY
46 ftp.gnu.org:DIRECTORY
47 build directive files and upload files by FTP
48 [user@]host:DIRECTORY upload files with scp
50 Example:
51 gnupload --to sources.redhat.com:~ftp/pub/automake \\
52 --to alpha.gnu.org:automake \\
53 automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
55 Report bugs to <bug-automake@gnu.org>.
56 Send patches to <automake-patches@gnu.org>."
58 while test -n "$1"; do
59 case $1 in
60 --help)
61 echo "$usage"
62 exit $?
64 --to)
65 if test -z "$2"; then
66 echo "$0: Missing argument for --to" 1>&2
67 exit 1
68 else
69 to="$to $2"
70 shift 2
73 --user)
74 if test -z "$2"; then
75 echo "$0: Missing argument for --user" 1>&2
76 exit 1
77 else
78 GPG="$GPG --local-user $2"
79 shift 2
82 --version)
83 echo "gnupload $scriptversion"
84 exit $?
86 -*)
87 echo "$0: Unknown option \`$1', try \`$0 --help'" 1>&2
88 exit 1
91 break
93 esac
94 done
96 if test $# = 0; then
97 echo "$0: No file to upload" 1>&2
98 exit 1
99 else
103 # Make sure all files exist. We don't want to ask
104 # for the passphrase if the script will fail.
105 for file;
107 if test ! -f $file; then
108 echo "$0: Cannot find \`$file'" 1>&2
109 exit 1
110 else
113 done
115 # Make sure passphrase is not exported in the environment.
116 unset passphrase
118 # Reset PATH to be sure that echo is a built-in. We will later use
119 # `echo $passphrase' to output the passphrase, so it is important that
120 # it is a built-in (third-party programs tend to appear in `ps'
121 # listings with their arguments...).
122 # Remember this script runs with `set -e', so if echo is not built-in
123 # it will exit now.
124 PATH=/empty echo -n "Enter GPG passphrase: "
125 stty -echo
126 read -r passphrase
127 stty echo
128 echo
130 for file;
132 echo "Signing $file..."
133 rm -f $file.sig
134 echo $passphrase | $GPG --passphrase-fd 0 -ba -o $file.sig $file
135 done
137 for dest in $to;
139 for file;
141 echo "Uploading $file to $dest..."
142 files="$file $file.sig"
143 destdir=`echo $dest | sed 's/[^:]*://'`
144 case $dest in
145 alpha.gnu.org:*)
146 rm -f $file.directive $file.directive.asc
147 cat >$file.directive<<EOF
148 version: 1.1
149 directory: $destdir
150 filename: $file
152 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
153 ncftpput ftp-upload.gnu.org /incoming/alpha $files $file.directive.asc
154 rm -f $file.directive $file.directive.asc
156 ftp.gnu.org:*)
157 rm -f $file.directive $file.directive.asc
158 cat >$file.directive<<EOF
159 version: 1.1
160 directory: $destdir
161 filename: $file
163 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
164 ncftpput ftp-upload.gnu.org /incoming/ftp $files $file.directive.asc
165 rm -f $file.directive $file.directive.asc
167 savannah.gnu.org:*)
168 ncftpput savannah.gnu.org /incoming/savannah/$destdir $files
170 savannah.nongnu.org:*)
171 ncftpput savannah.nongnu.org /incoming/savannah/$destdir $files
174 scp $files $dest
176 esac
177 done
178 done
180 # Local variables:
181 # eval: (add-hook 'write-file-hooks 'time-stamp)
182 # time-stamp-start: "scriptversion="
183 # time-stamp-format: "%:y-%02m-%02d.%02H"
184 # time-stamp-end: "$"
185 # End: