#!/bin/sh -e

# called by uscan with '--upstream-version' <version> <file>
VERSION=$2
DIR=jtharness-${VERSION}
TAR=../jtharness_${VERSION}.orig.tar.xz

rm -Rf $3 $DIR
mkdir $DIR
wget http://hg.openjdk.java.net/code-tools/jtharness/archive/$VERSION.tar.gz

tar xf $VERSION.tar.gz --strip-components=1 -C $DIR
XZ_OPT=--best tar cJvf $TAR $DIR
rm -Rf $DIR $VERSION.tar.gz

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

exit 0
