2 # Sign files and upload them.
4 scriptversion=2009-01-30.00
6 # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 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)
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>.
25 GPG='gpg --batch --no-tty'
29 usage="Usage: $0 [OPTIONS]... FILES...
31 Sign all FILES, and upload them to (or delete them from) selected
32 destinations, according to
33 <http://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html>.
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 --delete delete FILES from destination instead of uploading
41 --version output version information and exit
43 Recognized destinations are:
44 alpha.gnu.org:DIRECTORY
45 savannah.gnu.org:DIRECTORY
46 savannah.nongnu.org:DIRECTORY
48 build directive files and upload files by FTP
49 [user@]host:DIRECTORY upload files with scp
51 Deletion only works for ftp.gnu.org and alpha.gnu.org (using the
52 archive: directive). Otherwise it is a no-op. Deleting a file foo also
53 deletes foo.sig; do not specify the .sig explicitly.
55 Simple single-target single-file examples:
56 gnupload --to alpha.gnu.org:automake automake-1.8.2b.tar.gz
57 gnupload --to ftp.gnu.org:automake automake-1.8.3.tar.gz
58 gnupload --to alpha.gnu.org:automake --delete automake-oops.tar.gz
60 Multiple-target multiple-file example:
61 gnupload --to sources.redhat.com:~ftp/pub/automake \\
62 --to alpha.gnu.org:automake \\
63 automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
65 You can get the latest version of this script from savannah:
66 <http://git.savannah.gnu.org/cgit/automake.git/plain/lib/gnupload>
68 Report bugs to <bug-automake@gnu.org>.
69 Send patches to <automake-patches@gnu.org>."
71 while test -n "$1"; do
83 echo "$0: Missing argument for --to" 1>&2
92 echo "$0: Missing argument for --user" 1>&2
95 GPG="$GPG --local-user $2"
100 echo "gnupload $scriptversion"
104 echo "$0: Unknown option \`$1', try \`$0 --help'" 1>&2
114 echo "$0: No file to upload or delete" 1>&2
120 if $delete; then :; else
121 # Make sure all files exist. We don't want to ask
122 # for the passphrase if the script will fail.
125 if test ! -f $file; then
126 echo "$0: Cannot find \`$file'" 1>&2
134 # Make sure passphrase is not exported in the environment.
137 # Reset PATH to be sure that echo is a built-in. We will later use
138 # `echo $passphrase' to output the passphrase, so it is important that
139 # it is a built-in (third-party programs tend to appear in `ps'
140 # listings with their arguments...).
141 # Remember this script runs with `set -e', so if echo is not built-in
143 PATH=/empty echo -n "Enter GPG passphrase: "
149 # Nothing to sign if deleting.
150 if $delete; then :; else
153 echo "Signing $file..."
155 echo $passphrase | $GPG --passphrase-fd 0 -ba -o $file.sig $file
165 echo "Removing $file from $dest..."
166 files= # nothing to upload if deleting
167 directive="archive: $file"
169 echo "Uploading $file to $dest..."
170 files="$file $file.sig"
171 directive="filename: "`basename -- "$file"`
173 destdir=`echo $dest | sed 's/[^:]*://'`
177 rm -f $file.directive $file.directive.asc
178 cat >$file.directive<<EOF
183 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
184 ncftpput ftp-upload.gnu.org /incoming/alpha $files $file.directive.asc
185 rm -f $file.directive $file.directive.asc
188 rm -f $file.directive $file.directive.asc
189 cat >$file.directive<<EOF
194 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
195 ncftpput ftp-upload.gnu.org /incoming/ftp $files $file.directive.asc
196 rm -f $file.directive $file.directive.asc
199 # We only know how to implement delete for {ftp,alpha}.gnu.org.
201 || ncftpput savannah.gnu.org /incoming/savannah/$destdir $files
203 savannah.nongnu.org:*)
205 || ncftpput savannah.nongnu.org /incoming/savannah/$destdir $files
216 # eval: (add-hook 'write-file-hooks 'time-stamp)
217 # time-stamp-start: "scriptversion="
218 # time-stamp-format: "%:y-%02m-%02d.%02H"
219 # time-stamp-end: "$"