1 #!/bin/sh 2 3 DIRNAME=`dirname "$0"` 4 PROGNAME=`basename "$0"` 5 6 if [ ! "$1" ] || [ "$1" = '--help' ] ; then 7 cat 1>&2 <<EOF 8 Usage: $PROGNAME <archive directory> [ -f ] 9 10 Sign archives in the given archive directory, invoking GPG to produce a 11 detached signature. If a signature already exists for an archive, it is not 12 regenerated unless the -f (force) option is given. 13 14 All newly-created signature filenames are emitted on standard output. 15 EOF 16 exit 1 17 fi 18 19 OUTDIR=$1 20 FORCE=$2 21 22 if [ "$FORCE" != '-f' ]; then 23 FORCE= 24 fi 25 26 if [ ! -e "$OUTDIR" ]; then 27 cat 1>&2 <<EOF 28 No archive directory to process. 29 EOF 30 exit 1 31 fi 32 33 for FILENAME in "$OUTDIR/"*".tar.bz2" ; do 34 35 # Handle an absence of archives. 36 37 if [ ! -e "$FILENAME" ] ; then 38 break 39 fi 40 41 OUTFILE="$FILENAME.asc" 42 if [ ! -e "$OUTFILE" ] || [ "$FORCE" ]; then 43 gpg --sign -a -b "$FILENAME" 44 echo "$OUTFILE" 45 fi 46 done 47 48 # vim: tabstop=4 expandtab shiftwidth=4