lsmi.SlackBuild 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/bin/bash
  2. # Slackware build script for lsmi
  3. # Written by B. Watson (yalhcru@gmail.com)
  4. # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
  5. cd $(dirname $0) ; CWD=$(pwd)
  6. PRGNAM=lsmi
  7. VERSION=${VERSION:-0.1}
  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/usr/bin $OUTPUT
  41. cd $TMP
  42. rm -rf $PRGNAM
  43. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  44. cd $PRGNAM
  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. # all this seddery could have been done with a diff, I just felt like
  49. # using sed today for some reason.
  50. # use our flags and install to our directory.
  51. sed -i \
  52. -e "s/-g/$SLKCFLAGS/" \
  53. -e "s,/usr/local/bin,$PKG/usr/bin," \
  54. -e "s,install ,install -s -m0755 ," \
  55. Makefile
  56. # fix typo in --help output
  57. sed -i 's/thrree/three/' lsmi-mouse.c
  58. # make keyhack's --help actually work
  59. sed -i 's/fprintf.*Help.*/usage();/' lsmi-keyhack.c
  60. # fix possible segfault
  61. sed -i 's/\(char *prog_buf\)\[4\]/\1[5]/' lsmi-keyhack.c
  62. # As shipped, only lsmi-monterey supports POSIX realtime scheduling. This
  63. # patch (by the SlackBuild author) adds the -R option to the other lsmi-*
  64. # binaries.
  65. patch -p1 < $CWD/rtprio.diff
  66. make
  67. make install
  68. # man pages came from the Musix project:
  69. # ftp://musix.ourproject.org/pub/musix/deb/lsmi_0.1-1_i386.deb
  70. # Modified a bit: fixed a typo, rewrote section
  71. # about realtime scheduling so it applies to Slackware.
  72. mkdir -p $PKG/usr/man/man1
  73. cd $CWD/man
  74. for i in *; do
  75. gzip -9c < $i > $PKG/usr/man/man1/$i.gz
  76. done
  77. cd -
  78. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  79. cp -a README $PKG/usr/doc/$PRGNAM-$VERSION
  80. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  81. mkdir -p $PKG/install
  82. cat $CWD/slack-desc > $PKG/install/slack-desc
  83. if [ "${SETCAP:-yes}" = "yes" ]; then
  84. cat $CWD/setcap.sh >> $PKG/install/doinst.sh
  85. for i in lsmi-joystick lsmi-keyhack lsmi-monterey lsmi-mouse; do
  86. chown root:audio $PKG/usr/bin/$i
  87. chmod 0750 $PKG/usr/bin/$i
  88. done
  89. fi
  90. cd $PKG
  91. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE