From 760ad7c98a4a322b1f028ea9585cd17c5b74b2e2 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 30 Oct 2018 10:04:23 -0300 Subject: core.sysdetect: add fork-free OS detection (#938) Detect operating system and architecture without forking subprocesses, doing `file`-like detection reading data from well-known system executables. --- binary/all_in_one | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'binary') diff --git a/binary/all_in_one b/binary/all_in_one index 01758758..43a18a3b 100755 --- a/binary/all_in_one +++ b/binary/all_in_one @@ -50,6 +50,7 @@ local path = require("luarocks.path") local manif = require("luarocks.manif") local queries = require("luarocks.queries") local persist = require("luarocks.persist") +local sysdetect = require("luarocks.core.sysdetect") -------------------------------------------------------------------------------- @@ -144,16 +145,7 @@ local function write_hardcoded_module(dir) local processor = if_platform("windows", "x86") if if_platform("unix", true) then - system = util.popen_read("uname -s") - processor = util.popen_read("uname -m") - - if processor:match("i[%d]86") then - processor = "x86" - elseif processor:match("amd64") or processor:match("x86_64") then - processor = "x86_64" - elseif processor:match("Power Macintosh") then - processor = "powerpc" - end + system, processor = sysdetect.detect() end local hardcoded = { -- cgit v1.2.3-55-g6feb