#!/bin/sh
# script to download and repack source package of velvet
# this is needed to remove a copy of zlib

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

UPSTREAMDIR="${PKG}_${VERSION}"
mv ../${UPSTREAMDIR}.tgz .
tar -xzf ${UPSTREAMDIR}.tgz
rm -rf ${UPSTREAMDIR}/third-party
mv ${UPSTREAMDIR} ${UPSTREAMDIR}~nozlibcopy

GZIP=-9 tar -czf "$PKG"_"$VERSION~nozlibcopy".orig.tar.gz "${UPSTREAMDIR}~nozlibcopy"
rm -rf "${UPSTREAMDIR}~nozlibcopy"

