openresty-luarocks.SlackBuild 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/sh
  2. #
  3. # Slackware build script for LuaRocks with 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-luarocks
  21. SRCNAM=${PRGNAM#*-}
  22. VERSION=${VERSION:-3.10.0}
  23. BUILD=${BUILD:-1}
  24. TAG=${TAG:-_rgj}
  25. PKGTYPE=${PKGTYPE:-tgz}
  26. NUMJOBS=${NUMJOBS:-"$(nproc)"}
  27. if [ -z "${ARCH}" ]; then
  28. case "$(uname -m)" in
  29. i?86) ARCH=i586 ;;
  30. arm*) ARCH=arm ;;
  31. *) ARCH=$(uname -m) ;;
  32. esac
  33. fi
  34. CWD=$(pwd)
  35. TMP=${TMP:-/tmp/build}
  36. PKG="${TMP}/package-${PRGNAM}"
  37. OUTPUT=${OUTPUT:-/tmp}
  38. if [ "${ARCH}" = "i586" ]; then
  39. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  40. LIBDIRSUFFIX=""
  41. elif [ "${ARCH}" = "i686" ]; then
  42. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  43. LIBDIRSUFFIX=""
  44. elif [ "${ARCH}" = "x86_64" ]; then
  45. SLKCFLAGS="-O2 -fPIC"
  46. LIBDIRSUFFIX="64"
  47. else
  48. SLKCFLAGS="-O2"
  49. LIBDIRSUFFIX=""
  50. fi
  51. set -e
  52. rm -rf "${PKG}"
  53. mkdir -p "${TMP}" "${PKG}" "${OUTPUT}"
  54. cd "${TMP}"
  55. rm -rf "${PRGNAM}-${VERSION}"
  56. tar xvf "${CWD}/${SRCNAM}-${VERSION}.tar.gz"
  57. cd "${SRCNAM}-${VERSION}"
  58. chown -R root:root .
  59. find -L . \
  60. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  61. -o -perm 511 \) -exec chmod 755 {} \; -o \
  62. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  63. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  64. CFLAGS="${SLKCFLAGS}" \
  65. CXXFLAGS="${SLKCFLAGS}" \
  66. ./configure \
  67. --prefix=/usr \
  68. --sysconfdir=/etc \
  69. --rocks-tree="/usr/lib${LIBDIRSUFFIX}/openresty/luajit" \
  70. --lua-version=5.1 \
  71. --with-lua="/usr/lib${LIBDIRSUFFIX}/openresty/luajit" \
  72. --force-config
  73. make -j "${NUMJOBS}"
  74. make install DESTDIR="${PKG}"
  75. find "${PKG}" -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  76. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  77. mkdir -p "${PKG}/usr/doc/${PRGNAM}-${VERSION}"
  78. cp -a \
  79. CHANGELOG.md CODE_OF_CONDUCT.md COPYING README.md SECURITY.md \
  80. "${PKG}/usr/doc/${PRGNAM}-${VERSION}"
  81. cat "${CWD}/${PRGNAM}.SlackBuild" > "${PKG}/usr/doc/${PRGNAM}-${VERSION}/${PRGNAM}.SlackBuild"
  82. mkdir -p "${PKG}/install"
  83. cat "${CWD}/doinst.sh" > "${PKG}/install/doinst.sh"
  84. cat "${CWD}/slack-desc" > "${PKG}/install/slack-desc"
  85. # Backup config files.
  86. find "${PKG}/etc/${SRCNAM}" -type f |
  87. while IFS= read -r file; do
  88. mv "${file}" "${file}.new"
  89. done
  90. cd "${PKG}"
  91. /sbin/makepkg -l y -c n "${OUTPUT}/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE}"