Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: d7819d35b6
Fetching contributors…

Cannot retrieve contributors at this time

executable file 258 lines (216 sloc) 8.826 kB
#!/bin/sh
# $Id: calibre.SlackBuild,v 1.66 2012/06/15 11:09:03 root Exp root $
# Copyright 2010, 2011, 2012 Eric Hameleers, Eindhoven, NL
# All rights reserved.
#
# Permission to use, copy, modify, and distribute this software for
# any purpose with or without fee is hereby granted, provided that
# the above copyright notice and this permission notice appear in all
# copies.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# -----------------------------------------------------------------------------
#
# Slackware SlackBuild script
# ===========================
# By: Eric Hameleers <alien@slackware.com>
# For: calibre
# Descr: e-book library management application
# URL: http://calibre-ebook.com/
# Needs: icu4c, podofo;
# And if your system already has python2.7, you will also need:
# BeautifulSoup, dnspython, pysetuptools, python-cssutils,
# python-imaging, python-lxml, python-dateutil, python-mechanize
# python-netifaces
# Simplified by Willy Sudiarto Raharjo
# Changelog
# July, 1: Upgraded to 0.8.58
# Simplify the SlackBuild since we have all dependencies out of this package
# July, 7: Upgraded to 0.8.59
# July, 12: Upgraded to 0.8.60
# July, 27: Upgraded to 0.8.62
# August, 4 : Upgraded to 0.8.63
# August, 11: Upgraded to 0.8.64
# August, 18: Upgraded to 0.8.65
# August, 26: Upgraded to 0.8.66
# September, 2: Upgraded to 0.8.67
# September, 6: Rebuilt against new dependency: python-netifaces
# September, 8: Upgraded to 0.8.68
# September, 17: Upgraded to 0.8.69
# September, 26: Upgraded to 0.8.70
# September, 28: Upgraded to 0.9.0
# October, 5: Upgraded to 0.9.1
# October, 13: Upgraded to 0.9.2
# Set initial variables:
PRGNAM=calibre
VERSION=${VERSION:-0.9.2}
BUILD=${BUILD:-1wsr}
NUMJOBS=${NUMJOBS:" -j4 "}
DOCS="LICENSE* Changelog* COPYRIGHT README*"
PYTHON=$(python -c 'import sys; print sys.version[:3]')
SLACKVER=$(cat /etc/slackware-version |cut -d' ' -f2)
REQUIRED_PYTHON="2.7"
if [ "$PYTHON" != "$REQUIRED_PYTHON" ]; then
echo "You must have Python 2.7.x installed on your system to continue"
exit 1;
fi
# Where do we look for sources?
SRCDIR=$(cd $(dirname $0); pwd)
CWD=$(pwd)
# Place to build (TMP) package (PKG) and output (OUTPUT) the program:
TMP=${TMP:-/tmp/build}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) export ARCH=i486 ;;
arm*) export ARCH=arm ;;
# Unless $ARCH is already set, use uname -m for all other archs:
*) export ARCH=$( uname -m ) ;;
esac
fi
case "$ARCH" in
i486) SLKCFLAGS="-O2 -march=i486 -mtune=i686"
SLKLDFLAGS=""; LIBDIRSUFFIX=""
;;
x86_64) SLKCFLAGS="-O2 -fPIC"
SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64"
;;
*) SLKCFLAGS="-O2"
SLKLDFLAGS=""; LIBDIRSUFFIX=""
;;
esac
# Exit the script on errors:
set -e
trap 'echo "$0 FAILED at line ${LINENO}" | tee $OUTPUT/error-${PRGNAM}.log' ERR
# Catch unitialized variables:
set -u
P1=${1:-1}
# Save old umask and set to 0022:
_UMASK_=$(umask)
umask 0022
# Create working directories:
mkdir -p $OUTPUT # place for the package to be saved
mkdir -p $TMP/tmp-$PRGNAM # location to build the source
mkdir -p $PKG # place for the package to be built
rm -rf $PKG/* # always erase old package's contents
rm -rf $TMP/tmp-$PRGNAM/* # remove the remnants of previous build
echo -e "\n** calibre **\n"
cd $TMP
tar xvf $CWD/${PRGNAM}-${VERSION}.tar.xz
cd $TMP/$PRGNAM/
chown -R root:root .
chmod -R u+w,go+r-w,a+X-s .
# Calibre 0.8.6 has a version bug:
INTERNAL_VERSION=$(echo $VERSION | sed -e 's/\./, /g')
VERSION_CONSTANT=$(grep "^numeric_version" src/calibre/constants.py)
if [ "$VERSION_CONSTANT" != "numeric_version = ($INTERNAL_VERSION)" ]; then
echo "** Changing '$VERSION_CONSTANT' to:"
echo "** 'numeric_version = ($INTERNAL_VERSION)'"
sed -i -e "s/^numeric_version.*$/numeric_version = ($INTERNAL_VERSION)/" \
src/calibre/constants.py
fi
# See if we picked up any linker flags for python:
LDFLAGS=${LDFLAGS:-""}
# Place where we have to install stuff:
PYTHONLIB=$( python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" )
# Create the directory for calibre's environment module:
mkdir -p $PKG$PYTHONLIB
# Find the prefix python was installed to (may be different from calibre's):
PYTHONROOT=$( python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(prefix='/')" )
PYTHONPREF="${PYTHONLIB%$PYTHONROOT}"
# Massage the install script to actually install to that python libdir:
sed -e "/s.get_python_lib(prefix=/s,(prefix=.*),(prefix='$PKG$PYTHONPREF')," \
-i setup/install.py
# Cut out the DOS crap:
sed -i -e 's/\r//' src/calibre/web/feeds/recipes/*
OVERRIDE_LDFLAGS="$LDFLAGS $SLKLDFLAGS" \
OVERRIDE_CFLAGS="$SLKCFLAGS" \
python setup.py build
# Create the directories the xdg-utils expects to be present:
mkdir -p $PKG/usr/share/{applications,icons/hicolor,mime/packages}
mkdir -p $PKG/usr/share/{desktop-directories,packages}
XDG_DATA_DIRS="$PKG/usr/share" \
XDG_UTILS_INSTALL_MODE="system" \
LIBPATH="/usr/lib${LIBDIRSUFFIX}" \
python setup.py install \
--prefix=/usr \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--staging-root=$PKG/usr \
--staging-libdir=$PKG/usr/lib${LIBDIRSUFFIX}
# The bash completion files need to be in /etc :
mv $PKG/usr/etc $PKG/
# This is stupid:
rm -f $PKG/usr/bin/calibre-uninstall
# I'd rather not ship 1.6MB of redundant fonts:
( cd $PKG/usr/share/calibre/fonts/liberation/
for FONT in *.ttf ; do
rm $FONT
ln -sf /usr/share/fonts/TTF/$FONT
done
)
# All these files will be generated by update-mime-database:
find $PKG/usr/share/mime -maxdepth 1 -type f | xargs rm -f
# These files are generated by update-desktop-database while installing:
rm -f $PKG/usr/share/applications/defaults.list
rm -f $PKG/usr/share/applications/mimeinfo.cache
# These two served their purpose:
rmdir $PKG/usr/share/{desktop-directories,packages}
# And then some additions or it won't all look nice in your menu:
# Add a MimeType icon for lrf, and add an application icon:
for i in 16 24 32 48 64 96 128; do
mkdir -p $PKG/usr/share/icons/hicolor/${i}x${i}/{apps,mimetypes}
convert imgsrc/mimetypes/lrf.svg -scale $i \
$PKG/usr/share/icons/hicolor/${i}x${i}/mimetypes/application-x-sony-bbeb.png
convert resources/images/library.png -resize ${i}x${i} \
$PKG/usr/share/icons/hicolor/${i}x${i}/apps/calibre-gui.png
convert imgsrc/viewer.svg -scale $i \
$PKG/usr/share/icons/hicolor/${i}x${i}/apps/calibre-viewer.png
done
# Create a doinst.sh:
mkdir -p $PKG/install
cat <<EOT >> $PKG/install/doinst.sh
# Update the desktop and mime database:
if [ -x usr/bin/update-desktop-database ]; then
chroot . /usr/bin/update-desktop-database usr/share/applications > /dev/null 2>&1
fi
if [ -x usr/bin/update-mime-database ]; then
chroot . /usr/bin/update-mime-database usr/share/mime > /dev/null 2>&1
fi
if [ -x usr/bin/gtk-update-icon-cache ] ; then
chroot . /usr/bin/gtk-update-icon-cache --quiet usr/share/icons/hicolor
fi
EOT
# Add documentation:
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
# First, the calibre documentation files:
cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION || true
# And finally, add this SlackBuild script:
cat $SRCDIR/$(basename $0) > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION
find $PKG/usr/doc -type f -exec chmod 644 {} \;
# Strip binaries (if any):
find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
# Add a package description:
mkdir -p $PKG/install
cat $SRCDIR/slack-desc > $PKG/install/slack-desc
# Build the package:
cd $PKG
makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}.${PKGTYPE:-txz}
cd $OUTPUT
cd -
# Restore the original umask:
umask ${_UMASK_}
Jump to Line
Something went wrong with that request. Please try again.