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 and Liberation) and repacks it"
echo -e "to calibre-$VERSION-nofonts.tar.bz2 in $(pwd)"
exit 1
}
function exit_on_error {
echo -e "$1"
[[ -e ${MYTEMP} ]] && rm -rf ${MYTEMP}
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
curl -L http://status.calibre-ebook.com/dist/src > calibre-$VERSION.tar.xz
echo "done"
#
echo -n "Processing archive ... "
[ -e calibre-$VERSION.tar.xz ] || exit_on_error "Error: Calibre Archiv not found"
tar -xJf calibre-$VERSION.tar.xz
[ -e calibre/resources/fonts/liberation ] && rm -f calibre/resources/fonts/liberation/*
[ -e calibre/resources/fonts/prs500 ] && rm -f calibre/resources/fonts/prs500/*
echo "done"
cd - > /dev/null
#
echo -n "Creating new archive 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"
#
echo -n "Adding calibre-$VERSION-nofonts.tar.bz2 to OBS ... "
echo
# osc add $(pwd)/calibre-$VERSION-nofonts.tar.bz2
echo "done"