svxlink.SlackBuild 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #!/bin/bash
  2. # Slackware build script for svxlink - cmake version
  3. # Copyright 2014-2022, 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.2}
  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 [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  36. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  37. exit 0
  38. fi
  39. CWD=$(pwd)
  40. TMP=${TMP:-/tmp/SBo}
  41. PKG=$TMP/package-$PRGNAM
  42. OUTPUT=${OUTPUT:-/tmp}
  43. if [ "$ARCH" = "i586" ]; then
  44. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  45. LIBDIRSUFFIX=""
  46. elif [ "$ARCH" = "i686" ]; then
  47. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  48. LIBDIRSUFFIX=""
  49. elif [ "$ARCH" = "x86_64" ]; then
  50. SLKCFLAGS="-O2 -fPIC"
  51. LIBDIRSUFFIX="64"
  52. else
  53. SLKCFLAGS="-O2"
  54. LIBDIRSUFFIX=""
  55. fi
  56. # get runtime configuration
  57. # invoke script as: QTEL=NO ./svxlink.SlackBuild
  58. # to compile svxlink only, no Qtel
  59. BUILD_QTEL="-DUSE_QT=YES" && [[ "$QTEL" = "NO" ]] && BUILD_QTEL="-DUSE_QT=NO"
  60. set -e
  61. # Bail if user or group isn't valid on your system
  62. if ! grep ^svxlink: /etc/passwd 2>&1 > /dev/null; then
  63. cat << EOF
  64. You must have a svxlink user and group to run this script
  65. # groupadd -g 286 svxlink
  66. # useradd -u 286 -g svxlink -d /var/spool/svxlink -s /bin/false svxlink
  67. EOF
  68. exit
  69. elif ! grep ^svxlink: /etc/group 2>&1 > /dev/null; then
  70. cat << EOF
  71. You must have a svxlink group to run this script
  72. # groupadd -g 286 svxlink
  73. EOF
  74. exit
  75. fi
  76. rm -rf $PKG
  77. mkdir -p $TMP $PKG $OUTPUT
  78. cd $TMP
  79. rm -rf $PRGNAM-$VERSION
  80. #tar xvf $CWD/$VERSION.tar.gz || tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  81. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  82. # the Github download unpacks several directories, we only need src
  83. # We will download a larger file but I think it's better this way
  84. # to make the overall process simpler
  85. cd $PRGNAM-$VERSION/src
  86. chown -R root:root .
  87. find -L . \
  88. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  89. -o -perm 511 \) -exec chmod 755 {} \; -o \
  90. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  91. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  92. mkdir -p build
  93. cd build
  94. cmake \
  95. $BUILD_QTEL \
  96. -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
  97. -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
  98. -DCMAKE_INSTALL_PREFIX=/usr \
  99. -DSYSCONF_INSTALL_DIR=/etc \
  100. -DLOCAL_STATE_DIR=/var \
  101. -DMAN_INSTALL_DIR=/usr/man \
  102. -DLIB_SUFFIX=${LIBDIRSUFFIX} \
  103. ..
  104. make
  105. make man install DESTDIR=$PKG
  106. cd ..
  107. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  108. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  109. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  110. cp -a ../COPYRIGHT doc/README* doc/*.txt doc/qteluserdocs/*.pdf doc/qteluserdocs/*.tex \
  111. $PKG/usr/doc/$PRGNAM-$VERSION
  112. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  113. # remove unused directories
  114. rm -r $PKG/usr/share/doc
  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