A new user interface for you! Read more...

File download_and_recompress.sh of Package webtrees

#!/bin/sh

# Package source in tar.bz2 format instead of original zip file.
# Use the download_and_recompress.sh script to download the sources
# matching the spec file's version.

VERSION=`grep "^Version:" webtrees.spec | sed -e 's/Version:[ \t]*//'`
MAJORVERSION=`echo "$VERSION" | sed 's/\.[0-9]*$//'`

if [ -z "$VERSION" ]; then
        echo "Can't find Version definition in webtrees.spec"
        exit 1
fi

if [ -e "webtrees-$VERSION.tar.xz" ] ; then
	echo "webtrees-$VERSION.tar.xz already exsists!"
	exit 0
fi

if [ ! -e "webtrees-$VERSION.zip" ] ; then
	wget "https://launchpad.net/webtrees/$MAJORVERSION/$VERSION/%2Bdownload/webtrees-$VERSION.zip"
	if [ $? -ne 0 ] ; then
		echo "Error downloading https://launchpad.net/webtrees/$MAJORVERSION/$VERSION/%2Bdownload/webtrees-$VERSION.zip"
		exit 1
	fi
fi

if [ ! -e "webtrees-$VERSION.zip" ] ; then
	echo "Could not download https://launchpad.net/webtrees/$MAJORVERSION/$VERSION/+download/webtrees-$VERSION.zip"
	exit 2
fi

if [ -d "webtrees/" ] ; then
	rm -rf "webtrees/"
fi
if [ -d "webtrees-$VERSION/" ] ; then
	rm -rf "webtrees-$VERSION/"
fi

unzip -q "webtrees-$VERSION.zip"

mv "webtrees/" "webtrees-$VERSION/"

tar -cJf "webtrees-$VERSION.tar.xz" "webtrees-$VERSION/"

rm -rf "webtrees-$VERSION/" "webtrees-$VERSION.zip"