(remove_dir): Return RM_ERROR, not `1',
[coreutils.git] / gnupload
blobb5c7e554590d2c75cf17fd0bcaa607a95d6d8819
1 #!/bin/sh
2 # Sign files and upload them.
4 scriptversion=2004-01-28.17
6 # Copyright (C) 2004 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.
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 build directive files and upload files by FTP
43 ftp.gnu.org:DIRECTORY build directive files and upload files by FTP
44 [user@]host:DIRECTORY upload files with scp
46 Example:
47 gnupload --to sources.redhat.com:~ftp/automake \\
48 --to alpha.gnu.org:automake \\
49 automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
51 Report bugs to <bug-automake@gnu.org>.
52 Send patches to <automake-patches@gnu.org>."
54 while test -n "$1"; do
55 case $1 in
56 --help)
57 echo "$usage"
58 exit 0
60 --to)
61 if test -z "$2"; then
62 echo "$0: Missing argument for --to" 1>&2
63 exit 1
64 else
65 to="$to $2"
66 shift 2
69 --user)
70 if test -z "$2"; then
71 echo "$0: Missing argument for --user" 1>&2
72 exit 1
73 else
74 GPG="$GPG --local-user $2"
75 shift 2
78 --version)
79 echo "gnupload $scriptversion"
80 exit 0
82 -*)
83 echo "$0: Unknown option \`$1', try \`$0 --help'" 1>&2
84 exit 1
87 break
89 esac
90 done
92 if test $# = 0; then
93 echo "$0: No file to upload" 1>&2
94 exit 1
95 else
99 # Make sure all files exist. We don't want to ask
100 # for the passphrase if the script will fail.
101 for file;
103 if test ! -f $file; then
104 echo "$0: Cannot find \`$file'" 1>&2
105 exit 1
106 else
109 done
111 # Make sure passphrase is not exported in the environment.
112 unset passphrase
114 # Reset PATH to be sure that echo is a built-in. We will later use
115 # `echo $passphrase' to output the passphrase, so it is important that
116 # it is a built-in (third-party programs tend to appear in `ps'
117 # listings with their arguments...).
118 # Remember this script runs with `set -e', so if echo is not built-in
119 # it will exit now.
120 PATH=/empty echo -n "Enter GPG passphrase: "
121 stty -echo
122 read -r passphrase
123 stty echo
124 echo
126 for file;
128 echo "Signing $file..."
129 rm -f $file.sig
130 echo $passphrase | $GPG --passphrase-fd 0 -ba -o $file.sig $file
131 done
133 for dest in $to;
135 for file;
137 echo "Uploading $file to $dest..."
138 files="$file $file.sig"
139 case $dest in
140 alpha.gnu.org:*)
141 rm -f $file.directive $file.directive.asc
142 echo directory: `echo $dest | sed 's/[^:]*://'` >$file.directive
143 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
144 ncftpput ftp-upload.gnu.org /incoming/alpha $files $file.directive.asc
145 rm -f $file.directive $file.directive.asc
147 ftp.gnu.org:*)
148 rm -f $file.directive $file.directive.asc
149 echo directory: `echo $dest | sed 's/[^:]*://'` >$file.directive
150 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
151 ncftpput ftp-upload.gnu.org /incoming/ftp $files $file.directive.asc
152 rm -f $file.directive $file.directive.asc
155 scp $files $dest
157 esac
158 done
159 done
161 # Local variables:
162 # eval: (add-hook 'write-file-hooks 'time-stamp)
163 # time-stamp-start: "scriptversion="
164 # time-stamp-format: "%:y-%02m-%02d.%02H"
165 # time-stamp-end: "$"
166 # End: