summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-03-30 20:43:35 +0800
committerruki <[email protected]>2017-03-30 20:43:35 +0800
commit8cece0ebb4012780f8c290f38e7bb022e59b6782 (patch)
tree0be764a61a8fe99eabd1507fdcea09c813fb8a2b
parentdd3e97f4c1d1ede059b3cc6f52808409b4462c36 (diff)
fix root bug for installation
-rw-r--r--xmake/core/base/option.lua1
-rw-r--r--xmake/core/main.lua16
-rw-r--r--xmake/core/sandbox/modules/os.lua2
-rw-r--r--xmake/plugins/lua/xmake.lua1
4 files changed, 11 insertions, 9 deletions
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua
index 0bcd6f4b4..718cc68b8 100644
--- a/xmake/core/base/option.lua
+++ b/xmake/core/base/option.lua
@@ -487,7 +487,6 @@ function option.find(argv, name, shortname)
-- get value
nextvalue = true
end
-
end
end
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index b00f2ea60..f37e3940a 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -122,13 +122,6 @@ function main.done()
-- init
main._init()
- -- check run command as root
- local ok, errors = main._check_root()
- if not ok then
- utils.error(errors)
- return -1
- end
-
-- init option
local ok, errors = option.init(menu)
if not ok then
@@ -136,6 +129,15 @@ function main.done()
return -1
end
+ -- check run command as root
+ if not option.get("root") then
+ local ok, errors = main._check_root()
+ if not ok then
+ utils.error(errors)
+ return -1
+ end
+ end
+
-- start profiling
if option.get("profile") then
profiler:start()
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index 94b78c6b8..55950f7de 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -503,7 +503,7 @@ end
function sandbox_os.sudol(runner, luafile, luaargv)
-- init argv
- local argv = {"lua"}
+ local argv = {"lua", "--root"}
for _, name in ipairs({"file", "project", "backtrace", "verbose", "quiet"}) do
local value = option.get(name)
if type(value) == "string" then
diff --git a/xmake/plugins/lua/xmake.lua b/xmake/plugins/lua/xmake.lua
index abc723b3b..917d66119 100644
--- a/xmake/plugins/lua/xmake.lua
+++ b/xmake/plugins/lua/xmake.lua
@@ -73,6 +73,7 @@ task("lua")
, options =
{
{'l', "list", "k", nil, "List all scripts." }
+ , {nil, "root", "k", nil, "Allow to run script as root." }
, {nil, "script", "v", nil, "Run the given lua script." }
, {nil, "arguments", "vs", nil, "The script arguments." }
}