openresty.SlackBuild 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #!/bin/sh
  2. #
  3. # Slackware build script for OpenResty
  4. #
  5. # Copyright (C) 2023-2024 Ricardo García Jiménez <ricardogj08@riseup.net>
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. #
  20. PRGNAM=openresty
  21. VERSION=${VERSION:-1.21.4.3}
  22. BUILD=${BUILD:-1}
  23. TAG=${TAG:-_rgj}
  24. PKGTYPE=${PKGTYPE:-tgz}
  25. NUMJOBS=${NUMJOBS:-"$(nproc)"}
  26. if [ -z "${ARCH}" ]; then
  27. case "$(uname -m)" in
  28. i?86) ARCH=i586 ;;
  29. arm*) ARCH=arm ;;
  30. *) ARCH=$(uname -m) ;;
  31. esac
  32. fi
  33. CWD=$(pwd)
  34. TMP=${TMP:-/tmp/build}
  35. PKG="${TMP}/package-${PRGNAM}"
  36. OUTPUT=${OUTPUT:-/tmp}
  37. if [ "${ARCH}" = "i586" ]; then
  38. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  39. LIBDIRSUFFIX=""
  40. elif [ "${ARCH}" = "i686" ]; then
  41. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  42. LIBDIRSUFFIX=""
  43. elif [ "${ARCH}" = "x86_64" ]; then
  44. SLKCFLAGS="-O2 -fPIC"
  45. LIBDIRSUFFIX="64"
  46. else
  47. SLKCFLAGS="-O2"
  48. LIBDIRSUFFIX=""
  49. fi
  50. set -e
  51. rm -rf "${PKG}"
  52. mkdir -p "${TMP}" "${PKG}" "${OUTPUT}"
  53. cd "${TMP}"
  54. rm -rf "${PRGNAM}-${VERSION}"
  55. tar xvf "${CWD}/${PRGNAM}-${VERSION}.tar.gz"
  56. cd "${PRGNAM}-${VERSION}"
  57. chown -R root:root .
  58. find -L . \
  59. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  60. -o -perm 511 \) -exec chmod 755 {} \; -o \
  61. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  62. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  63. CFLAGS="${SLKCFLAGS}" \
  64. CXXFLAGS="${SLKCFLAGS}" \
  65. ./configure \
  66. --prefix="/usr/lib${LIBDIRSUFFIX}/${PRGNAM}" \
  67. "-j${NUMJOBS}" \
  68. --with-http_iconv_module \
  69. --sbin-path="/usr/sbin/${PRGNAM}" \
  70. --modules-path="/usr/lib${LIBDIRSUFFIX}/nginx/modules" \
  71. --conf-path="/etc/${PRGNAM}/${PRGNAM}.conf" \
  72. --error-log-path="/var/log/${PRGNAM}/error.log" \
  73. --pid-path="/var/run/${PRGNAM}/${PRGNAM}.pid" \
  74. --lock-path="/var/run/${PRGNAM}/${PRGNAM}.lock" \
  75. --user="${RESTYUSER:=nobody}" \
  76. --group="${RESTYGROUP:=nogroup}" \
  77. --build="${ARCH}-slackware-linux" \
  78. --with-threads \
  79. --with-file-aio \
  80. --with-http_ssl_module \
  81. --with-http_v2_module \
  82. --with-http_realip_module \
  83. --with-http_addition_module \
  84. --with-http_xslt_module=dynamic \
  85. --with-http_image_filter_module=dynamic \
  86. --with-http_geoip_module=dynamic \
  87. --with-http_sub_module \
  88. --with-http_dav_module \
  89. --with-http_mp4_module \
  90. --with-http_gunzip_module \
  91. --with-http_gzip_static_module \
  92. --with-http_auth_request_module \
  93. --with-http_random_index_module \
  94. --with-http_secure_link_module \
  95. --with-http_degradation_module \
  96. --with-http_slice_module \
  97. --with-http_stub_status_module \
  98. --with-http_perl_module=dynamic \
  99. --with-perl_modules_path="/usr/lib${LIBDIRSUFFIX}/perl5/vendor_perl" \
  100. --http-log-path="/var/log/${PRGNAM}/access.log" \
  101. --http-client-body-temp-path="/var/tmp/${PRGNAM}/client_body" \
  102. --http-proxy-temp-path="/var/tmp/${PRGNAM}/proxy" \
  103. --http-fastcgi-temp-path="/var/tmp/${PRGNAM}/fastcgi" \
  104. --http-uwsgi-temp-path="/var/tmp/${PRGNAM}/uwsgi" \
  105. --http-scgi-temp-path="/var/tmp/${PRGNAM}/scgi" \
  106. --with-mail=dynamic \
  107. --with-mail_ssl_module \
  108. --with-stream=dynamic \
  109. --with-stream_ssl_module \
  110. --with-stream_realip_module \
  111. --with-stream_geoip_module=dynamic \
  112. --with-stream_ssl_preread_module \
  113. --with-pcre-jit
  114. make -j "${NUMJOBS}"
  115. make install DESTDIR="${PKG}"
  116. find "${PKG}" -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  117. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  118. mkdir -p "${PKG}/usr/man/man8"
  119. install -m 644 "build/nginx-${VERSION%\.*}/objs/nginx.8" "${PKG}/usr/man/man8/${PRGNAM}.8"
  120. find "${PKG}/usr/man" -type f -exec gzip -9 {} \;
  121. # Set the permissions for the log directory.
  122. chown "${RESTYUSER}" "${PKG}/var/log/${PRGNAM}"
  123. chmod 750 "${PKG}/var/log/${PRGNAM}"
  124. # Make the temp path.
  125. mkdir -p "${PKG}/var/tmp/${PRGNAM}"
  126. chown "${RESTYUSER}" "${PKG}/var/tmp/${PRGNAM}"
  127. chmod 700 "${PKG}/var/tmp/${PRGNAM}"
  128. # Add the OpenResty command-line utilities in the enviroment.
  129. mkdir -p "${PKG}/etc/profile.d"
  130. cat <<EOF > "${PKG}/etc/profile.d/${PRGNAM}.sh"
  131. #!/bin/sh
  132. export PATH="\${PATH}"
  133. PATH="\${PATH}:/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/bin"
  134. PATH="\${PATH}:/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/luajit/bin"
  135. EOF
  136. chmod 755 "${PKG}/etc/profile.d/${PRGNAM}.sh"
  137. # Add symbolic link to nginx.
  138. ln -sf "/usr/sbin/${PRGNAM}" "${PKG}/usr/sbin/nginx"
  139. mkdir -p "${PKG}/usr/doc/${PRGNAM}-${VERSION}"
  140. cp -a \
  141. COPYRIGHT README.markdown \
  142. "${PKG}/usr/doc/${PRGNAM}-${VERSION}"
  143. cat "${CWD}/${PRGNAM}.SlackBuild" > "${PKG}/usr/doc/${PRGNAM}-${VERSION}/${PRGNAM}.SlackBuild"
  144. mkdir -p "${PKG}/install"
  145. cat "${CWD}/doinst.sh" > "${PKG}/install/doinst.sh"
  146. cat "${CWD}/slack-desc" > "${PKG}/install/slack-desc"
  147. # Backup config files.
  148. find "${PKG}/etc/${PRGNAM}" -type f |
  149. while IFS= read -r file; do
  150. mv "${file}" "${file}.new"
  151. done
  152. cd "${PKG}"
  153. /sbin/makepkg -l y -c n "${OUTPUT}/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE}"