#!/bin/sh -ex

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

# clean up the upstream tarball
tar -xf $3
find $DIR -name .svn -exec rm -rf {} \; || true
GZIP="--best --no-name" tar -czf $TAR --exclude '*/fcgi/*' $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
