File generate-tarball.sh of Package calibre

#!/bin/sh
#
# Copyright (c) 2010,2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# Authors: Sascha Manns <saigkill@opensuse.org>
#          Frank Sundermeyer <fsundermeyer@opensuse.org>
#
# Downloads the latest source file for Calibre from
# http://status.calibre-ebook.com/dist/src
# Unpacks the sources to a temporary directory, removes
# fonts (proprietary ons and Liberation) and repacks it
# to calibre-$VERSION-nofonts.tar.bz2 in the current directory

#----------
# Functions
#----------

# usage

function usage {
                 echo -e "\nusage: $0 VERSION\n"
                 echo -e "Downloads the latest source file for Calibre from"
                 echo -e "http://status.calibre-ebook.com/dist/src"
                 echo -e "Unpacks the sources to a temporary directory, removes"
                 echo -e "fonts (proprietary ons and Liberation) and repacks it"
                 echo -e "to calibre-$VERSION-nofonts.tar.bz2 in $(pwd)"
                 exit 1
}
function exit_on_error {
    echo -e "$1"
    exit 1
}

VERSION=$1
[ -z $VERSION ] && usage

MYTEMP=$(mktemp -dq) || exit_on_error "Error: Could not create tmp directory"

trap exit 0 SIGTERM SIGINT

#-----
# Main
#-----

cd $MYTEMP || exit_on_error "Error: Could not cd into $MYTEMP"
echo -n "Downloading ... "
wget -q http://status.calibre-ebook.com/dist/src
echo "done"
echo -n "Processing archive ... "
tar -xzf calibre-$VERSION.tar.gz
rm -f calibre/resources/fonts/liberation/*
rm -f calibre/resources/fonts/prs500/*
echo "done"
cd - > /dev/null
echo -n "Creating new archive $(pwd)/calibre-$VERSION-nofonts.tar.bz2 ... "
tar -c -f calibre-$VERSION-nofonts.tar.bz2 -C ${MYTEMP} -j calibre
echo "done"
echo -n "Cleaning up ... "
rm -rf $MYTEMP
echo "done"
openSUSE Build Service is sponsored by