#!/bin/sh

PUB_TARGET=$1
TARNAMEPREFIX=$2

if test "x$PUB_TARGET" == "x"; then
    echo "usage: $0 <target> <tar-prefix>"
    exit 1
fi
if test "x$TARNAMEPREFIX" == "x"; then
    echo "usage: $0 <target> <tar-prefix>"
    exit 1
fi

if ! test -d "$PUB_TARGET"; then
    echo "target directory $PUB_TARGET does not exist !"
    exit 2
fi

NOW=`date +"%Y%m%d%H%M"`

TARNAME="$TARNAMEPREFIX-$NOW.tar.gz"

echo "creating tar $TARNAME ..."
cd $PUB_TARGET

tar zc \
    --exclude=CVS \
    --exclude=BUILD \
    --exclude=TARGET \
    --exclude=".svn" \
    --exclude=".cvsignore" \
    --exclude="run.sh" \
    --exclude="log4j.properties" \
    --exclude="nohup.out" \
    --exclude="common.make" \
    --exclude="ChangeLog.txt" \
    --exclude="*.png" \
    --exclude="*.gif" \
    --exclude="*.jpg" \
    --exclude="*.tgz" \
    --file=$TARNAME .

exit 0
