Files
termux-packages/packages/luarocks/build.sh
termux-pacman-bot ff5a922150 fix(main/luarocks): wrap return "linux" with if true condition in sysdetect-no-proc.patch
- Fixes https://github.com/termux/termux-packages/issues/25320

- In Lua, unfortunately, **`return` statement before the end of a block is not allowed** and produces a syntax error at runtime. Placing the `return "linux"` statement at the beginnning of the function for easier rebasing of the patch is possible, but **only by placing it inside of an `if true` condition**.
  - https://www.lua.org/pil/4.4.html
  - "For syntactic reasons, a `break` or `return` can appear only as the last statement of a block"
2025-07-11 08:43:35 +00:00

44 lines
1.5 KiB
Bash

TERMUX_PKG_HOMEPAGE=https://luarocks.org/
TERMUX_PKG_DESCRIPTION="Deployment and management system for Lua modules"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="3.12.2"
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://luarocks.org/releases/luarocks-${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=b0e0c85205841ddd7be485f53d6125766d18a81d226588d2366931e9a1484492
TERMUX_PKG_AUTO_UPDATE=true
__LUA_VERSION=5.1 # Lua version against which it will be built.
# Do not use varible here since buildorder.py do not evaluate bash before reading.
TERMUX_PKG_DEPENDS="curl, lua51"
TERMUX_PKG_BUILD_DEPENDS="liblua51"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_PLATFORM_INDEPENDENT=true
termux_step_configure() {
if [ "$TERMUX_ON_DEVICE_BUILD" != true ]; then
# Create temporary symlink to workaround luarock bootstrap
# script trying to run cross-compiled lua
mv "$TERMUX_PREFIX"/bin/lua"$__LUA_VERSION"{,.bak}
ln -sf /usr/bin/lua"$__LUA_VERSION" "$TERMUX_PREFIX"/bin/lua"$__LUA_VERSION"
fi
./configure --prefix="$TERMUX_PREFIX" \
--with-lua="$TERMUX_PREFIX"
}
termux_step_post_make_install() {
if [ "$TERMUX_ON_DEVICE_BUILD" != "true" ]; then
# Restore lua
unlink "$TERMUX_PREFIX"/bin/lua"$__LUA_VERSION"
mv "$TERMUX_PREFIX"/bin/lua"$__LUA_VERSION"{.bak,}
fi
}
termux_step_post_massage() {
if [ "$TERMUX_ON_DEVICE_BUILD" != true ]; then
# Remove lua, due to us moving it back and fourth, the build system
# thinks it is a newly compiled package.
rm bin/lua"$__LUA_VERSION"
fi
}