#!/bin/sh -e

# $1 = version
TAR=../substance_$1.orig.tar.gz
ZIP=substance-all.zip
DIR=substance-$1.orig
# version 5.3 (Reykjavik)
RELEASE_ID=135950

wget https://substance.dev.java.net/files/documents/3294/$RELEASE_ID/$ZIP

# clean up the upstream tarball
unzip -d $DIR $ZIP
tar -c -z -f $TAR -X debian/orig-tar.exclude $DIR
rm -rf $DIR $ZIP

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