sonarqube.SlackBuild 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/bin/bash
  2. # Slackware build script for sonarqube
  3. # Copyright 2016 Giorgio Peron <giorgio.peron@gmail.com>, Belluno, Italy
  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=sonarqube
  24. VERSION=${VERSION:-5.6.1}
  25. BUILD=${BUILD:-1}
  26. TAG=${TAG:-_SBo}
  27. PKGTYPE=${PKGTYPE:-tgz}
  28. bailout() {
  29. printf "\nThis requires a \"sonar\" user and group.\n"
  30. printf "\tgroupadd -g 287 sonar\n"
  31. printf "\tuseradd -g 287 -u 287 -r -c 'SonarQube user' -s /bin/bash -d /usr/share/sonarqube sonar\n\n"
  32. exit 1
  33. }
  34. if ! getent group sonar 2>/dev/null 1>/dev/null ; then
  35. bailout
  36. elif ! getent passwd sonar 2>/dev/null 1>/dev/null ; then
  37. bailout
  38. fi
  39. if [ -z "$ARCH" ]; then
  40. case "$( uname -m )" in
  41. i?86) ARCH=i586 ;;
  42. arm*) ARCH=arm ;;
  43. *) ARCH=$( uname -m ) ;;
  44. esac
  45. fi
  46. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  47. # the name of the created package would be, and then exit. This information
  48. # could be useful to other scripts.
  49. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  50. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  51. exit 0
  52. fi
  53. TMP=${TMP:-/tmp/SBo}
  54. PKG=$TMP/package-$PRGNAM
  55. OUTPUT=${OUTPUT:-/tmp}
  56. if [ "$ARCH" = "i586" ]; then
  57. SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  58. LIBDIRSUFFIX=""
  59. BINDIR="linux-x86-32"
  60. elif [ "$ARCH" = "i686" ]; then
  61. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  62. LIBDIRSUFFIX=""
  63. BINDIR="linux-x86-32"
  64. elif [ "$ARCH" = "x86_64" ]; then
  65. SLKCFLAGS="-O2 -fPIC"
  66. LIBDIRSUFFIX="64"
  67. BINDIR="linux-x86-64"
  68. else
  69. SLKCFLAGS="-O2"
  70. BINDIR=""
  71. fi
  72. set -e
  73. rm -rf $PKG $TMP/$PRGNAM-$VERSION
  74. mkdir -p $PKG $OUTPUT
  75. cd $TMP
  76. unzip $CWD/$PRGNAM-$VERSION.zip
  77. mkdir -p $PKG/usr/share/$PRGNAM
  78. mkdir -p $PKG/var/{log,run,tmp}/$PRGNAM
  79. mkdir -p $PKG/etc/rc.d
  80. mv $TMP/$PRGNAM-$VERSION/* $PKG/usr/share/$PRGNAM/
  81. # expose the configuration file under /etc
  82. mv $PKG/usr/share/$PRGNAM/conf/sonar.properties{,.new}
  83. mv $PKG/usr/share/$PRGNAM/conf/wrapper.conf{,.new}
  84. cd $PKG/etc
  85. ln -sf ../usr/share/$PRGNAM/conf $PRGNAM
  86. sed -i "s_sonar.jdbc.url=jdbc:h2:_#sonar.jdbc.url=jdbc:h2:_g" $PKG/usr/share/$PRGNAM/conf/sonar.properties.new
  87. sed -i "s_#sonar.jdbc.url=jdbc:mysql:_sonar.jdbc.url=jdbc:mysql:_g" $PKG/usr/share/$PRGNAM/conf/sonar.properties.new
  88. sed -i "s_#sonar.web.context=_sonar.web.context=/sonarqube_g" $PKG/usr/share/$PRGNAM/conf/sonar.properties.new
  89. sed -i "s_wrapper.java.command=java_wrapper.java.command=/usr/lib${LIBDIRSUFFIX}/java/bin/java_g" $PKG/usr/share/$PRGNAM/conf/wrapper.conf.new
  90. chown -R sonar:sonar $PKG/usr/share/$PRGNAM
  91. chown -R sonar:sonar $PKG/var/{log,run,tmp}/$PRGNAM
  92. rm -rf $PKG/usr/share/$PRGNAM/logs
  93. rm -rf $PKG/usr/share/$PRGNAM/temp
  94. cd $PKG/usr/share/$PRGNAM
  95. ln -fs ../../../var/log/$PRGNAM logs
  96. ln -fs ../../../var/tmp/$PRGNAM temp
  97. # remove the executables for the others platforms
  98. cd $PKG/usr/share/$PRGNAM/bin
  99. find . -type d -not -name ${BINDIR} -not -name "." -not -name "lib" | xargs rm -rf
  100. cat $CWD/rc.$PRGNAM > $PKG/etc/rc.d/rc.$PRGNAM.new
  101. sed -i "s:WRAPPER_CMD=\"./wrapper\":WRAPPER_CMD=\"/usr/share/sonarqube/bin/${BINDIR}/wrapper\":g" $PKG/etc/rc.d/rc.$PRGNAM.new
  102. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  103. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  104. mkdir -p $PKG/install
  105. cat $CWD/slack-desc > $PKG/install/slack-desc
  106. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  107. cd $PKG
  108. /sbin/makepkg -c n -l y $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE