#!/bin/sh
#
# Executed by uscan, repackages the upstream source removing
# all non-DFSG content.
   
set -e
   
PACKAGE=$(dpkg-parsechangelog | sed -rn '/^Source:/ {s/^Source: //; p}')
VERSION=$(echo $2)
FILE=$3
DIR="$PACKAGE-$VERSION"
DFSG_FILE=$(echo "$FILE" | sed 's/\.orig\.tar\.gz$/+dfsg\.orig\.tar\.gz/')
  
# Unpack
tar xzf $FILE \
 --exclude "*/packages/acs-templating/www/resources/xinha-nightly/iconsets/Tango" \
 --exclude "*/packages/acs-templating/www/resources/xinha-nightly/images/tango" \
 --exclude "*/packages/acs-templating/www/resources/tinymce/jscripts/tiny_mce/plugins/media/img/flv_player.swf"
  
# Repack
tar cz -f $FILE $DIR
mv $FILE $DFSG_FILE
  
# Clean
rm -rf $DIR
