get privilege while installing
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!")
