diff options
| author | ruki <[email protected]> | 2024-07-16 22:46:29 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-07-16 22:46:29 +0800 |
| commit | 47b8220c696df2fe33e8e24590d871feedfabf2a (patch) | |
| tree | e239c3f6afc2c9c5ccc3a93a985a42f851da83bc | |
| parent | 79fffb69b3bff30eacc42e0547c53041b207c75d (diff) | |
fix install/uninstall with admin
| -rw-r--r-- | tests/actions/install/xmake.lua | 6 | ||||
| -rw-r--r-- | xmake/actions/install/install_admin.lua | 21 | ||||
| -rw-r--r-- | xmake/actions/install/main.lua | 5 | ||||
| -rw-r--r-- | xmake/actions/uninstall/main.lua | 5 | ||||
| -rw-r--r-- | xmake/actions/uninstall/uninstall_admin.lua | 18 |
5 files changed, 20 insertions, 35 deletions
diff --git a/tests/actions/install/xmake.lua b/tests/actions/install/xmake.lua index b774e9e27..8dc12f176 100644 --- a/tests/actions/install/xmake.lua +++ b/tests/actions/install/xmake.lua @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release") -set_version("1.0.1", {soname = true}) +--set_version("1.0.1", {soname = true}) add_requires("libplist", {system = false, configs = {shared = true}}) @@ -10,13 +10,13 @@ target("foo") add_packages("libplist", {public = true}) add_headerfiles("src/foo.h", {public = true}) add_installfiles("src/foo.txt", {prefixdir = "assets", public = true}) - set_prefixdir("/", {bindir = "foo_bin", libdir = "foo_lib"}) +-- set_prefixdir("/", {bindir = "foo_bin", libdir = "foo_lib"}) target("app") set_kind("binary") add_deps("foo") add_files("src/main.cpp") - set_prefixdir("app") +-- set_prefixdir("app") includes("@builtin/xpack") diff --git a/xmake/actions/install/install_admin.lua b/xmake/actions/install/install_admin.lua index ba5101324..93fbf5beb 100644 --- a/xmake/actions/install/install_admin.lua +++ b/xmake/actions/install/install_admin.lua @@ -25,39 +25,30 @@ import("core.project.project") import("core.platform.platform") import("install") --- install function main(targetname, group_pattern, installdir, prefix) - local verbose = option.get("verbose") + if group_pattern and #group_pattern == 0 then + group_pattern = nil + end + if installdir and #installdir == 0 then + installdir = nil + end - -- enter project directory os.cd(project.directory()) - - -- load config config.load() - - -- load platform platform.load(config.plat()) -- save the current option and push a new option context option.save() - - -- preserve verbose option option.set("verbose", verbose) - - -- pass installdir to option if installdir then option.set("installdir", installdir) end - - -- pass prefix to option if prefix then option.set("prefix", prefix) end -- install target install(targetname, group_pattern) - - -- restore the previous option context option.restore() end diff --git a/xmake/actions/install/main.lua b/xmake/actions/install/main.lua index 1d9f8b1c1..24081f874 100644 --- a/xmake/actions/install/main.lua +++ b/xmake/actions/install/main.lua @@ -116,7 +116,10 @@ function main() if sudo.has() and option.get("admin") then -- install target with administrator permission - sudo.execl(path.join(os.scriptdir(), "install_admin.lua"), {targetname or (option.get("all") and "__all" or "__def"), group_pattern, option.get("installdir"), option.get("prefix")}) + sudo.execl(path.join(os.scriptdir(), "install_admin.lua"), { + targetname or (option.get("all") and "__all" or "__def"), + group_pattern or "", option.get("installdir") or "", + option.get("prefix")}) cprint("${color.success}install ok!") ok = true end diff --git a/xmake/actions/uninstall/main.lua b/xmake/actions/uninstall/main.lua index 5c403b85e..f2ae59eb9 100644 --- a/xmake/actions/uninstall/main.lua +++ b/xmake/actions/uninstall/main.lua @@ -68,7 +68,10 @@ function main() if sudo.has() and option.get("admin") then -- uninstall target with administrator permission - sudo.execl(path.join(os.scriptdir(), "uninstall_admin.lua"), {targetname or "__all", option.get("installdir"), option.get("prefix")}) + sudo.execl(path.join(os.scriptdir(), "uninstall_admin.lua"), { + targetname or "__all", + option.get("installdir") or "", + option.get("prefix")}) -- trace cprint("${color.success}uninstall ok!") diff --git a/xmake/actions/uninstall/uninstall_admin.lua b/xmake/actions/uninstall/uninstall_admin.lua index f597dea11..68b496d87 100644 --- a/xmake/actions/uninstall/uninstall_admin.lua +++ b/xmake/actions/uninstall/uninstall_admin.lua @@ -25,39 +25,27 @@ import("core.project.project") import("core.platform.platform") import("uninstall") --- uninstall function main(targetname, installdir, prefix) - local verbose = option.get("verbose") + if installdir and #installdir == 0 then + installdir = nil + end - -- enter project directory os.cd(project.directory()) - - -- load config config.load() - - -- load platform platform.load(config.plat()) -- save the current option and push a new option context option.save() - - -- preserve verbose option option.set("verbose", verbose) - - -- pass installdir to option if installdir then option.set("installdir", installdir) end - - -- pass prefix to option if prefix then option.set("prefix", prefix) end -- uninstall target uninstall(targetname ~= "__all" and targetname or nil) - - -- restore the previous option context option.restore() end |
