#!/bin/sh

# Script to export the source code of jsymphonic from its SVN
# repository, and repackage that into a decent .orig tarball...

version="$1"
package="libvamsas-client-java"

if [ -z "$version" ]; then
    echo <<EOF
Usage:

  debian/get-git-source version
EOF
    exit 1;
fi

REP="http://source.jalview.org/git/vamsas.git"

tmpdir=`mktemp -d `
curdir=`pwd`

cd $tmpdir;

echo "Getting git code"
git clone $REP
cd vamsas
rev=$(git rev-list --abbrev-commit HEAD | head -n1)
fullrev=`date +%Y.%m.%d`+$rev
fullversion="${version}~git$fullrev"
tarball="${package}_${fullversion}.orig.tar.bz2"

echo 
echo "Removing unnecessary files"
rm -rf .git docs packages lib tools

echo 
echo "Making tarball"
cd ..
tar cvjf "$curdir/../$tarball" vamsas

echo "Cleaning up temporary files"
cd $curdir
rm -rf $tmpdir