asap.SlackBuild 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. #!/bin/bash
  2. # Slackware build script for asap
  3. # Written by B. Watson (urchlay@slackware.uk)
  4. # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
  5. # Notes:
  6. # This SlackBuild turned out to be a lot more elaborate and in-depth
  7. # than I expected...
  8. # Do not build asapscan or the java/python/etc stuff: they require
  9. # "cito", because they're written in Ć (not C, C-with-acute-accent,
  10. # *.ci source files) and there's no SBo build for it... and I don't
  11. # think it's worth the trouble of creating one. What I probably
  12. # will do someday is create a cito SlackBuild, then use it to
  13. # build an asap-extras package that uses the same source as this,
  14. # including only the stuff that needs cito.
  15. # Slackware 15.0 has a binary called "asapcat", which is part of
  16. # akonadi. It's utterly unrelated to this asap build!
  17. # Any time vlc or xmms2 updates, this build has to be tested against
  18. # the new version. Currently it's known to work with:
  19. # xmms2-20170827_dedc33d
  20. # vlc-3.0.17.3
  21. cd $(dirname $0) ; CWD=$(pwd)
  22. PRGNAM=asap
  23. VERSION=${VERSION:-5.2.0}
  24. BUILD=${BUILD:-1}
  25. TAG=${TAG:-_SBo}
  26. PKGTYPE=${PKGTYPE:-tgz}
  27. if [ -z "$ARCH" ]; then
  28. case "$( uname -m )" in
  29. i?86) ARCH=i586 ;;
  30. arm*) ARCH=arm ;;
  31. *) ARCH=$( uname -m ) ;;
  32. esac
  33. fi
  34. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  35. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  36. exit 0
  37. fi
  38. TMP=${TMP:-/tmp/SBo}
  39. PKG=$TMP/package-$PRGNAM
  40. OUTPUT=${OUTPUT:-/tmp}
  41. if [ "$ARCH" = "i586" ]; then
  42. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  43. LIBDIRSUFFIX=""
  44. elif [ "$ARCH" = "i686" ]; then
  45. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  46. LIBDIRSUFFIX=""
  47. elif [ "$ARCH" = "x86_64" ]; then
  48. SLKCFLAGS="-O2 -fPIC"
  49. LIBDIRSUFFIX="64"
  50. else
  51. SLKCFLAGS="-O2"
  52. LIBDIRSUFFIX=""
  53. fi
  54. set -e
  55. rm -rf $PKG
  56. mkdir -p $TMP $PKG $OUTPUT
  57. cd $TMP
  58. rm -rf $PRGNAM-$VERSION
  59. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  60. cd $PRGNAM-$VERSION
  61. chown -R root:root .
  62. find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
  63. \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
  64. LIBDIR=/usr/lib$LIBDIRSUFFIX
  65. PKGLIBDIR=$PKG/$LIBDIR
  66. PKGBIN=$PKG/usr/bin
  67. PKGMAN1=$PKG/usr/man/man1
  68. # These functions help me follow the DRY principle.
  69. runmake() {
  70. make CFLAGS="$SLKCFLAGS" V=1 "$@"
  71. }
  72. installbin() {
  73. mkdir -p "$2"
  74. install -s -m0755 -oroot -groot "$1" "$2"
  75. }
  76. installfile() {
  77. mkdir -p "$2"
  78. install -m0644 -oroot -groot "$1" "$2"
  79. }
  80. installscript() {
  81. mkdir -p "$2"
  82. install -m0755 -oroot -groot "$1" "$2"
  83. }
  84. # I got carried away and wrote man pages for everything...
  85. # Note to self: don't forget to "sh mkman.sh" after editing
  86. # any of the man/*.rst files.
  87. mkdir -p $PKGMAN1
  88. for i in $CWD/man/*.1; do
  89. gzip -9c < $i > $PKGMAN1/$( basename $i ).gz
  90. done
  91. # Always build the standalone converter and library. The lib
  92. # is static (no option to make it dynamic).
  93. # There's a "make install" but it's not doing what I want.
  94. runmake
  95. installbin asapconv $PKGBIN
  96. installfile asap.h $PKG/usr/include
  97. installfile libasap.a $PKGLIBDIR
  98. # mplayer wrapper, for command-line users' convenience.
  99. installscript $CWD/asap-mplayer $PKGBIN
  100. # This tools looks useful.
  101. installscript chksap.pl $PKG/usr/bin
  102. # It has POD that renders as a man page. Clean up the formatting some
  103. # and add a SEE ALSO section like the rest of the man pages have.
  104. sed -i -e 's/^chksap -/chksap.pl -/' \
  105. -e 's/perl \(chksap\.pl\)/\1/' \
  106. -e '/^=cut/i=head1 SEE ALSO\n\nB<asap-mplayer>(1), B<asap-sdl>(1), B<asapconv>(1), B<sap2ntsc>(1), B<sap2txt>(1)\n' \
  107. chksap.pl
  108. pod2man -r$VERSION -s1 -cSlackBuilds.org chksap.pl | \
  109. gzip -9c > $PKG/usr/man/man1/chksap.pl.1.gz
  110. # Looks useful, but it would need cito (don't have):
  111. #runmake asapscan
  112. #installbin asapscan $PKGBIN
  113. # Standalone player (seems to work, dunno why it's not built by default).
  114. runmake asap-sdl
  115. installbin asap-sdl $PKGBIN
  116. # This builds and seems useful, especially since most SAP files have
  117. # PAL timing and I live in an NTSC country:
  118. gcc $SLKCFLAGS -o sap2ntsc sap2ntsc.c
  119. installbin sap2ntsc $PKGBIN
  120. # This, too:
  121. gcc $SLKCFLAGS -o sap2txt sap2txt.c -lz
  122. installbin sap2txt $PKGBIN
  123. # Now build the plugins.
  124. # moc is part of Slackware, but I'll make it optional anyway,
  125. # in case someone's running a stripped-down Slackware install.
  126. # We need the moc source, and have to ./configure it (but not
  127. # actually build it).
  128. if [ -x /usr/bin/mocp ]; then
  129. echo "=== building moc plugin"
  130. MOCVER="${MOCVER:-$( /usr/bin/mocp --version | grep Version | sed 's,.*: ,,' )}"
  131. tar xvf $CWD/moc-$MOCVER.tar.bz2
  132. ( cd moc-$MOCVER && ./configure )
  133. runmake asap-moc MOC_INCLUDE="$(pwd)/moc-$MOCVER"
  134. installbin libasap_decoder.so $PKGLIBDIR/moc/decoder_plugins
  135. PLUGINS+=" moc"
  136. fi
  137. # xmms is part of Slackware, but I'll make it optional anyway.
  138. if xmms-config --version &>/dev/null; then
  139. echo "=== building xmms plugin"
  140. runmake asap-xmms
  141. installbin libasap-xmms.so $PKG/"$( xmms-config --input-plugin-dir )"
  142. PLUGINS+=" xmms"
  143. fi
  144. # xmms2 is SBo, optional.
  145. if pkg-config --exists xmms2-plugin; then
  146. echo "=== building xmms2 plugin"
  147. # slight xmms2 API change:
  148. sed -i 's,XMMS_XFORM_PLUGIN,&_DEFINE,' xmms2/libxmms_asap.c
  149. runmake asap-xmms2
  150. installbin libxmms_asap.so $PKGLIBDIR/xmms2
  151. PLUGINS+=" xmms2"
  152. fi
  153. # vlc is SBo, optional.
  154. if pkg-config --exists vlc-plugin; then
  155. echo "=== building vlc plugin"
  156. runmake asap-vlc
  157. installbin libasap_plugin.so \
  158. $PKG/$( pkg-config --variable pluginsdir vlc-plugin )/demux
  159. PLUGINS+=" vlc"
  160. # doinst and douninst update the VLC plugins cache. only include
  161. # in the package if they're actually needed.
  162. mkdir -p $PKG/install
  163. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  164. cat $CWD/douninst.sh > $PKG/install/douninst.sh
  165. fi
  166. PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
  167. mkdir -p $PKGDOC/examples
  168. cd $PKGDOC/examples
  169. unzip -LL $CWD/examples.zip
  170. chmod 644 *
  171. cd -
  172. cp -a README COPYING $PKGDOC
  173. cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild
  174. mkdir -p $PKG/install
  175. sed "s,@PLUGINS@,$PLUGINS," < $CWD/slack-desc > $PKG/install/slack-desc
  176. cd $PKG
  177. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE