j4-dmenu-desktop.SlackBuild 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #!/bin/bash
  2. # Slackware build script for j4-dmenu-desktop
  3. # Written by B. Watson (yalhcru@gmail.com)
  4. # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
  5. # 20201103 bkw: update for 2.18 release
  6. # 20191128 bkw:
  7. # - Update for 2.17 release.
  8. # - Upstream now includes the man page in the tarball, use that
  9. # instead the old one that used to be here. Means this script can't
  10. # build older versions.
  11. # 20180112 bkw: Update for 2.16 release.
  12. # 20170301 bkw: Update for 2.15 release, use github long-form URL.
  13. # 20160726 bkw: Update for 2.14 release.
  14. # 20150914 bkw: Update for 2.13 release.
  15. # 20150512 bkw:
  16. # - Update for 2.12 release.
  17. # - Replace my man page with upstream's (from git).
  18. # - Escape dashes in terminal name, in man page (MANTERM).
  19. # - Replace no_interactive_shell.diff with sed -i.
  20. # 20140724 bkw: updated to 20140724 snapshot.
  21. # - Default to TERMINAL=xterm if i3-sensible-terminal not installed
  22. # on build host. Can still set TERMINAL in env to override.
  23. # - Fix hangs caused by using an interactive shell when there's no
  24. # controlling terminal. Thanks to crumb on ##slackware for the
  25. # bug report.
  26. # 20140310 bkw: updated to 20140310 snapshot.
  27. # - Added man page
  28. # - Added default terminal selection
  29. cd $(dirname $0) ; CWD=$(pwd)
  30. PRGNAM=j4-dmenu-desktop
  31. VERSION=${VERSION:-2.18}
  32. BUILD=${BUILD:-1}
  33. TAG=${TAG:-_SBo}
  34. PKGTYPE=${PKGTYPE:-tgz}
  35. if [ -z "$ARCH" ]; then
  36. case "$( uname -m )" in
  37. i?86) ARCH=i586 ;;
  38. arm*) ARCH=arm ;;
  39. *) ARCH=$( uname -m ) ;;
  40. esac
  41. fi
  42. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  43. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  44. exit 0
  45. fi
  46. TMP=${TMP:-/tmp/SBo}
  47. PKG=$TMP/package-$PRGNAM
  48. OUTPUT=${OUTPUT:-/tmp}
  49. if [ "$ARCH" = "i586" ]; then
  50. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  51. LIBDIRSUFFIX=""
  52. elif [ "$ARCH" = "i686" ]; then
  53. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  54. LIBDIRSUFFIX=""
  55. elif [ "$ARCH" = "x86_64" ]; then
  56. SLKCFLAGS="-O2 -fPIC"
  57. LIBDIRSUFFIX="64"
  58. else
  59. SLKCFLAGS="-O2"
  60. LIBDIRSUFFIX=""
  61. fi
  62. set -e
  63. rm -rf $PKG
  64. mkdir -p $TMP $PKG $OUTPUT
  65. cd $TMP
  66. rm -rf $PRGNAM-r$VERSION
  67. tar xvf $CWD/$PRGNAM-r$VERSION.tar.gz
  68. cd $PRGNAM-r$VERSION
  69. chown -R root:root .
  70. find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
  71. \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
  72. # For some reason, j4-dmenu-desktop uses "bash -i -c <command>" to execute
  73. # the user's choice. bash -i means interactive shell... which causes it to
  74. # hang if there's no controlling terminal. No idea why upstream wanted the -i
  75. # option in the first place, I've asked but not gotten an answer.
  76. sed -i '/execl(shell/s|"-i", *||' src/*.hh
  77. # For users who don't use i3, let them pick the default terminal.
  78. # If TERMINAL not set, and i3-sensible-terminal not installed, just
  79. # default to xterm.
  80. if which i3-sensible-terminal &>/dev/null; then
  81. DEFTERM="i3-sensible-terminal"
  82. else
  83. DEFTERM="xterm"
  84. fi
  85. TERMINAL="${TERMINAL:-$DEFTERM}"
  86. MANTERM="$( echo $TERMINAL | sed 's,-,\\\\-,g' )"
  87. echo "Using TERMINAL=$TERMINAL"
  88. sed -i "s,i3-sensible-terminal,$TERMINAL,g" src/Main.hh
  89. # Don't use 'make install', it wants to run the tests, which require
  90. # something called 'catch', which isn't shipped in the src (it tries to
  91. # download it, but fails, and I can't make myself care why). For the same
  92. # reason, have to use 'make $PRGNAM' instead of plain make.
  93. mkdir -p build
  94. cd build
  95. cmake \
  96. -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
  97. -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
  98. -DCMAKE_INSTALL_PREFIX=/usr \
  99. -DCMAKE_BUILD_TYPE=Release ..
  100. make $PRGNAM
  101. mkdir -p $PKG/usr/bin
  102. install -m0755 -s $PRGNAM $PKG/usr/bin/$PRGNAM
  103. cd ..
  104. # Tell the user what the default terminal is, in the man page.
  105. mkdir -p $PKG/usr/man/man1
  106. sed "s,to start terminal apps *\$,& (default: $MANTERM)," < $PRGNAM.1 | \
  107. gzip -9c > $PKG/usr/man/man1/$PRGNAM.1.gz
  108. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  109. cp -a CHANGELOG LICENSE README* $PKG/usr/doc/$PRGNAM-$VERSION
  110. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  111. mkdir -p $PKG/install
  112. sed "s,_TERMINAL_,$TERMINAL,g" $CWD/slack-desc > $PKG/install/slack-desc
  113. cd $PKG
  114. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE