diff options
-rwxr-xr-x | distribute.sh | 192 |
1 files changed, 147 insertions, 45 deletions
diff --git a/distribute.sh b/distribute.sh index e98ad24..95edcb5 100755 --- a/distribute.sh +++ b/distribute.sh @@ -1,48 +1,127 @@ #! /bin/sh +# distribute-gnu.sh - upload file for distribution to gnu ftp site and mirrors. +# Copyright (C) 2006 Free Software Foundation, Inc. +# Written by Claudio Fontana <claudio@gnu.org>, 2006. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# This software depends on the following programs to run correctly: +# /bin/sh +# basename +# gpg +# ftp +# +# This script also assumes that you already generated/registered your key +# for the ftp uploads (see link below). +# +# For more information about the procedure see the +# "Information for maintainers of GNU software" +# +# http://www.gnu.org/prep/maintain/ + +as_me=`basename ${0}` +PACKAGE_VERSION=distribute-gnu-0.0 + if test $# -lt 1 ; then - echo "Usage: ./distribute.sh [OPTIONS] DIRECTORY PACKAGE" - echo " " - echo "OPTIONS:" - echo "-uHOSTNAME choose upload hostname (def:ftp-upload.gnu.org)" - echo "-hHOSTNAME choose the destination hostname [ftp|alpha] (def:ftp)" - echo "-cCOMMENT add a comment to the upload directive" - echo " " - echo "DIRECTORY: the destination directory on the remote host" - echo "PACKAGE: the tarball file to distribute" - echo " " - exit 1 + echo "$as_me: insufficient arguments. Try --help" >&2 + exit 2 fi -UPLOAD_HOST=ftp-upload.gnu.org -DESTINATION_HOST=ftp -COMMENT= +HOST=ftp-upload.gnu.org +TARGET=ftp DIRECTORY= PACKAGE= +BASE_PACKAGE= +COMMENT= +simulate=0 +debug=0 processing_options=1 -for ARG in "$@" ; do +for ARG in "$@" +do if test $processing_options = 1 ; then case $ARG in - -u*) - UPLOAD_HOST="${ARG#-u}" - echo UPLOAD_HOST=${UPLOAD_HOST} - continue + -h | --help) + echo "Usage: $as_me [OPTIONS] DIRECTORY FILENAME" + echo " " + echo "OPTIONS:" + echo "-h, --help this help" + echo "-v, --version show script version" + echo " " + echo "-h, --host=HOSTNAME (def:ftp-upload.gnu.org)" + echo "-t, --target=HOSTNAME [ftp|alpha] (def:ftp)" + echo "-c, --comment=COMMENT (def:no comment)" + echo "-s, --simulation do not perform the upload" + echo "-d, --debug show more information" + echo " " + echo "DIRECTORY: the destination directory on the remote host" + echo "FILENAME: the file to distribute" + echo " " + exit 0 + ;; + + -v | --version) + echo "$PACKAGE_VERSION (C) 2006 Free Software Foundation Inc." + echo "Written by Claudio Fontana, 2006." + exit 0 ;; + -h*) - DESTINATION_HOST="${ARG#-h}" - echo DESTINATION_HOST=${DESTINATION_HOST} + HOST="${ARG#-h}" + continue + ;; + + --host=*) + HOST="${ARG#--host=}" continue ;; + + -t*) + TARGET="${ARG#-t}" + continue + ;; + + --target=*) + TARGET="${ARG#--target=}" + continue + ;; + -c*) COMMENT="${ARG#-c}" - echo COMMENT=${COMMENT} continue ;; + + --comment=*) + COMMENT="${ARG#--comment=}" + continue + ;; + + -s | --simulation) + simulate=1 + continue + ;; + + -d | --debug) + debug=1 + continue + ;; + -*) - echo "unknown option: $ARG" >&2 - exit 1 + echo "$as_me: unknown option: $ARG" >&2 + exit 2 esac fi @@ -50,54 +129,77 @@ for ARG in "$@" ; do if test "x$DIRECTORY" = "x" ; then DIRECTORY="${ARG}" - echo DIRECTORY=${DIRECTORY} - continue; + continue fi if test "x$PACKAGE" = "x" ; then PACKAGE="${ARG}" - echo PACKAGE=${PACKAGE} continue; fi - echo "too many arguments: $ARG" >&2 - exit 1 + echo "$as_me: too many arguments." >&2 + exit 2 done if test "x$DIRECTORY" = "x" ; then - echo "missing required DIRECTORY argument" >&2 - exit 1 + echo "$as_me: missing required DIRECTORY argument." >&2 + exit 2 fi if test "x$PACKAGE" = "x" ; then - echo "missing required PACKAGE argument" >&2 - exit 1 + echo "$as_me: missing required PACKAGE argument." >&2 + exit 2 fi if test -f "$PACKAGE" ; then - echo "${PACKAGE} is a regular file." + : else - echo "${PACKAGE} is not an existing regular file" >&2 - exit 1 + echo "$as_me: ${PACKAGE} is not an existing regular file." >&2 + exit 2 fi -gpg -b --yes ${PACKAGE} +BASE_PACKAGE=`basename ${PACKAGE}` + +if test "$debug" = "1" ; then + echo "HOST=${HOST}" + echo "TARGET=${TARGET}" + echo "DIRECTORY=${DIRECTORY}" + echo "PACKAGE=${PACKAGE}" + echo "BASE_PACKAGE=${BASE_PACKAGE}" + echo "COMMENT=${COMMENT}" +fi + +if gpg -b --yes ${PACKAGE} ; then + : +else + echo "$as_me: failed to sign package using gpg." >&2 + exit 2 +fi echo "version: 1.1" > ${PACKAGE}.directive echo "directory: ${DIRECTORY}" >> ${PACKAGE}.directive -echo "filename: ${PACKAGE}" >> ${PACKAGE}.directive +echo "filename: ${BASE_PACKAGE}" >> ${PACKAGE}.directive if test "x$COMMENT" != "x" ; then echo "comment: ${COMMENT}" >> ${PACKAGE}.directive fi -gpg --clearsign --yes ${PACKAGE}.directive +if gpg --clearsign --yes ${PACKAGE}.directive ; then + : +else + echo "$as_me: failed to sign directive file using gpg." >&2 + exit 2 +fi + +if test "$simulate" != "0" ; then + exit 0 +fi #upload results to ftp. -cmdftp ${UPLOAD_HOST}<<EOF -cd /incoming/${DESTINATION_HOST} -u ${PACKAGE} . -u ${PACKAGE}.sig . -u ${PACKAGE}.directive.asc . -exit +ftp -p ${HOST}<<EOF +cd /incoming/${TARGET} +binary +put ${PACKAGE} ${BASE_PACKAGE} +put ${PACKAGE}.sig ${BASE_PACKAGE}.sig +put ${PACKAGE}.directive.asc ${BASE_PACKAGE}.directive.asc EOF |