#!/bin/sh
#
# new-upstream: copyright 2008, 2009 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 source zip file:
tar xvz -C $dir -f "$filename"
origname=jalview_$version.dfsg.orig.tar.bz2

# We repackage excluding the lib/ subdir
cd $dir
# Removing the utils/ directory, not needed for build ?
rm -rf jalview*/utils

# Removing all binary jars...
find -name '*.jar' | xargs rm 

# Removing examples/ subdirectory, whose copyright status is unclear
# to me for the time being
rm -rf jalview*/examples


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