#!/bin/sh -e

# called by uscan with '--upstream-version' <version> <file>
DIR=pdfsam-$2
TAR=../pdfsam_$2.orig.tar.gz

# clean up the upstream tarball
mkdir $DIR
unzip $3 -d $DIR
(cd $DIR && for ZIP in *.zip; do unzip $ZIP; rm -f $ZIP; done)
tar -c -z -f $TAR -X debian/orig-tar.exclude $DIR
rm -rf $DIR $3

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