#!/bin/sh -e

# called by uscan with '--upstream-version' <version> <file>
TAR=../libjboss-aop-java_$2.orig.tar.gz
DIR=libjboss-aop-java-$2.orig

# clean up the upstream tarball
unzip $3
mv jboss-aop-$2 $DIR
(cd $DIR;\
grep -ril -m 60 --include="*.java" "Generated.*Do not edit" . | xargs rm;\
grep -irl --include '*.java' com.bea.jvm . |xargs rm )
tar -c -z -f $TAR -X debian/orig-tar.exclude $DIR
rm -rf $3 $DIR

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