diff options
| author | TitanSnow <[email protected]> | 2017-05-22 20:02:51 +0800 |
|---|---|---|
| committer | TitanSnow <[email protected]> | 2017-05-22 20:02:51 +0800 |
| commit | 5e36555036052217345596a1bab1e859ffaa8db0 (patch) | |
| tree | 2767a8930f7cdf0cf6e5283d9710d1681f1cc38c | |
| parent | bd775f017f77043aac5b6290c9899f7daf23e172 (diff) | |
get privilege while installing
| -rw-r--r-- | xmake/actions/install/main.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/xmake/actions/install/main.lua b/xmake/actions/install/main.lua index 3ca155789..f9bca9419 100644 --- a/xmake/actions/install/main.lua +++ b/xmake/actions/install/main.lua @@ -26,6 +26,7 @@ import("core.base.option") import("core.project.task") import("core.platform.platform") +import("core.base.privilege") import("install") -- main @@ -57,6 +58,28 @@ function main() -- failed or not permission? request administrator permission and install it again function (errors) + -- try get privilege + if privilege.get() then + local ok = try + { + function () + -- install target + install.install(targetname or ifelse(option.get("all"), "__all", "__def")) + + -- trace + cprint("${bright}install ok!${clear}${ok_hand}") + + -- ok + return true + end + } + + -- release privilege + privilege.store() + + if ok then return end + end + -- show tips cprint("${bright red}error: ${default red}installation failed, may permission denied!") |
