pipe-viewer.SlackBuild 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #!/bin/bash
  2. # Slackware build script for pipe-viewer
  3. # Written by B. Watson (urchlay@slackware.uk)
  4. # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
  5. cd $(dirname $0) ; CWD=$(pwd)
  6. PRGNAM=pipe-viewer
  7. VERSION=${VERSION:-0.1.8}
  8. BUILD=${BUILD:-1}
  9. TAG=${TAG:-_SBo}
  10. PKGTYPE=${PKGTYPE:-tgz}
  11. if [ -z "$ARCH" ]; then
  12. case "$( uname -m )" in
  13. i?86) ARCH=i586 ;;
  14. arm*) ARCH=arm ;;
  15. *) ARCH=$( uname -m ) ;;
  16. esac
  17. fi
  18. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  19. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  20. exit 0
  21. fi
  22. TMP=${TMP:-/tmp/SBo}
  23. PKG=$TMP/package-$PRGNAM
  24. OUTPUT=${OUTPUT:-/tmp}
  25. if [ "$ARCH" = "i586" ]; then
  26. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  27. LIBDIRSUFFIX=""
  28. elif [ "$ARCH" = "i686" ]; then
  29. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  30. LIBDIRSUFFIX=""
  31. elif [ "$ARCH" = "x86_64" ]; then
  32. SLKCFLAGS="-O2 -fPIC"
  33. LIBDIRSUFFIX="64"
  34. else
  35. SLKCFLAGS="-O2"
  36. LIBDIRSUFFIX=""
  37. fi
  38. set -e
  39. rm -rf $PKG
  40. mkdir -p $TMP $PKG $OUTPUT
  41. cd $TMP
  42. rm -rf $PRGNAM-$VERSION
  43. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  44. cd $PRGNAM-$VERSION
  45. chown -R root:root .
  46. find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
  47. \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
  48. # perl-Gtk3 is a runtime dep, we can build with GTK=yes even if it's not
  49. # installed... but don't do that by default.
  50. GTK="${GTK:-auto}"
  51. case "$GTK" in
  52. no) BUILD_GTK="no" ;;
  53. yes) BUILD_GTK="yes" ;;
  54. *) perl -MGtk3 -MFile::ShareDir -e 0 2>/dev/null \
  55. && BUILD_GTK="yes" \
  56. || BUILD_GTK="no" ;;
  57. esac
  58. [ "$BUILD_GTK" = "yes" ] && GTKOPT="--gtk"
  59. echo "=== GTK=$GTK BUILD_GTK=$BUILD_GTK GTKOPT=$GTKOPT"
  60. # Upstream used to support mplayer (in the original youtube-viewer,
  61. # before the straw-viewer and pipe-viewer forks), then dropped it.
  62. # That's as may be, but mplayer is included in core Slackware and the
  63. # other players aren't. So we'll give the user the option to at least
  64. # try it.
  65. patch -p1 < $CWD/restore_mplayer.diff
  66. perl Build.PL prefix=/usr installdirs=vendor --destdir="$PKG" $GTKOPT
  67. ./Build
  68. ./Build test
  69. ./Build install --install_path script=/usr/bin
  70. mv $PKG/usr/share/man $PKG/usr/man
  71. gzip -9 $PKG/usr/man/man?/*.?
  72. if [ "$BUILD_GTK" = "yes" ]; then
  73. # link .desktop to standard locations
  74. mkdir -p $PKG/usr/share/applications $PKG/usr/share/pixmaps
  75. LNPATH="../perl5/vendor_perl/auto/share/dist/WWW-PipeViewer"
  76. ln -s $LNPATH/gtk-$PRGNAM.desktop \
  77. $PKG/usr/share/applications/gtk-$PRGNAM.desktop
  78. # icon is huge (351x313)...
  79. for px in 16 32 48 64 128; do
  80. size=${px}x${px}
  81. dir=$PKG/usr/share/icons/hicolor/$size/apps
  82. mkdir -p $dir
  83. convert -resize $size share/icons/gtk-pipe-viewer.png $dir/gtk-$PRGNAM.png
  84. done
  85. ln -s ../icons/hicolor/48x48/apps/gtk-$PRGNAM.png \
  86. $PKG/usr/share/pixmaps/gtk-$PRGNAM.png
  87. # support TERMINAL option for user's preferred terminal.
  88. if [ "$TERMINAL" != "" ]; then
  89. sed -i "s/'gnome-terminal'/'$TERMINAL', &/" $PKG/usr/bin/gtk-$PRGNAM
  90. fi
  91. fi
  92. find $PKG -name perllocal.pod \
  93. -o -name ".packlist" \
  94. -o -name "*.bs" \
  95. | xargs rm -f
  96. find $PKG -depth -type d -empty -delete || true
  97. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  98. cp -a Changes LICENSE README* $PKG/usr/doc/$PRGNAM-$VERSION
  99. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  100. # the permissions in the final package are weird.
  101. find $PKG -type f -print0 | xargs -0 chmod 644
  102. find $PKG -type d -print0 | xargs -0 chmod 755
  103. chmod +x $PKG/usr/bin/*
  104. mkdir -p $PKG/install
  105. cat $CWD/slack-desc > $PKG/install/slack-desc
  106. cd $PKG
  107. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE