#!/bin/sh
# I could not find the src on the sf.net download page.
# Instead pull down the svn tree
set -ex

PACKAGE=xslthl

VERSION=${VERSION:-$2}
TARFILE=${TARFILE:-$3}

if [ -z ${VERSION}]; then
VERSION=`dpkg-parsechangelog | sed -n -e 's/^Version: \(.*\)-[^-]*$/\1/p'`
fi

REVISION=`echo $VERSION | sed -e 's/^.*svn//g'`
#REVISION=10509
FOLDER=${PACKAGE}-${VERSION}

if [ -z ${TARFILE} ]; then
TARFILE=${PACKAGE}_${VERSION}.orig.tar.gz
fi

#svn export --quiet --revision ${REVISION} http://xslthl.svn.sourceforge.net/svnroot/xslthl/tags/v2_0_1/ ${FOLDER}
svn export --quiet http://xslthl.svn.sourceforge.net/svnroot/xslthl/tags/v2_0_2/ ${FOLDER}

cd ${FOLDER}
# saxon6 / saxon9 / xalan are packaged inside the source...
rm -rf ./lib
# examples have weird license or no license. we do not need them:
rm -rf ./examples
cd ..

GZIP=-9 tar czf ${TARFILE} ${FOLDER}
rm -rf ${FOLDER}

