#!/bin/sh
#
# new-upstream: copyright 2012 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=`readlink -f $3`

dir=`mktemp -d`

curdir=`pwd`

origname=batik_$version"+dfsg".orig.tar.xz

echo "Repackaging batik version $version from $filename"

# Abort on errors:
set -e

# We repackage the upstream source file, skipping binary JAR files.
cd $dir
unzip $filename
cd $dir/batik*
find -name '*.jar' | xargs rm
cd ..
tar cvJf $curdir/../$origname batik*/
cd -
rm -rf $dir
