123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- #!/bin/sh
- #
- # Slackware build script for OpenResty
- #
- # Copyright (C) 2023-2024 Ricardo García Jiménez <ricardogj08@riseup.net>
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <https://www.gnu.org/licenses/>.
- #
- PRGNAM=openresty
- VERSION=${VERSION:-1.21.4.3}
- BUILD=${BUILD:-1}
- TAG=${TAG:-_rgj}
- PKGTYPE=${PKGTYPE:-tgz}
- NUMJOBS=${NUMJOBS:-"$(nproc)"}
- if [ -z "${ARCH}" ]; then
- case "$(uname -m)" in
- i?86) ARCH=i586 ;;
- arm*) ARCH=arm ;;
- *) ARCH=$(uname -m) ;;
- esac
- fi
- CWD=$(pwd)
- TMP=${TMP:-/tmp/build}
- PKG="${TMP}/package-${PRGNAM}"
- OUTPUT=${OUTPUT:-/tmp}
- if [ "${ARCH}" = "i586" ]; then
- SLKCFLAGS="-O2 -march=i586 -mtune=i686"
- LIBDIRSUFFIX=""
- elif [ "${ARCH}" = "i686" ]; then
- SLKCFLAGS="-O2 -march=i686 -mtune=i686"
- LIBDIRSUFFIX=""
- elif [ "${ARCH}" = "x86_64" ]; then
- SLKCFLAGS="-O2 -fPIC"
- LIBDIRSUFFIX="64"
- else
- SLKCFLAGS="-O2"
- LIBDIRSUFFIX=""
- fi
- set -e
- rm -rf "${PKG}"
- mkdir -p "${TMP}" "${PKG}" "${OUTPUT}"
- cd "${TMP}"
- rm -rf "${PRGNAM}-${VERSION}"
- tar xvf "${CWD}/${PRGNAM}-${VERSION}.tar.gz"
- cd "${PRGNAM}-${VERSION}"
- chown -R root:root .
- find -L . \
- \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
- -o -perm 511 \) -exec chmod 755 {} \; -o \
- \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
- -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
- CFLAGS="${SLKCFLAGS}" \
- CXXFLAGS="${SLKCFLAGS}" \
- ./configure \
- --prefix="/usr/lib${LIBDIRSUFFIX}/${PRGNAM}" \
- "-j${NUMJOBS}" \
- --with-http_iconv_module \
- --sbin-path="/usr/sbin/${PRGNAM}" \
- --modules-path="/usr/lib${LIBDIRSUFFIX}/nginx/modules" \
- --conf-path="/etc/${PRGNAM}/${PRGNAM}.conf" \
- --error-log-path="/var/log/${PRGNAM}/error.log" \
- --pid-path="/var/run/${PRGNAM}/${PRGNAM}.pid" \
- --lock-path="/var/run/${PRGNAM}/${PRGNAM}.lock" \
- --user="${RESTYUSER:=nobody}" \
- --group="${RESTYGROUP:=nogroup}" \
- --build="${ARCH}-slackware-linux" \
- --with-threads \
- --with-file-aio \
- --with-http_ssl_module \
- --with-http_v2_module \
- --with-http_realip_module \
- --with-http_addition_module \
- --with-http_xslt_module=dynamic \
- --with-http_image_filter_module=dynamic \
- --with-http_geoip_module=dynamic \
- --with-http_sub_module \
- --with-http_dav_module \
- --with-http_mp4_module \
- --with-http_gunzip_module \
- --with-http_gzip_static_module \
- --with-http_auth_request_module \
- --with-http_random_index_module \
- --with-http_secure_link_module \
- --with-http_degradation_module \
- --with-http_slice_module \
- --with-http_stub_status_module \
- --with-http_perl_module=dynamic \
- --with-perl_modules_path="/usr/lib${LIBDIRSUFFIX}/perl5/vendor_perl" \
- --http-log-path="/var/log/${PRGNAM}/access.log" \
- --http-client-body-temp-path="/var/tmp/${PRGNAM}/client_body" \
- --http-proxy-temp-path="/var/tmp/${PRGNAM}/proxy" \
- --http-fastcgi-temp-path="/var/tmp/${PRGNAM}/fastcgi" \
- --http-uwsgi-temp-path="/var/tmp/${PRGNAM}/uwsgi" \
- --http-scgi-temp-path="/var/tmp/${PRGNAM}/scgi" \
- --with-mail=dynamic \
- --with-mail_ssl_module \
- --with-stream=dynamic \
- --with-stream_ssl_module \
- --with-stream_realip_module \
- --with-stream_geoip_module=dynamic \
- --with-stream_ssl_preread_module \
- --with-pcre-jit
- make -j "${NUMJOBS}"
- make install DESTDIR="${PKG}"
- find "${PKG}" -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
- | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
- mkdir -p "${PKG}/usr/man/man8"
- install -m 644 "build/nginx-${VERSION%\.*}/objs/nginx.8" "${PKG}/usr/man/man8/${PRGNAM}.8"
- find "${PKG}/usr/man" -type f -exec gzip -9 {} \;
- # Set the permissions for the log directory.
- chown "${RESTYUSER}" "${PKG}/var/log/${PRGNAM}"
- chmod 750 "${PKG}/var/log/${PRGNAM}"
- # Make the temp path.
- mkdir -p "${PKG}/var/tmp/${PRGNAM}"
- chown "${RESTYUSER}" "${PKG}/var/tmp/${PRGNAM}"
- chmod 700 "${PKG}/var/tmp/${PRGNAM}"
- # Add the OpenResty command-line utilities in the enviroment.
- mkdir -p "${PKG}/etc/profile.d"
- cat <<EOF > "${PKG}/etc/profile.d/${PRGNAM}.sh"
- #!/bin/sh
- export PATH="\${PATH}"
- PATH="\${PATH}:/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/bin"
- PATH="\${PATH}:/usr/lib${LIBDIRSUFFIX}/${PRGNAM}/luajit/bin"
- EOF
- chmod 755 "${PKG}/etc/profile.d/${PRGNAM}.sh"
- # Add symbolic link to nginx.
- ln -sf "/usr/sbin/${PRGNAM}" "${PKG}/usr/sbin/nginx"
- mkdir -p "${PKG}/usr/doc/${PRGNAM}-${VERSION}"
- cp -a \
- COPYRIGHT README.markdown \
- "${PKG}/usr/doc/${PRGNAM}-${VERSION}"
- cat "${CWD}/${PRGNAM}.SlackBuild" > "${PKG}/usr/doc/${PRGNAM}-${VERSION}/${PRGNAM}.SlackBuild"
- mkdir -p "${PKG}/install"
- cat "${CWD}/doinst.sh" > "${PKG}/install/doinst.sh"
- cat "${CWD}/slack-desc" > "${PKG}/install/slack-desc"
- # Backup config files.
- find "${PKG}/etc/${PRGNAM}" -type f |
- while IFS= read -r file; do
- mv "${file}" "${file}.new"
- done
- cd "${PKG}"
- /sbin/makepkg -l y -c n "${OUTPUT}/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE}"
|