#!/bin/sh
# script to download and repack source package of tophat 
# stripping off SeqAn which is distributed in Debian.

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=tophat
UPSTREAMDIR="${UPSTREAMNAME}-${VERSION}"
tar -xzf ../${UPSTREAMDIR}.tar.gz

rm -rf ${UPSTREAMDIR}/src/SeqAn-1.3

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

