#!/bin/sh -e

VERSION=$2
DIR=gluegen-v$VERSION
TAR=gluegen2_$VERSION.orig.tar.xz

# clean up the upstream tarball
p7zip -d $3
tar xvf gluegen-v$VERSION.tar
cd $DIR*
rm -rf .gitignore .htaccess make/lib/
rm -f $(find . -iname '*.jar')
cd ..
XZ_OPT=--best tar Jcvf ../$TAR $DIR
rm -rf $DIR gluegen-v$VERSION.tar

# move to directory 'tarballs'
if [ -r .svn/deb-layout ]; then
    . .svn/deb-layout
    mv $TAR $origDir
    echo "moved $TAR to $origDir"
fi

exit 0
