2 # Sign files and upload them.
4 scriptversion=2008-11-12.21
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)
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 Report bugs to <bug-automake@gnu.org>.
66 Send patches to <automake-patches@gnu.org>."
68 while test -n "$1"; do
80 echo "$0: Missing argument for --to" 1>&2
89 echo "$0: Missing argument for --user" 1>&2
92 GPG="$GPG --local-user $2"
97 echo "gnupload $scriptversion"
101 echo "$0: Unknown option \`$1', try \`$0 --help'" 1>&2
111 echo "$0: No file to upload or delete" 1>&2
117 if $delete; then :; else
118 # Make sure all files exist. We don't want to ask
119 # for the passphrase if the script will fail.
122 if test ! -f $file; then
123 echo "$0: Cannot find \`$file'" 1>&2
131 # Make sure passphrase is not exported in the environment.
134 # Reset PATH to be sure that echo is a built-in. We will later use
135 # `echo $passphrase' to output the passphrase, so it is important that
136 # it is a built-in (third-party programs tend to appear in `ps'
137 # listings with their arguments...).
138 # Remember this script runs with `set -e', so if echo is not built-in
140 PATH=/empty echo -n "Enter GPG passphrase: "
146 # Nothing to sign if deleting.
147 if $delete; then :; else
150 echo "Signing $file..."
152 echo $passphrase | $GPG --passphrase-fd 0 -ba -o $file.sig $file
162 echo "Removing $file from $dest..."
163 files= # nothing to upload if deleting
164 directive="archive: $file"
166 echo "Uploading $file to $dest..."
167 files="$file $file.sig"
168 directive="filename: "`basename -- "$file"`
170 destdir=`echo $dest | sed 's/[^:]*://'`
174 rm -f $file.directive $file.directive.asc
175 cat >$file.directive<<EOF
180 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
181 ncftpput ftp-upload.gnu.org /incoming/alpha $files $file.directive.asc
182 rm -f $file.directive $file.directive.asc
185 rm -f $file.directive $file.directive.asc
186 cat >$file.directive<<EOF
191 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
192 ncftpput ftp-upload.gnu.org /incoming/ftp $files $file.directive.asc
193 rm -f $file.directive $file.directive.asc
196 # We only know how to implement delete for {ftp,alpha}.gnu.org.
198 || ncftpput savannah.gnu.org /incoming/savannah/$destdir $files
200 savannah.nongnu.org:*)
202 || ncftpput savannah.nongnu.org /incoming/savannah/$destdir $files
213 # eval: (add-hook 'write-file-hooks 'time-stamp)
214 # time-stamp-start: "scriptversion="
215 # time-stamp-format: "%:y-%02m-%02d.%02H"
216 # time-stamp-end: "$"