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

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

automake 1.9.6

File size: 4.3 KB
Line 
1#!/bin/sh
2# Sign files and upload them.
3
4scriptversion=2005-05-14.22
5
6# Copyright (C) 2004, 2005 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 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
45
46Example:
47 gnupload --to sources.redhat.com:~ftp/pub/automake \\
48 --to alpha.gnu.org:automake \\
49 automake-1.8.2b.tar.gz automake-1.8.2b.tar.bz2
50
51Report bugs to <bug-automake@gnu.org>.
52Send patches to <automake-patches@gnu.org>."
53
54while test -n "$1"; do
55 case $1 in
56 --help)
57 echo "$usage"
58 exit $?
59 ;;
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
67 fi
68 ;;
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
76 fi
77 ;;
78 --version)
79 echo "gnupload $scriptversion"
80 exit $?
81 ;;
82 -*)
83 echo "$0: Unknown option \`$1', try \`$0 --help'" 1>&2
84 exit 1
85 ;;
86 *)
87 break
88 ;;
89 esac
90done
91
92if test $# = 0; then
93 echo "$0: No file to upload" 1>&2
94 exit 1
95else
96 :
97fi
98
99# Make sure all files exist. We don't want to ask
100# for the passphrase if the script will fail.
101for file;
102do
103 if test ! -f $file; then
104 echo "$0: Cannot find \`$file'" 1>&2
105 exit 1
106 else
107 :
108 fi
109done
110
111# Make sure passphrase is not exported in the environment.
112unset passphrase
113
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.
120PATH=/empty echo -n "Enter GPG passphrase: "
121stty -echo
122read -r passphrase
123stty echo
124echo
125
126for file;
127do
128 echo "Signing $file..."
129 rm -f $file.sig
130 echo $passphrase | $GPG --passphrase-fd 0 -ba -o $file.sig $file
131done
132
133for dest in $to;
134do
135 for file;
136 do
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
146 ;;
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
153 ;;
154 *)
155 scp $files $dest
156 ;;
157 esac
158 done
159done
160
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:
Note: See TracBrowser for help on using the repository browser.