svxlink.SlackBuild 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #!/bin/bash
  2. # Slackware build script for svxlink - cmake version
  3. # Copyright 2014-2019, Gustavo Conrad (gus3963 gmail)
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  13. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  15. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. cd $(dirname $0) ; CWD=$(pwd)
  23. PRGNAM=svxlink
  24. VERSION=${VERSION:-19.09.1}
  25. BUILD=${BUILD:-1}
  26. TAG=${TAG:-_SBo}
  27. PKGTYPE=${PKGTYPE:-tgz}
  28. if [ -z "$ARCH" ]; then
  29. case "$( uname -m )" in
  30. i?86) ARCH=i586 ;;
  31. arm*) ARCH=arm ;;
  32. *) ARCH=$( uname -m ) ;;
  33. esac
  34. fi
  35. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  36. # the name of the created package would be, and then exit. This information
  37. # could be useful to other scripts.
  38. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  39. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  40. exit 0
  41. fi
  42. TMP=${TMP:-/tmp/SBo}
  43. PKG=$TMP/package-$PRGNAM
  44. OUTPUT=${OUTPUT:-/tmp}
  45. if [ "$ARCH" = "i586" ]; then
  46. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  47. LIBDIRSUFFIX=""
  48. elif [ "$ARCH" = "i686" ]; then
  49. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  50. LIBDIRSUFFIX=""
  51. elif [ "$ARCH" = "x86_64" ]; then
  52. SLKCFLAGS="-O2 -fPIC"
  53. LIBDIRSUFFIX="64"
  54. else
  55. SLKCFLAGS="-O2"
  56. LIBDIRSUFFIX=""
  57. fi
  58. # get runtime configuration
  59. # invoke script as: QTEL=NO ./svxlink.SlackBuild
  60. # to compile svxlink only, no Qtel
  61. BUILD_QTEL="-DUSE_QT=YES" && [[ "$QTEL" = "NO" ]] && BUILD_QTEL="-DUSE_QT=NO"
  62. set -e
  63. # Bail if user or group isn't valid on your system
  64. if ! grep ^svxlink: /etc/passwd 2>&1 > /dev/null; then
  65. cat << EOF
  66. You must have a svxlink user and group to run this script
  67. # groupadd -g 286 svxlink
  68. # useradd -u 286 -g svxlink -d /var/spool/svxlink -s /bin/false svxlink
  69. EOF
  70. exit
  71. elif ! grep ^svxlink: /etc/group 2>&1 > /dev/null; then
  72. cat << EOF
  73. You must have a svxlink group to run this script
  74. # groupadd -g 286 svxlink
  75. EOF
  76. exit
  77. fi
  78. rm -rf $PKG
  79. mkdir -p $TMP $PKG $OUTPUT
  80. cd $TMP
  81. rm -rf $PRGNAM-$VERSION
  82. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  83. # the Github download unpacks several directories, we only need src
  84. # We will download a larger file but I think it's better this way
  85. # to make the overall process simpler
  86. cd $PRGNAM-$VERSION/src
  87. chown -R root:root .
  88. find -L . \
  89. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  90. -o -perm 511 \) -exec chmod 755 {} \; -o \
  91. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  92. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  93. mkdir -p build
  94. cd build
  95. cmake \
  96. $BUILD_QTEL \
  97. -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
  98. -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS -fpermissive" \
  99. -DCMAKE_INSTALL_PREFIX=/usr \
  100. -DSYSCONF_INSTALL_DIR=/etc \
  101. -DLOCAL_STATE_DIR=/var \
  102. -DLIB_SUFFIX=${LIBDIRSUFFIX} \
  103. ..
  104. make
  105. make doc
  106. make install DESTDIR=$PKG
  107. cd ..
  108. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  109. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  110. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  111. cp -a ../COPYRIGHT doc/README* doc/*.txt doc/qteluserdocs/*.pdf doc/qteluserdocs/*.tex \
  112. $PKG/usr/doc/$PRGNAM-$VERSION
  113. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  114. mv $PKG/usr/share/man $PKG/usr/
  115. mkdir -p $PKG/install
  116. cat $CWD/slack-desc > $PKG/install/slack-desc
  117. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  118. mkdir -p $PKG/etc/rc.d
  119. cat $CWD/rc.svxlink > $PKG/etc/rc.d/rc.svxlink.new
  120. mkdir -p $PKG/etc/logrotate.d
  121. cat $CWD/svxlink > $PKG/etc/logrotate.d/svxlink
  122. # Rename .conf to .new to be processed by doinst.sh
  123. rename .conf .conf.new $PKG/etc/svxlink/*
  124. rename .conf .conf.new $PKG/etc/svxlink/svxlink.d/*.conf
  125. cd $PKG
  126. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE