SOGo.SlackBuild 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. #!/bin/bash
  2. # Slackware build script for SOGo
  3. # Copyright 2018-2020 Chris Walker Kempner, TX
  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. # 20220218 bkw: Modified by SlackBuilds.org:
  23. # - get the docs out of DOWNLOAD in the info file. they were getting
  24. # downloaded (or failing to, due to user-agent checking on the
  25. # server), but only installed if the user set an environment
  26. # variable.
  27. cd $(dirname $0) ; CWD=$(pwd)
  28. PRGNAM=SOGo
  29. VERSION=${VERSION:-5.0.1}
  30. BUILD=${BUILD:-1}
  31. TAG=${TAG:-_SBo}
  32. PKGTYPE=${PKGTYPE:-tgz}
  33. if [ -z "$ARCH" ]; then
  34. case "$( uname -m )" in
  35. i?86) ARCH=i586 ;;
  36. arm*) ARCH=arm ;;
  37. *) ARCH=$( uname -m ) ;;
  38. esac
  39. fi
  40. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  41. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  42. exit 0
  43. fi
  44. TMP=${TMP:-/tmp/SBo}
  45. PKG=$TMP/package-$PRGNAM
  46. OUTPUT=${OUTPUT:-/tmp}
  47. if [ "$ARCH" = "i586" ]; then
  48. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  49. LIBDIRSUFFIX=""
  50. elif [ "$ARCH" = "i686" ]; then
  51. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  52. LIBDIRSUFFIX=""
  53. elif [ "$ARCH" = "x86_64" ]; then
  54. SLKCFLAGS="-O2 -fPIC"
  55. LIBDIRSUFFIX="64"
  56. else
  57. SLKCFLAGS="-O2"
  58. LIBDIRSUFFIX=""
  59. fi
  60. PRGUID=356
  61. PRGGID=356
  62. PRGUSR=${PRGUSR:-sogo}
  63. PRGGRP=${PRGGRP:-sogo}
  64. if [ -z "$(getent passwd $PRGUSR)" -o -z "$(getent group $PRGGRP)" ]; then
  65. echo
  66. echo "You must have the $PRGUSR user and $PRGGRP group in order to build $PRGNAM."
  67. echo
  68. echo "Example:"
  69. echo " # groupadd -g $PRGGID $PRGGRP"
  70. echo " # useradd -u $PRGUID -m -d /var/lib/$PRGUSR -s /bin/bash -g $PRGGRP $PRGUSR"
  71. echo
  72. exit 1
  73. fi
  74. set -e
  75. rm -rf $PKG
  76. mkdir -p $TMP $PKG $OUTPUT
  77. cd $TMP
  78. rm -rf $PRGNAM-$VERSION
  79. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  80. cd $PRGNAM-$VERSION
  81. chown -R root:root .
  82. find -L . \
  83. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  84. -o -perm 511 \) -exec chmod 755 {} \+ -o \
  85. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  86. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+
  87. CFLAGS="$SLKCFLAGS" \
  88. CXXFLAGS="$SLKCFLAGS" \
  89. ./configure \
  90. --enable-strip
  91. make
  92. make install DESTDIR=$PKG GNUSTEP_INSTALLATION_DOMAIN=SYSTEM
  93. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  94. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  95. mkdir -p $PKG/var/log/sogo $PKG/var/spool/sogo $PKG/var/run/sogo
  96. chown $PRGUSR:$PRGGRP $PKG/var/log/sogo $PKG/var/spool/sogo $PKG/var/run/sogo
  97. # Install daemon script
  98. mkdir -p $PKG/etc/rc.d
  99. sed -e "s,USER=sogo,USER=$PRGUSR,g" $CWD/rc.sogod > $PKG/etc/rc.d/rc.sogod.new
  100. # Install crontab files
  101. mkdir -p $PKG/etc/cron.d
  102. sed -e "s,\s\+sogo\s\+/usr/sbin, /usr/sbin,g" \
  103. -e "s,\s\+sogo\s\+/usr/share/doc/sogo, /usr/doc/$PRGNAM-$VERSION,g" \
  104. Scripts/sogo.cron > $PKG/etc/cron.d/sogo.new
  105. mkdir -p $PKG/etc/cron.daily
  106. cat Scripts/tmpwatch > $PKG/etc/cron.daily/sogo.new
  107. chmod +x $PKG/etc/cron.daily/sogo.new
  108. # Install logrotate config
  109. mkdir -p $PKG/etc/logrotate.d
  110. cat Scripts/logrotate > $PKG/etc/logrotate.d/sogo.new
  111. # Install configuration files
  112. mkdir -p $PKG/etc/{sogo,sysconfig}
  113. cat Scripts/sogo.conf > $PKG/etc/sogo/sogo.conf.new
  114. sed -e "s,USER=sogo,USER=$PRGUSR,g" \
  115. Scripts/sogo-default > $PKG/etc/sysconfig/sogo.new
  116. # Install example SOGo Apache configuration files
  117. mkdir -p $PKG/etc/httpd/extra
  118. sed -e "s,/lib/GNUstep,/lib${LIBDIRSUFFIX}/GNUstep,g" \
  119. Apache/SOGo.conf > $PKG/etc/httpd/extra/httpd-sogo.conf.new
  120. # Install documentation
  121. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  122. cp -a \
  123. COPYING.GPL COPYING.LGPL ChangeLog ChangeLog.old README.md \
  124. $PKG/usr/doc/$PRGNAM-$VERSION
  125. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  126. # 20220218 bkw: install PDF docs, if available.
  127. for i in \
  128. SOGoInstallationGuide \
  129. SOGoMozillaThunderbirdConfigurationGuide \
  130. SOGoOutlookConnectorConfigurationGuide
  131. do
  132. [ -e $CWD/$i.pdf ] && cat $CWD/$i.pdf > $PKG/usr/doc/$PRGNAM-$VERSION/$i.pdf
  133. done
  134. # Install backup script
  135. cat Scripts/sogo-backup.sh > $PKG/usr/doc/$PRGNAM-$VERSION/sogo-backup.sh
  136. chmod +x $PKG/usr/doc/$PRGNAM-$VERSION/sogo-backup.sh
  137. # Install fail2ban configuration files
  138. cp -r Scripts/fail2ban $PKG/usr/doc/$PRGNAM-$VERSION
  139. # Install Thunderbird extension propagation script
  140. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/Thunderbird
  141. cat Scripts/updates.php > $PKG/usr/doc/$PRGNAM-$VERSION/Thunderbird/updates.php
  142. # Install database scripts
  143. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/db
  144. cp -a \
  145. Scripts/mysql-utf8mb4.sql Scripts/sql-update-*.sh \
  146. $PKG/usr/doc/$PRGNAM-$VERSION/db
  147. mkdir -p $PKG/install
  148. cat $CWD/slack-desc > $PKG/install/slack-desc
  149. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  150. cd $PKG
  151. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE