diff options
| author | ruki <[email protected]> | 2017-05-24 21:03:43 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-05-24 21:03:43 +0800 |
| commit | 2d075777fd3ab515f508eedf08dd596ac9fdda93 (patch) | |
| tree | 42202806994a86226553816f56b2fc2e4f4d5c13 | |
| parent | 7ef69739513b4b4431f6f683fe2a9d297658be02 (diff) | |
improve sudo and build test script
| -rw-r--r-- | tests/build.lua | 15 | ||||
| -rw-r--r-- | xmake/modules/detect/tool/find_sudo.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/privilege/sudo.lua | 6 |
3 files changed, 19 insertions, 6 deletions
diff --git a/tests/build.lua b/tests/build.lua index 918b00133..e72744b60 100644 --- a/tests/build.lua +++ b/tests/build.lua @@ -1,3 +1,6 @@ +-- imports +import("privilege.sudo") + -- main entry function main(argv) @@ -5,6 +8,10 @@ function main(argv) os.exec("xmake m -b") os.exec("xmake f -c") os.exec("xmake") + if os.host() ~= "windows" then + os.exec("xmake install -o /tmp -a --verbose --backtrace") + os.exec("xmake uninstall --installdir=/tmp --verbose --backtrace") + end os.exec("xmake p") os.exec("xmake c") os.exec("xmake f -m release") @@ -17,8 +24,16 @@ function main(argv) os.exec("xmake m -l") os.exec("xmake f --cc=gcc --cxx=g++") os.exec("xmake m buildtest") + if os.host() ~= "windows" then + sudo.exec("xmake install") + sudo.exec("xmake uninstall") + end os.exec("xmake f --cc=clang --cxx=clang++ --ld=clang++ --verbose --backtrace") os.exec("xmake m buildtest") + if os.host() ~= "windows" then + sudo.exec("xmake install --all -v --backtrace") + sudo.exec("xmake uninstall -v --backtrace") + end os.exec("xmake m -d buildtest") -- test iphoneos? diff --git a/xmake/modules/detect/tool/find_sudo.lua b/xmake/modules/detect/tool/find_sudo.lua index 32bd86456..968746020 100644 --- a/xmake/modules/detect/tool/find_sudo.lua +++ b/xmake/modules/detect/tool/find_sudo.lua @@ -42,12 +42,12 @@ import("lib.detect.find_programver") function main(opt) -- find program - local program = find_program("sudo", { "/usr/bin", "/usr/local/bin"}) + local program = find_program("sudo", { "/usr/bin", "/usr/local/bin"}, "-h") -- find program version local version = nil if program and opt and opt.version then - version = find_programver(program) + version = find_programver(program, "-V") end -- ok? diff --git a/xmake/modules/privilege/sudo.lua b/xmake/modules/privilege/sudo.lua index aba3a0362..ae35ee23a 100644 --- a/xmake/modules/privilege/sudo.lua +++ b/xmake/modules/privilege/sudo.lua @@ -37,10 +37,8 @@ function _sudo(runner, cmd, ...) local program = find_sudo() assert(program, "sudo not found!") - -- TODO handle -E on ubuntu - -- run it with administrator permission and preserve parent environment - runner(program .. " -E " .. cmd, ...) + runner(program .. " PATH=" .. os.getenv("PATH") .. " " .. cmd, ...) end -- sudo run shell with administrator permission and arguments list @@ -55,7 +53,7 @@ function _sudov(runner, shellname, argv) assert(program, "sudo not found!") -- run it with administrator permission and preserve parent environment - runner(program, table.join("-E", shellname, argv)) + runner(program, table.join("PATH=" .. os.getenv("PATH"), shellname, argv)) end -- sudo run lua script with administrator permission and arguments list |
