#!/usr/bin/env bash # This will package the latest version of Calibre for Slackware. Run it # as root. It will download Calibre, package it, and give you a correctly- # named, ready-to-install Slackware package in /tmp. set -e VERSION=$(wget -O - -o /dev/null http://status.calibre-ebook.com/latest) TMP=${TMP:-/tmp} PKG=$TMP/package-calibre BUILD=1AL CWD=$(pwd) if [ -z "$ARCH" ]; then case "$( uname -m )" in i?86) ARCH=i486 ;; arm*) ARCH=arm ;; *) ARCH=$( uname -m ) ;; esac fi rm -rf "$PKG" rm -rf "$TMP/calibre-installer-cache" mkdir -p "$PKG/usr/share" mkdir -p "$PKG/usr/bin" wget -nv -O- https://download.calibre-ebook.com/linux-installer.py | python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main(install_dir='$PKG/opt', isolated=True)" LD_LIBRARY_PATH="$PKG/opt/calibre/lib" "$PKG/opt/calibre/bin/calibre_postinstall" --root="$PKG/usr" # 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 # This does not belong in a package - use 'removepkg' instead: rm -f $PKG/usr/bin/calibre-uninstall # remove unused symbolic links/files rm -f $PKG/usr/bin/calibre $PKG/usr/bin/calibredb $PKG/usr/bin/calibre-smtp $PKG/usr/bin/calibre-server $PKG/usr/bin/calibre-parallel $PKG/usr/bin/calibre-debug $PKG/usr/bin/calibre-customize # including old .desktop files rm -rf /usr/share/applications/calibre* rm -rf /usr/local/share/applications/calibre* # get our preferred .desktop files into usual location mkdir -p $PKG/usr/share/applications cp -f $CWD/calibre-ebook-edit.desktop $PKG/usr/share/applications/calibre-ebook-edit.desktop cp -f $CWD/calibre-gui.desktop $PKG/usr/share/applications/calibre-gui.desktop cp -f $CWD/calibre-ebook-viewer.desktop $PKG/usr/share/applications/calibre-ebook-viewer.desktop cp -f $CWD/calibre-lrfviewer.desktop $PKG/usr/share/applications/calibre-lrfviewer.desktop # plug in link scripts... used by arox cp -f $CWD/calibre $PKG/usr/bin/calibregui cp -f $CWD/calibreedit $PKG/usr/bin/calibreedit cp -f $CWD/calibreviewer $PKG/usr/bin/calibreviewer chmod +x $PKG/usr/bin/calibreviewer chmod +x $PKG/usr/bin/calibreedit chmod +x $PKG/usr/bin/calibregui mkdir -p $PKG/usr/share/pixmaps cp -f $CWD/calibre-gui.svg $PKG/usr/share/pixmaps/calibre-gui.svg cp -f $CWD/book-edit.svg $PKG/usr/share/pixmaps/book-edit.svg cp -f $CWD/book-read.svg $PKG/usr/share/pixmaps/book-read.svg mkdir -p $PKG/usr/share/icewm/icons cp -f $CWD/calibre-gui.svg $PKG/usr/share/icewm/icons/calibre-gui.svg # include package description mkdir -p "$PKG/install" cp -f $CWD/slack-desc $PKG/install/slack-desc # Add this to the doinst.sh: mkdir -p $PKG/install cat < $PKG/install/doinst.sh #!/bin/bash if [ -x /usr/bin/update-desktop-database ]; then /usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1 fi if [ -x /usr/bin/update-mime-database ]; then /usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1 fi refreshmenu > /dev/null 2>&1 EOINS cd "$PKG" /sbin/makepkg -l n -c n "$TMP/calibre-$VERSION-$ARCH-${BUILD}.txz" cat $PKG/install/slack-desc | grep "^calibre" > $TMP/calibre-${VERSION}-${ARCH}-${BUILD}.txt