#!/bin/sh

DIRNAME=`dirname $0`
PROGNAME=`basename $0`
OUTDIR=$1
FORCE=$2

if [ ! "$OUTDIR" ]; then
    cat 1>&2 <<EOF
Usage: $PROGNAME <archive directory>
EOF
    exit 1
fi

if [ "$FORCE" != '-f' ]; then
    FORCE=
fi

if [ ! -e "$OUTDIR" ]; then
    cat 1>&2 <<EOF
No archive directory to process.
EOF
    exit 1
fi

for FILENAME in "$OUTDIR/"*".tar.bz2" ; do
    OUTFILE="$FILENAME.asc"
    if [ ! -e "$OUTFILE" ] || [ "$FORCE" ]; then
        gpg --sign -a -b "$FILENAME"
    fi
    echo "$OUTFILE"
done
