* Makefile.maint (alpha beta major): Fix syntax error.
[coreutils.git] / gnupload
blob04363faa64d75b4fb8de844dfe6badc45bb47fe0
1 #!/bin/sh
2 # Sign files and upload them.
4 scriptversion=2006-05-20.00
6 # Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
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.
34 Options:
35 --help print this help text and exit
36 --to DEST specify one destination for FILES
37 (multiple --to options are allowed)
38 --user NAME sign with key NAME
39 --version output version information and exit
41 Recognized destinations are:
42 alpha.gnu.org:DIRECTORY
43 savannah.gnu.org:DIRECTORY
44 savannah.nongnu.org:DIRECTORY
45 ftp.gnu.org:DIRECTORY
46 build directive files and upload files by FTP
47 [user@]host:DIRECTORY upload files with scp
49 Example:
50 gnupload --to sources.redhat.com:~ftp/pub/automake \\
51 ""--to alpha.gnu.org:automake \\
52 automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
54 Report bugs to <bug-automake@gnu.org>.
55 Send patches to <automake-patches@gnu.org>."
57 while test -n "$1"; do
58 case $1 in
59 --help)
60 echo "$usage"
61 exit $?
63 --to)
64 if test -z "$2"; then
65 echo "$0: Missing argument for --to" 1>&2
66 exit 1
67 else
68 to="$to $2"
69 shift 2
72 --user)
73 if test -z "$2"; then
74 echo "$0: Missing argument for --user" 1>&2
75 exit 1
76 else
77 GPG="$GPG --local-user $2"
78 shift 2
81 --version)
82 echo "gnupload $scriptversion"
83 exit $?
85 -*)
86 echo "$0: Unknown option \`$1', try \`$0 --help'" 1>&2
87 exit 1
90 break
92 esac
93 done
95 if test $# = 0; then
96 echo "$0: No file to upload" 1>&2
97 exit 1
98 else
102 # Make sure all files exist. We don't want to ask
103 # for the passphrase if the script will fail.
104 for file;
106 if test ! -f $file; then
107 echo "$0: Cannot find \`$file'" 1>&2
108 exit 1
109 else
112 done
114 # Make sure passphrase is not exported in the environment.
115 unset passphrase
117 # Reset PATH to be sure that echo is a built-in. We will later use
118 # `echo $passphrase' to output the passphrase, so it is important that
119 # it is a built-in (third-party programs tend to appear in `ps'
120 # listings with their arguments...).
121 # Remember this script runs with `set -e', so if echo is not built-in
122 # it will exit now.
123 PATH=/empty echo -n "Enter GPG passphrase: "
124 stty -echo
125 read -r passphrase
126 stty echo
127 echo
129 for file;
131 echo "Signing $file..."
132 rm -f $file.sig
133 echo $passphrase | $GPG --passphrase-fd 0 -ba -o $file.sig $file
134 done
136 for dest in $to;
138 for file;
140 echo "Uploading $file to $dest..."
141 files="$file $file.sig"
142 destdir=`echo $dest | sed 's/[^:]*://'`
143 case $dest in
144 alpha.gnu.org:*)
145 rm -f $file.directive $file.directive.asc
146 echo directory: $destdir >$file.directive
147 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
148 ncftpput ftp-upload.gnu.org /incoming/alpha $files $file.directive.asc
149 rm -f $file.directive $file.directive.asc
151 ftp.gnu.org:*)
152 rm -f $file.directive $file.directive.asc
153 echo directory: $destdir >$file.directive
154 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
155 ncftpput ftp-upload.gnu.org /incoming/ftp $files $file.directive.asc
156 rm -f $file.directive $file.directive.asc
158 savannah.gnu.org:*)
159 ncftpput savannah.gnu.org /incoming/savannah/$destdir $files
161 savannah.nongnu.org:*)
162 ncftpput savannah.nongnu.org /incoming/savannah/$destdir $files
165 scp $files $dest
167 esac
168 done
169 done
171 # Local variables:
172 # eval: (add-hook 'write-file-hooks 'time-stamp)
173 # time-stamp-start: "scriptversion="
174 # time-stamp-format: "%:y-%02m-%02d.%02H"
175 # time-stamp-end: "$"
176 # End: