#!/bin/sh
#
# new-upstream: copyright 2008 by Vincent Fourmond.
# Repackage a zip into a .tar.gz archive
#
# 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 source zip file:
unzip $filename -d $dir
origname=batik_$version.orig.tar.gz

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