#!/bin/sh
# script to download and repack source package of pycorrfit

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

PKGVERSION=`echo $VERSION | sed "s/~//"`

cd ../tarballs

UPSTREAMNAME=pycorrfit
UPSTREAMDIR="${UPSTREAMNAME}-${VERSION}"
mkdir $UPSTREAMDIR
cd $UPSTREAMDIR
tar --strip-components=1 -xzf ../"${UPSTREAMNAME}-${PKGVERSION}".tar.gz
cd ..

rm -rf ${UPSTREAMDIR}/pyinstaller-howto
#rm -f ${UPSTREAMDIR}/*.pdf

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

