2 # Sign files and upload them.
4 scriptversion=2008-04-02.19
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'
28 usage="Usage: $0 [OPTIONS]... FILES...
30 Sign all FILES, and upload them to selected destinations, according to
31 <http://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html>.
34 --help print this help text and exit
35 --to DEST specify one destination for FILES
36 (multiple --to options are allowed)
37 --user NAME sign with key NAME
38 --version output version information and exit
40 Recognized destinations are:
41 alpha.gnu.org:DIRECTORY
42 savannah.gnu.org:DIRECTORY
43 savannah.nongnu.org:DIRECTORY
45 build directive files and upload files by FTP
46 [user@]host:DIRECTORY upload files with scp
48 Simple single-target single-file examples:
49 gnupload --to alpha.gnu.org:automake automake-1.8.2b.tar.gz
50 gnupload --to ftp.gnu.org:automake automake-1.8.3.tar.gz
52 Multiple-target multiple-file example:
53 gnupload --to sources.redhat.com:~ftp/pub/automake \\
54 --to alpha.gnu.org:automake \\
55 automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
57 Report bugs to <bug-automake@gnu.org>.
58 Send patches to <automake-patches@gnu.org>."
60 while test -n "$1"; do
68 echo "$0: Missing argument for --to" 1>&2
77 echo "$0: Missing argument for --user" 1>&2
80 GPG="$GPG --local-user $2"
85 echo "gnupload $scriptversion"
89 echo "$0: Unknown option \`$1', try \`$0 --help'" 1>&2
99 echo "$0: No file to upload" 1>&2
105 # Make sure all files exist. We don't want to ask
106 # for the passphrase if the script will fail.
109 if test ! -f $file; then
110 echo "$0: Cannot find \`$file'" 1>&2
117 # Make sure passphrase is not exported in the environment.
120 # Reset PATH to be sure that echo is a built-in. We will later use
121 # `echo $passphrase' to output the passphrase, so it is important that
122 # it is a built-in (third-party programs tend to appear in `ps'
123 # listings with their arguments...).
124 # Remember this script runs with `set -e', so if echo is not built-in
126 PATH=/empty echo -n "Enter GPG passphrase: "
134 echo "Signing $file..."
136 echo $passphrase | $GPG --passphrase-fd 0 -ba -o $file.sig $file
143 echo "Uploading $file to $dest..."
144 files="$file $file.sig"
145 destdir=`echo $dest | sed 's/[^:]*://'`
148 rm -f $file.directive $file.directive.asc
149 cat >$file.directive<<EOF
152 filename: `basename -- "$file"`
154 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
155 ncftpput ftp-upload.gnu.org /incoming/alpha $files $file.directive.asc
156 rm -f $file.directive $file.directive.asc
159 rm -f $file.directive $file.directive.asc
160 cat >$file.directive<<EOF
163 filename: `basename -- "$file"`
165 echo "$passphrase" | $GPG --passphrase-fd 0 --clearsign $file.directive
166 ncftpput ftp-upload.gnu.org /incoming/ftp $files $file.directive.asc
167 rm -f $file.directive $file.directive.asc
170 ncftpput savannah.gnu.org /incoming/savannah/$destdir $files
172 savannah.nongnu.org:*)
173 ncftpput savannah.nongnu.org /incoming/savannah/$destdir $files
183 # eval: (add-hook 'write-file-hooks 'time-stamp)
184 # time-stamp-start: "scriptversion="
185 # time-stamp-format: "%:y-%02m-%02d.%02H"
186 # time-stamp-end: "$"