source: trunk/essentials/sys-devel/automake-1.10/lib/gnupload

Last change on this file was 3147, checked in by bird, 18 years ago

automake 1.10

File size: 4.5 KB
Line 
1#!/bin/sh
2# Sign files and upload them.
3
4scriptversion=2006-05-11.09
5
6# Copyright (C) 2004, 2005, 2006 Free Software Foundation
7#
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.
12#
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.
17#
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.
22
23# Originally written by Alexandre Duret-Lutz <adl@gnu.org>.
24
25set -e
26
27GPG='/usr/bin/gpg --batch --no-tty'
28to=
29
30usage="Usage: $0 [OPTIONS]... FILES...
31
32Sign all FILES, and upload them to selected destinations.
33
34Options:
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
40
41Recognized 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
48
49Example:
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
53
54Report bugs to <bug-automake@gnu.org>.
55Send patches to <automake-patches@gnu.org>."
56
57while test -n "$1"; do
58 case $1 in
59 --help)
60 echo "$usage"
61 exit $?
62 ;;
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
70 fi
71 ;;
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
79 fi
80 ;;
81 --version)
82 echo "gnupload $scriptversion"
83 exit $?
84 ;;
85 -*)
86 echo "$0: Unknown option \`$1', try \`$0 --help'" 1>&2
87 exit 1
88 ;;
89 *)
90 break
91 ;;
92 esac
93done
94
95if test $# = 0; then
96 echo "$0: No file to upload" 1>&2
97 exit 1
98else
99 :
100fi
101
102# Make sure all files exist. We don't want to ask
103# for the passphrase if the script will fail.
104for file;
105do
106 if test ! -f $file; then
107 echo "$0: Cannot find \`$file'" 1>&2
108 exit 1
109 else
110 :
111 fi
112done
113
114# Make sure passphrase is not exported in the environment.
115unset passphrase
116
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.
123PATH=/empty echo -n "Enter GPG passphrase: "
124stty -echo
125read -r passphrase
126stty echo
127echo
128
129for file;
130do
131 echo "Signing $file..."
132 rm -f $file.sig
133 echo $passphrase | $GPG --passphrase-fd 0 -ba -o $file.sig $file
134done
135
136for dest in $to;
137do
138 for file;
139 do
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
150 ;;
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
157 ;;
158 savannah.gnu.org:*)
159 ncftpput savannah.gnu.org /incoming/savannah/$destdir $files
160 ;;
161 savannah.nongnu.org:*)
162 ncftpput savannah.nongnu.org /incoming/savannah/$destdir $files
163 ;;
164 *)
165 scp $files $dest
166 ;;
167 esac
168 done
169done
170
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:
Note: See TracBrowser for help on using the repository browser.