~ubuntu-branches/ubuntu/vivid/parted/vivid

« back to all changes in this revision

Viewing changes to build-aux/gnupload

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-07-30 13:16:15 UTC
  • mfrom: (7.2.34 sid)
  • Revision ID: package-import@ubuntu.com-20140730131615-6uy87mosal6722s6
Tags: 3.2-1
* New upstream release.
* Drop currently-unused build-dependency on po4a (thanks, Johannes
  Schauer).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
# Sign files and upload them.
3
3
 
4
 
scriptversion=2012-01-15.15; # UTC
 
4
scriptversion=2013-03-19.17; # UTC
5
5
 
6
 
# Copyright (C) 2004-2010, 2012 Free Software Foundation, Inc.
 
6
# Copyright (C) 2004-2014 Free Software Foundation, Inc.
7
7
#
8
8
# This program is free software; you can redistribute it and/or modify
9
9
# it under the terms of the GNU General Public License as published by
28
28
conffile=.gnuploadrc
29
29
to=
30
30
dry_run=false
 
31
replace=
31
32
symlink_files=
32
33
delete_files=
33
34
delete_symlinks=
38
39
 
39
40
usage="Usage: $0 [OPTION]... [CMD] FILE... [[CMD] FILE...]
40
41
 
41
 
Sign all FILES, and process them at selected destinations according to CMD.
42
 
<http://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html>
43
 
explains further.
 
42
Sign all FILES, and process them at the destinations specified with --to.
 
43
If CMD is not given, it defaults to uploading.  See examples below.
44
44
 
45
45
Commands:
46
46
  --delete                 delete FILES from destination
49
49
  --                       treat the remaining arguments as files to upload
50
50
 
51
51
Options:
52
 
  --help                   print this help text and exit
53
 
  --to DEST                specify one destination for FILES
 
52
  --to DEST                specify a destination DEST for FILES
54
53
                           (multiple --to options are allowed)
55
54
  --user NAME              sign with key NAME
 
55
  --replace                allow replacements of existing files
56
56
  --symlink-regex[=EXPR]   use sed script EXPR to compute symbolic link names
57
57
  --dry-run                do nothing, show what would have been done
 
58
                           (including the constructed directive file)
58
59
  --version                output version information and exit
 
60
  --help                   print this help text and exit
59
61
 
60
62
If --symlink-regex is given without EXPR, then the link target name
61
63
is created by replacing the version information with '-latest', e.g.:
62
 
 
63
64
  foo-1.3.4.tar.gz -> foo-latest.tar.gz
64
65
 
65
66
Recognized destinations are:
77
78
actual command line options.  Use this to keep your defaults.  Comments
78
79
(#) and empty lines in $conffile are allowed.
79
80
 
 
81
<http://www.gnu.org/prep/maintain/html_node/Automated-FTP-Uploads.html>
 
82
gives some further background.
 
83
 
80
84
Examples:
81
85
1. Upload foobar-1.0.tar.gz to ftp.gnu.org:
82
86
  gnupload --to ftp.gnu.org:foobar foobar-1.0.tar.gz
101
105
           --delete oopsbar-0.9.91.tar.gz \\
102
106
           -- foobar-0.9.91.tar.gz
103
107
 
104
 
gnupload uses the ncftpput program to do the transfers; if you don't
 
108
gnupload executes a program ncftpput to do the transfers; if you don't
105
109
happen to have an ncftp package installed, the ncftpput-ftp script in
106
110
the build-aux/ directory of the gnulib package
107
111
(http://savannah.gnu.org/projects/gnulib) may serve as a replacement.
129
133
      if test -z "$2"; then
130
134
        echo "$0: Missing argument for --to" 1>&2
131
135
        exit 1
 
136
      elif echo "$2" | grep 'ftp-upload\.gnu\.org' >/dev/null; then
 
137
        echo "$0: Use ftp.gnu.org:PKGNAME or alpha.gnu.org:PKGNAME" >&2
 
138
        echo "$0: for the destination, not ftp-upload.gnu.org (which" >&2
 
139
        echo "$0:  is used for direct ftp uploads, not with gnupload)." >&2
 
140
        echo "$0: See --help and its examples if need be." >&2
 
141
        exit 1
132
142
      else
133
143
        to="$to $2"
134
144
        shift
146
156
    --delete)
147
157
      collect_var=delete_files
148
158
      ;;
 
159
    --replace)
 
160
      replace="replace: true"
 
161
      ;;
149
162
    --rmsymlink)
150
163
      collect_var=delete_symlinks
151
164
      ;;
236
249
 
237
250
# Make sure passphrase is not exported in the environment.
238
251
unset passphrase
 
252
unset passphrase_fd_0
 
253
GNUPGHOME=${GNUPGHOME:-$HOME/.gnupg}
239
254
 
240
255
# Reset PATH to be sure that echo is a built-in.  We will later use
241
256
# 'echo $passphrase' to output the passphrase, so it is important that
243
258
# listings with their arguments...).
244
259
# Remember this script runs with 'set -e', so if echo is not built-in
245
260
# it will exit now.
246
 
PATH=/empty echo -n "Enter GPG passphrase: "
247
 
stty -echo
248
 
read -r passphrase
249
 
stty echo
250
 
echo
 
261
if $dry_run || grep -q "^use-agent" $GNUPGHOME/gpg.conf; then :; else
 
262
  PATH=/empty echo -n "Enter GPG passphrase: "
 
263
  stty -echo
 
264
  read -r passphrase
 
265
  stty echo
 
266
  echo
 
267
  passphrase_fd_0="--passphrase-fd 0"
 
268
fi
251
269
 
252
270
if test $# -ne 0; then
253
271
  for file
254
272
  do
255
273
    echo "Signing $file ..."
256
274
    rm -f $file.sig
257
 
    echo "$passphrase" | $dbg $GPG --passphrase-fd 0 -ba -o $file.sig $file
 
275
    echo "$passphrase" | $dbg $GPG $passphrase_fd_0 -ba -o $file.sig $file
258
276
  done
259
277
fi
260
278
 
270
288
  fi
271
289
 
272
290
  cat >${2}.directive<<EOF
273
 
version: 1.1
 
291
version: 1.2
274
292
directory: $1
275
293
comment: gnupload v. $scriptversion$stmt
276
294
EOF
312
330
  case $dest in
313
331
    alpha.gnu.org:*)
314
332
      mkdirective "$destdir" "$base" "$file" "$stmt"
315
 
      echo "$passphrase" | $dbg $GPG --passphrase-fd 0 --clearsign $base.directive
 
333
      echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign $base.directive
316
334
      $dbg ncftpput ftp-upload.gnu.org /incoming/alpha $files $base.directive.asc
317
335
      ;;
318
336
    ftp.gnu.org:*)
319
337
      mkdirective "$destdir" "$base" "$file" "$stmt"
320
 
      echo "$passphrase" | $dbg $GPG --passphrase-fd 0 --clearsign $base.directive
 
338
      echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign $base.directive
321
339
      $dbg ncftpput ftp-upload.gnu.org /incoming/ftp $files $base.directive.asc
322
340
      ;;
323
341
    savannah.gnu.org:*)
336
354
      destdir_p1=`echo "$destdir" | sed 's,^[^/]*/,,'`
337
355
      destdir_topdir=`echo "$destdir" | sed 's,/.*,,'`
338
356
      mkdirective "$destdir_p1" "$base" "$file" "$stmt"
339
 
      echo "$passphrase" | $dbg $GPG --passphrase-fd 0 --clearsign $base.directive
 
357
      echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign $base.directive
340
358
      for f in $files $base.directive.asc
341
359
      do
342
360
        echo put $f
345
363
    /*)
346
364
      dest_host=`echo "$dest" | sed 's,:.*,,'`
347
365
      mkdirective "$destdir" "$base" "$file" "$stmt"
348
 
      echo "$passphrase" | $dbg $GPG --passphrase-fd 0 --clearsign $base.directive
 
366
      echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign $base.directive
349
367
      $dbg cp $files $base.directive.asc $dest_host
350
368
      ;;
351
369
    *)
393
411
  do
394
412
    echo "Uploading $file to $dest ..."
395
413
    stmt=
 
414
    #
 
415
    # allowing file replacement is all or nothing.
 
416
    if test -n "$replace"; then stmt="$stmt
 
417
$replace"
 
418
    fi
 
419
    #
396
420
    files="$file $file.sig"
397
421
    destdir=`echo $dest | sed 's/[^:]*://'`
398
422
    if test -n "$symlink_expr"; then