calibre.SlackBuild 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #!/bin/bash
  2. # Slackware build script for calibre
  3. # Copyright 2009-2018 Larry Hajali <larryhaja[at]gmail[dot]com>
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED
  13. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  15. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. cd $(dirname $0) ; CWD=$(pwd)
  23. PRGNAM=calibre
  24. VERSION=${VERSION:-3.48.0}
  25. BUILD=${BUILD:-1}
  26. TAG=${TAG:-_SBo}
  27. PKGTYPE=${PKGTYPE:-tgz}
  28. if [ -z "$ARCH" ]; then
  29. case "$( uname -m )" in
  30. i?86) ARCH=i586 ;;
  31. arm*) ARCH=arm ;;
  32. *) ARCH=$( uname -m ) ;;
  33. esac
  34. fi
  35. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  36. # the name of the created package would be, and then exit. This information
  37. # could be useful to other scripts.
  38. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  39. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  40. exit 0
  41. fi
  42. TMP=${TMP:-/tmp/SBo}
  43. PKG=$TMP/package-$PRGNAM
  44. OUTPUT=${OUTPUT:-/tmp}
  45. if [ "$ARCH" = "i586" ]; then
  46. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  47. LIBDIRSUFFIX=""
  48. elif [ "$ARCH" = "i686" ]; then
  49. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  50. LIBDIRSUFFIX=""
  51. elif [ "$ARCH" = "x86_64" ]; then
  52. SLKCFLAGS="-O2 -fPIC"
  53. LIBDIRSUFFIX="64"
  54. else
  55. SLKCFLAGS="-O2"
  56. LIBDIRSUFFIX=""
  57. fi
  58. set -e
  59. rm -rf $PKG
  60. mkdir -p $TMP $PKG $OUTPUT
  61. cd $TMP
  62. rm -rf $PRGNAM-$VERSION
  63. tar xvf $CWD/$PRGNAM-$VERSION.tar.xz
  64. cd $PRGNAM-$VERSION
  65. chown -R root:root .
  66. find -L . \
  67. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  68. -o -perm 511 \) -exec chmod 755 {} \; -o \
  69. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  70. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  71. # Patch for the newer icu4c
  72. patch -p1 < $CWD/patches/icu.patch
  73. # Patch for qt-5.15.x
  74. patch -p1 < $CWD/patches/qt-5.15.patch
  75. # Remove desktop integration. We'll do that later.
  76. patch -p1 < $CWD/patches/remove-desktop-integration.patch
  77. # Fix calibre module location.
  78. patch -p1 < $CWD/patches/calibre-module-fix.patch
  79. # Remove calibre update check
  80. patch -p1 < $CWD/patches/calibre-no-update.patch
  81. # Remove calibre portable scripts.
  82. rm -f resources/calibre-portable.*
  83. OVERRIDE_CFLAGS="$SLKCFLAGS" \
  84. OVERRIDE_LDFLAGS="-L/usr/lib${LIBDIRSUFFIX}" \
  85. python setup.py build
  86. # We have to fake out CALIBRE_CONFIG_DIRECTORY if there is a current
  87. # calibre installation while the build process takes place. :/
  88. mkdir -p "$PWD/tmp/config"
  89. # Hack for installing zsh completion.
  90. mkdir -p $PKG/usr/share/zsh/site-functions
  91. CALIBRE_CONFIG_DIRECTORY="$PWD/tmp/config" \
  92. python setup.py install \
  93. --root=$PKG \
  94. --prefix=/usr \
  95. --libdir=/usr/lib${LIBDIRSUFFIX} \
  96. --sharedir=/usr/share \
  97. --bindir=/usr/bin \
  98. --staging-libdir=$PKG/usr/lib${LIBDIRSUFFIX} \
  99. --staging-bindir=$PKG/usr/bin \
  100. --staging-sharedir=$PKG/usr/share
  101. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  102. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  103. # Fix permissions.
  104. find $PKG/usr/lib${LIBDIRSUFFIX} -iname "*\.py" -exec chmod 0644 '{}' \;
  105. # Install the necessary desktop items.
  106. mkdir -p $PKG/usr/share/{applications,mime/packages}
  107. cat src/calibre/linux.py | sed -n "/^VIEWER/,/^'''/p" | \
  108. sed -e "/'''/d" > $PKG/usr/share/applications/$PRGNAM-lrfviewer.desktop
  109. cat src/calibre/linux.py | sed -n "/^EVIEWER/,/^'''/p" | \
  110. sed -e "/'''/d" > $PKG/usr/share/applications/$PRGNAM-ebook-viewer.desktop
  111. cat src/calibre/linux.py | sed -n "/^ETWEAK/,/^'''/p" | \
  112. sed -e "/'''/d" > $PKG/usr/share/applications/$PRGNAM-ebook-edit.desktop
  113. cat src/calibre/linux.py | sed -n "/^GUI/,/^'''/p" | \
  114. sed -e "/'''/d" -e '/^Name/s|calibre|Calibre|' \
  115. > $PKG/usr/share/applications/$PRGNAM-gui.desktop
  116. install -D -m 0644 resources/$PRGNAM-mimetypes.xml $PKG/usr/share/mime/packages
  117. rm -f $PKG/usr/share/$PRGNAM/$PRGNAM-mimetypes.xml
  118. for i in 16 24 32 64 96 128; do
  119. convert resources/images/lt.png -resize ${i}x${i}! $PRGNAM-gui-${i}.png
  120. convert -background none imgsrc/viewer.svg \
  121. -resize ${i}x${i}! $PRGNAM-viewer-${i}.png
  122. convert imgsrc/mimetypes/lrf.svg \
  123. -resize ${i}x${i}! application-x-sony-bbeb-${i}.png
  124. convert resources/images/tweak.png -resize ${i}x${i}! $PRGNAM-ebook-edit-${i}.png
  125. install -D -m 0644 $PRGNAM-gui-${i}.png \
  126. $PKG/usr/share/icons/hicolor/${i}x${i}/apps/$PRGNAM-gui.png
  127. install -D -m 0644 $PRGNAM-viewer-${i}.png \
  128. $PKG/usr/share/icons/hicolor/${i}x${i}/apps/$PRGNAM-viewer.png
  129. install -D -m 0644 application-x-sony-bbeb-${i}.png \
  130. $PKG/usr/share/icons/hicolor/${i}x${i}/mimetypes/application-x-sony-bbeb.png
  131. install -D -m 0644 $PRGNAM-ebook-edit-${i}.png \
  132. $PKG/usr/share/icons/hicolor/${i}x${i}/apps/$PRGNAM-ebook-edit.png
  133. done
  134. # Don't ship fonts that are already in Slackware.
  135. for FONT in $PKG/usr/share/$PRGNAM/fonts/liberation/*; do
  136. # Make sure that the fonts exist first before deleting them.
  137. if find /usr/share/fonts/ -name "$(basename $FONT)" 2>/dev/null 1>/dev/null
  138. then
  139. rm -f $FONT
  140. ln -s $(find /usr/share/fonts/ -name "$(basename $FONT)") $FONT
  141. fi
  142. done
  143. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  144. cp -a \
  145. LICENSE* Changelog.yaml COPYRIGHT README.md \
  146. $PKG/usr/doc/$PRGNAM-$VERSION
  147. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  148. mkdir -p $PKG/install
  149. cat $CWD/slack-desc > $PKG/install/slack-desc
  150. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  151. cd $PKG
  152. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE