serviio.SlackBuild 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/bin/bash
  2. # serviio.SlackBuild: build script for Serviio DNLA Server
  3. # Copyright 2016 Luís Fernando Carvalho Cavalheiro ( pessoal at profcavalheiro dot com)
  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=serviio
  24. VERSION=${VERSION:-1.7.1.1}
  25. BUILD=${BUILD:-1}
  26. TAG=${TAG:-_SBo}
  27. PKGTYPE=${PKGTYPE:-tgz}
  28. SERVIIOGID=${SERVIIOGID:-337}
  29. SERVIIOUID=${SERVIIOUID:-337}
  30. if ! grep -q "^serviio:" /etc/group; then
  31. echo "$0: Error: $PRGNAM group ($SERVIIOGID) doesn't exist."
  32. echo "$0: Try creating one with:"
  33. echo " # groupadd -g $SERVIIOGID $PRGNAM"
  34. exit 1
  35. fi
  36. if ! grep -q "^serviio:" /etc/passwd; then
  37. echo "$0: Error: $PRGNAM user ($SERVIIOUID) doesn't exist."
  38. echo "$0: Try creating one with:"
  39. echo " # useradd -u $SERVIIOUID -g $SERVIIOGID -d /opt/$PRGNAM $PRGNAM"
  40. exit 1
  41. fi
  42. if [ -z "$ARCH" ]; then
  43. case "$( uname -m )" in
  44. i?86) ARCH=i586 ;;
  45. arm*) ARCH=arm ;;
  46. *) ARCH=$( uname -m ) ;;
  47. esac
  48. fi
  49. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  50. # the name of the created package would be, and then exit. This information
  51. # could be useful to other scripts.
  52. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  53. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  54. exit 0
  55. fi
  56. TMP=${TMP:-/tmp/SBo}
  57. PKG=$TMP/package-$PRGNAM
  58. OUTPUT=${OUTPUT:-/tmp}
  59. if [ "$ARCH" = "i586" ]; then
  60. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  61. LIBDIRSUFFIX=""
  62. elif [ "$ARCH" = "i686" ]; then
  63. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  64. LIBDIRSUFFIX=""
  65. elif [ "$ARCH" = "x86_64" ]; then
  66. SLKCFLAGS="-O2 -fPIC"
  67. LIBDIRSUFFIX="64"
  68. else
  69. SLKCFLAGS="-O2"
  70. LIBDIRSUFFIX=""
  71. fi
  72. set -e
  73. rm -rf $PKG
  74. mkdir -p $TMP $PKG $OUTPUT
  75. cd $TMP
  76. rm -rf $PRGNAM-$VERSION
  77. tar xvf $CWD/$PRGNAM-$VERSION-linux.tar.gz
  78. cd $PRGNAM-$VERSION
  79. chown -R root:root .
  80. find -L . \
  81. -type d -exec chmod 755 {} \; -o \
  82. -type f -exec chmod 644 {} \;
  83. chmod 755 bin/*
  84. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  85. mv -t $PKG/usr/doc/$PRGNAM-$VERSION LICENCE.txt NOTICE.txt README.txt RELEASE_NOTES.txt
  86. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  87. # Without this rc.serviio won't work
  88. sed -i '/^exec /s:$: \& echo \$! > /var/run/serviio/serviio.pid:' bin/serviio.sh
  89. mkdir -p $PKG/opt/$PRGNAM
  90. mv -t $PKG/opt/$PRGNAM *
  91. mkdir -p $PKG/etc/rc.d
  92. install --mode=644 $CWD/rc.$PRGNAM $PKG/etc/rc.d/rc.$PRGNAM.new
  93. mkdir -p $PKG/install
  94. cat $CWD/slack-desc > $PKG/install/slack-desc
  95. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  96. cd $PKG
  97. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE