luarocks: fix system detect

Can't read /proc on android.

Fixes https://github.com/termux/termux-packages/issues/8780, fix
found by @ramonrwx.
This commit is contained in:
Henrik Grimler 2022-01-30 15:11:12 +01:00
parent e7365c115c
commit aed08bf1d6
No known key found for this signature in database
GPG Key ID: B0076E490B71616B
2 changed files with 64 additions and 1 deletions

View File

@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Deployment and management system for Lua modules"
TERMUX_PKG_LICENSE="BSD"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=3.1.3
TERMUX_PKG_REVISION=5
TERMUX_PKG_REVISION=6
TERMUX_PKG_SRCURL=https://luarocks.org/releases/luarocks-${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=c573435f495aac159e34eaa0a3847172a2298eb6295fcdc35d565f9f9b990513
TERMUX_PKG_DEPENDS="curl, lua53"

View File

@ -0,0 +1,63 @@
--- ./src/luarocks/core/sysdetect.lua~ 2019-06-06 21:46:21.000000000 +0200
+++ ./src/luarocks/core/sysdetect.lua 2022-01-30 15:04:29.507292068 +0100
@@ -139,59 +139,7 @@
local system = e_osabi[hdr.osabi]
local endian = hdr.endian
- if system == "sysv" then
- local abitag = sections[".note.ABI-tag"]
- if abitag then
- if abitag.namedata == "GNU" and abitag.type == 1
- and abitag.descdata:sub(0, 4) == "\0\0\0\0" then
- return "linux"
- end
- elseif sections[".SUNW_version"]
- or sections[".SUNW_signature"] then
- return "solaris"
- elseif sections[".note.netbsd.ident"] then
- return "netbsd"
- elseif sections[".note.openbsd.ident"] then
- return "openbsd"
- end
-
- local gnu_version_r = sections[".gnu.version_r"]
- if gnu_version_r then
-
- local dynstr = sections[".dynstr"].sh_offset
-
- local idx = 0
- for _ = 0, gnu_version_r.sh_info - 1 do
- fd:seek("set", gnu_version_r.sh_offset + idx)
- assert(read(fd, 2, endian)) -- vn_version
- local vn_cnt = read(fd, 2, endian)
- local vn_file = read(fd, 4, endian)
- local vn_next = read(fd, 2, endian)
-
- fd:seek("set", dynstr + vn_file)
- local libname = fd:read(64):gsub("%z.*", "")
-
- if hdr.e_type == 0x03 and libname == "libroot.so" then
- return "haiku"
- elseif libname:match("linux") then
- return "linux"
- end
-
- idx = idx + (vn_next * (vn_cnt + 1))
- end
- end
-
- local procfile = io.open("/proc/sys/kernel/ostype")
- if procfile then
- local version = procfile:read(6)
- procfile:close()
- if version == "Linux\n" then
- return "linux"
- end
- end
- end
-
- return system
+ return "linux"
end
local function read_elf_header(fd)