#!/bin/sh
# script to download and repack source package of transtermhp
# this is needed because it is in ZIP format.
# Once we are repackaging we can also strip useless binaries.

PKG=`dpkg-parsechangelog | awk '/^Source/ { print $2 }'`
VERSION=`uscan --verbose --force-download | \
    grep "Newest version on remote site is .* local version is .*" | \
    head -n 1 | \
    sed "s/Newest version on remote site is \([-0-9.]\+\),.*/\1/"`

mkdir -p ../tarballs
cd ../tarballs

UPSTREAMNAME=transterm_hp
UPSTREAMDIR="${UPSTREAMNAME}_v${VERSION}"
unzip ../${UPSTREAMDIR}.zip

# Once we need to repack the zip archive anyway we can remove useless
# binaries which are included
rm -f ${UPSTREAMDIR}/2ndscore ${UPSTREAMDIR}/transterm

GZIP="--best --no-name" tar -czf "$PKG"_"$VERSION".orig.tar.gz "${UPSTREAMDIR}"
rm -rf "${UPSTREAMDIR}"
