diff options
| author | ruki <[email protected]> | 2020-09-15 22:56:11 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-09-15 22:56:11 +0800 |
| commit | edb94735dc313f04af34bf1fe4c866e41de355de (patch) | |
| tree | 11608b3388175b3a2ccae2221fa6512ae64d319c | |
| parent | 6860d9c30b71ff3492c33f889e159ebabda81c29 (diff) | |
improve install and uninstall
| -rw-r--r-- | xmake/actions/install/main.lua | 17 | ||||
| -rw-r--r-- | xmake/actions/install/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/actions/uninstall/main.lua | 17 | ||||
| -rw-r--r-- | xmake/actions/uninstall/xmake.lua | 1 |
4 files changed, 14 insertions, 22 deletions
diff --git a/xmake/actions/install/main.lua b/xmake/actions/install/main.lua index 48f92c70f..3a9abb1c7 100644 --- a/xmake/actions/install/main.lua +++ b/xmake/actions/install/main.lua @@ -116,19 +116,14 @@ function main() -- continue to install with administrator permission? local ok = false - if sudo.has() then + if sudo.has() and option.get("admin") then - -- confirm to install? - local confirm = utils.confirm({default = true, description = "try continue to install with administrator permission again"}) - if confirm then + -- install target with administrator permission + sudo.runl(path.join(os.scriptdir(), "install_admin.lua"), {targetname or ifelse(option.get("all"), "__all", "__def"), option.get("installdir"), option.get("prefix")}) - -- install target with administrator permission - sudo.runl(path.join(os.scriptdir(), "install_admin.lua"), {targetname or ifelse(option.get("all"), "__all", "__def"), option.get("installdir"), option.get("prefix")}) - - -- trace - cprint("${color.success}install ok!") - ok = true - end + -- trace + cprint("${color.success}install ok!") + ok = true end assert(ok, "install failed, %s", errors or "unknown reason") end diff --git a/xmake/actions/install/xmake.lua b/xmake/actions/install/xmake.lua index 3b859238a..e592d54b9 100644 --- a/xmake/actions/install/xmake.lua +++ b/xmake/actions/install/xmake.lua @@ -47,6 +47,7 @@ task("install") "or $ DESTDIR=/usr/local xmake install", "or $ INSTALLDIR=/usr/local xmake install" } , {'a', "all", "k", nil , "Install all targets." } + , {nil, "admin", "k", nil , "Try to request administrator permission to install"} , { } , {nil, "target", "v", nil , "The target name. It will install all default targets if this parameter is not specified." diff --git a/xmake/actions/uninstall/main.lua b/xmake/actions/uninstall/main.lua index 7b656e3ac..87bc6cd29 100644 --- a/xmake/actions/uninstall/main.lua +++ b/xmake/actions/uninstall/main.lua @@ -78,19 +78,14 @@ function main() -- continue to uninstall with administrator permission? local ok = false - if sudo.has() then + if sudo.has() and option.get("admin") then - -- confirm to uninstall? - local confirm = utils.confirm({default = true, description = "try continue to uninstall with administrator permission again"}) - if confirm then + -- uninstall target with administrator permission + sudo.runl(path.join(os.scriptdir(), "uninstall_admin.lua"), {targetname or "__all", option.get("installdir"), option.get("prefix")}) - -- uninstall target with administrator permission - sudo.runl(path.join(os.scriptdir(), "uninstall_admin.lua"), {targetname or "__all", option.get("installdir"), option.get("prefix")}) - - -- trace - cprint("${color.success}uninstall ok!") - ok = true - end + -- trace + cprint("${color.success}uninstall ok!") + ok = true end assert(ok, "uninstall failed, %s", errors or "unknown reason") end diff --git a/xmake/actions/uninstall/xmake.lua b/xmake/actions/uninstall/xmake.lua index 882499668..e623a2abc 100644 --- a/xmake/actions/uninstall/xmake.lua +++ b/xmake/actions/uninstall/xmake.lua @@ -50,6 +50,7 @@ task("uninstall") "e.g.", " $ xmake uninstall --prefix=local", "or $ PREFIX=local xmake uninstall" } + , {nil, "admin", "k", nil , "Try to request administrator permission to uninstall"} , { } , {nil, "target", "v", nil , "The target name. It will uninstall all default targets if this parameter is not specified." , values = function (complete, opt) return import("private.utils.complete_helper.targets")(complete, opt) end } |
