#!/bin/sh
#
# new-upstream: copyright 2007,2008 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.
#
# Thanks to Sam Morris <sam@robots.org.uk> for giving me the idea

version=$2
filename=$3

dir=`mktemp -d`


# We repackage the upstream tarball, removing the jars in the library and
# the examples, which have dubious copyright status
tar xvzf $filename -C "$dir" --exclude '*/lib/*.jar'  --exclude '*/examples'
origname=xmlgraphics-commons_$version.dfsg.orig.tar.gz

# We repackage excluding the lib/ subdir
cd $dir
tar cvz -f $origname xml*
cd -
mv $dir/$origname ..
rm -rf $dir