mag.SlackBuild 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. # Slackware build script for mag
  3. # Written by B. Watson (yalhcru@gmail.com)
  4. # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
  5. # VERSION comes from the last modified date on the homepage.
  6. # 20211207 bkw: BUILD=2
  7. # - fix blank window on -current (it shouldn't have worked on 14.2 either).
  8. # - add BUGS to man page (no way to exit mag).
  9. cd $(dirname $0) ; CWD=$(pwd)
  10. PRGNAM=mag
  11. VERSION=${VERSION:-20100913}
  12. BUILD=${BUILD:-2}
  13. TAG=${TAG:-_SBo}
  14. PKGTYPE=${PKGTYPE:-tgz}
  15. if [ -z "$ARCH" ]; then
  16. case "$( uname -m )" in
  17. i?86) ARCH=i586 ;;
  18. arm*) ARCH=arm ;;
  19. *) ARCH=$( uname -m ) ;;
  20. esac
  21. fi
  22. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  23. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  24. exit 0
  25. fi
  26. TMP=${TMP:-/tmp/SBo}
  27. PKG=$TMP/package-$PRGNAM
  28. OUTPUT=${OUTPUT:-/tmp}
  29. if [ "$ARCH" = "i586" ]; then
  30. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  31. LIBDIRSUFFIX=""
  32. elif [ "$ARCH" = "i686" ]; then
  33. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  34. LIBDIRSUFFIX=""
  35. elif [ "$ARCH" = "x86_64" ]; then
  36. SLKCFLAGS="-O2 -fPIC"
  37. LIBDIRSUFFIX="64"
  38. else
  39. SLKCFLAGS="-O2"
  40. LIBDIRSUFFIX=""
  41. fi
  42. set -e
  43. # Since it's just a single C source file, we don't have a
  44. # $TMP/$PRGNAM-$VERSION and don't need find/chown/chmod stuff.
  45. # In case you're wondering, -Wl,-s builds a stripped binary.
  46. rm -rf $PKG
  47. mkdir -p $PKG/usr/bin $OUTPUT
  48. cd $PKG
  49. # 20211207 bkw: we *do* have to patch it now, and we don't want
  50. # to write to $CWD, so:
  51. cat $CWD/$PRGNAM.c > $PRGNAM.c
  52. # 20211207 bkw: silly mistake in the code: it was calling
  53. # XDestroyImage(ximage) before the for loop that *uses* ximage.
  54. # On 14.2's X, this was equivalent to a use-after-free, and worked
  55. # accidentally most (or even all) of the time, but on -current's X,
  56. # it results in a blank (all-black) window.
  57. patch -p0 < $CWD/xdestroyimage.diff
  58. gcc $SLKCFLAGS -Wl,-s -o $PKG/usr/bin/$PRGNAM $PRGNAM.c -lX11
  59. rm $PRGNAM.c
  60. # Man page written by SlackBuild author. Please don't include mag.rst
  61. # in the package, it's the source for the man page only.
  62. mkdir -p $PKG/usr/man/man1
  63. gzip -9c < $CWD/$PRGNAM.1 > $PKG/usr/man/man1/$PRGNAM.1.gz
  64. # Include our own README.
  65. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  66. cat $CWD/README > $PKG/usr/doc/$PRGNAM-$VERSION/README
  67. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  68. mkdir -p $PKG/install
  69. cat $CWD/slack-desc > $PKG/install/slack-desc
  70. cd $PKG
  71. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE