#!/bin/bash


function info()
{
    cat <<EOF
This script creates brizpped tar archive of the project
EOF
}

function help()
{
    cat <<EOF
Parameters
   package - package name
   version - package version
For example:
   $0 --package=fbpanel --version=6.2
EOF
}


source scripts/funcs.sh

parse_argv "$@"
check_var package
check_var version


# Sanity checks
# check that pwd is project's topdir
[ -x ./configure -a -f rules.mk ] || error "Not a top dir"
# check that there is no uncomitted changes
if [ -d .svn -a -n "`svn st --no-ignore`" ]; then
    svn st --no-ignore
    error "SVN repository is not clean."
fi

n=${package}-${version}
t=$n.tbz2

# Create tarball
pwd=`pwd`
td=/tmp/$$
mkdir $td || exit 1
cd $td 
ln -s $pwd $n
tar hjcvf $t --exclude .svn $n
cd -
cp $td/$t ..
ls -al ../$t
rm -rf $td

