#!/bin/sh
#
# new-upstream: Copyright © 2010 by Jan Dittberner <jandd@debian.org>
#
# 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 Vincent Fourmond's <fourmond@debian.org> freecol package - where he
# thanks Sam Morris <sam@robots.org.uk> for giving him the idea - for giving me
# the idea.
#

# If called manually, this file must be called within the spring/ directory.

version=$2
filename=`readlink -f $3`
targetdir=`dirname $filename`

dir=`mktemp -d`

curdir=`pwd`

origname="${targetdir}/spring_${version}+dfsg1.orig.tar.gz"

echo "Repacking spring version $version from $filename"

# Abort on errors:
set -e

cd "$dir"
tar xzf "$filename"
rm -rf spring_$version/AI/Interfaces/Java/data/jlib/vecmath.jar \
       spring_$version/AI/Interfaces/Java/data/jlib/jna.jar \
       spring_$version/installer/7za.exe \
       spring_$version/installer/dos2unix.exe \
       spring_$version/installer/nsis_plugins/FindProcDLL.dll \
       spring_$version/installer/nsis_plugins/inetc.dll \
       spring_$version/installer/nsis_plugins/registry.dll \
       spring_$version/installer/nsis_plugins/nsis7z.dll \
       spring_$version/include/SDL \
       spring_$version/include/GL
tar czf "$origname" spring_$version
echo "Repacked tarball is $origname"
cd -
rm -rf "$dir"
