aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Gorrie <luke@snabb.co>2019-03-11 17:03:06 -0700
committerHisham Muhammad <hisham@gobolinux.org>2019-03-12 12:40:03 -0700
commit9d87dafb47f48315547d5e384dd995836cf67995 (patch)
tree6de0d6e6ef5c55c83197ebedcce925435389aa15
parentb096e35e29f5406f74c5cf7bdb86eff8ebf3b526 (diff)
downloadluarocks-9d87dafb47f48315547d5e384dd995836cf67995.tar.gz
luarocks-9d87dafb47f48315547d5e384dd995836cf67995.tar.bz2
luarocks-9d87dafb47f48315547d5e384dd995836cf67995.zip
core.sysdetect: Fallback to /proc to detect Linux
Check if /proc/sys/kernel/ostype reads as "Linux\n" to detect when a "sysv" platform is really Linux. This test is a fallback with lower priority than the existing heuristics based on ELF headers. This fixes a problem with Alpine Linux docker images where LuaRocks does not detect Linux because /bin/sh ELF headers don't contain have the expected clues: $ docker run -ti alpine / # apk add --no-cache build-base [...] / # readelf -h /bin/sh ELF Header: Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: DYN (Shared object file) Machine: Advanced Micro Devices X86-64 Version: 0x1 Entry point address: 0xc410 Start of program headers: 64 (bytes into file) Start of section headers: 803616 (bytes into file) Flags: 0x0 Size of this header: 64 (bytes) Size of program headers: 56 (bytes) Number of program headers: 7 Size of section headers: 64 (bytes) Number of section headers: 22 Section header string table index: 21
-rw-r--r--src/luarocks/core/sysdetect.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/luarocks/core/sysdetect.lua b/src/luarocks/core/sysdetect.lua
index bd5139b7..213d16bf 100644
--- a/src/luarocks/core/sysdetect.lua
+++ b/src/luarocks/core/sysdetect.lua
@@ -180,6 +180,15 @@ local function detect_elf_system(fd, hdr, sections)
180 idx = idx + (vn_next * (vn_cnt + 1)) 180 idx = idx + (vn_next * (vn_cnt + 1))
181 end 181 end
182 end 182 end
183
184 local procfile = io.open("/proc/sys/kernel/ostype")
185 if procfile then
186 local version = procfile:read(6)
187 procfile:close()
188 if version == "Linux\n" then
189 return "linux"
190 end
191 end
183 end 192 end
184 193
185 return system 194 return system