#!/bin/sh
#
# new-upstream: copyright 2011 by Vincent Fourmond.
# See debian/copyright file for details.
#
# Called by uscan; from uscan(1):
#
# Finally,  if a third parameter (an action) is given in the watchfile
# line, this is taken as the name of a command, and the command
#  command --upstream-version version filename
# 
# is executed, using either the original file or the symlink name.


version=$2
filename=$3

dir=`mktemp -d`
srcdir=$dir/libvamsas-client-java
mkdir $srcdir

# We repackage the upstream source zip file:
unzip -d $srcdir "$filename"
origname=libvamsas-client-java_$version+dfsg.orig.tar.bz2

# We repackage excluding the lib/ subdir
cd $dir

# Blindly removing the documentation for now, we'll see how to deal
# with it later on.

rm -rf lib*/docs
rm -rf lib*/lib 
rm -rf lib*/tools

# # We also remove the zip classes, as they are found in ant
# # Maybe they could be split from ant ?

# rm -rf lib*/src/org/apache/tools/zip

# Not removing anymore, since it seems that there are some things
# different in there.

echo "Creating archive"
tar cvj -f $origname lib*/
cd -
# We remove any file already existing there: it might be a symlink.
rm -f $orginame 
mv $dir/$origname ..
rm -rf $dir