summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-01-07 00:07:14 +0800
committerruki <[email protected]>2023-01-06 18:45:02 +0800
commitcd41fd1b0a40da26d14ea9d3512436b7571f07dc (patch)
treedc1c4a7a925253ba4746cc9611265e831b75c2bc
parent41a79045a74bccf4804a8ba11ef841ac18e403ab (diff)
fix xmake install
-rw-r--r--core/src/xmake/os/syserror.c1
-rw-r--r--xmake/actions/install/main.lua7
-rw-r--r--xmake/actions/uninstall/main.lua7
-rw-r--r--xmake/core/base/os.lua1
-rw-r--r--xmake/core/sandbox/modules/os.lua1
5 files changed, 13 insertions, 4 deletions
diff --git a/core/src/xmake/os/syserror.c b/core/src/xmake/os/syserror.c
index c93a4eeda..1ab6afb23 100644
--- a/core/src/xmake/os/syserror.c
+++ b/core/src/xmake/os/syserror.c
@@ -45,6 +45,7 @@ tb_int_t xm_os_syserror(lua_State* lua)
{
case TB_STATE_SYSERROR_NOT_PERM: err = 1; break;
case TB_STATE_SYSERROR_NOT_FILEDIR: err = 2; break;
+ case TB_STATE_SYSERROR_NOT_ACCESS: err = 3; break;
case TB_STATE_SYSERROR_UNKNOWN_ERROR: err = -1; break;
}
lua_pushinteger(lua, err);
diff --git a/xmake/actions/install/main.lua b/xmake/actions/install/main.lua
index 4f59c2b79..5d15a4c40 100644
--- a/xmake/actions/install/main.lua
+++ b/xmake/actions/install/main.lua
@@ -118,8 +118,11 @@ function main()
cprint("${color.success}install ok!")
ok = true
end
- if not ok and os.syserror() == os.SYSERR_NOT_PERM then
- wprint("please pass the --admin parameter to `xmake install` to request administrator permissions!")
+ if not ok then
+ local syserror = os.syserror()
+ if syserror == os.SYSERR_NOT_PERM or syserror == os.SYSERR_NOT_ACCESS then
+ wprint("please pass the --admin parameter to `xmake install` to request administrator permissions!")
+ end
end
assert(ok, "install failed, %s", errors or "unknown reason")
end
diff --git a/xmake/actions/uninstall/main.lua b/xmake/actions/uninstall/main.lua
index 67bb36a83..3132a3456 100644
--- a/xmake/actions/uninstall/main.lua
+++ b/xmake/actions/uninstall/main.lua
@@ -75,8 +75,11 @@ function main()
cprint("${color.success}uninstall ok!")
ok = true
end
- if not ok and os.syserror() == os.SYSERR_NOT_PERM then
- wprint("please pass the --admin parameter to `xmake uninstall` to request administrator permissions!")
+ if not ok then
+ local syserror = os.syserror()
+ if syserror == os.SYSERR_NOT_PERM or syserror == os.SYSERR_NOT_ACCESS then
+ wprint("please pass the --admin parameter to `xmake uninstall` to request administrator permissions!")
+ end
end
assert(ok, "uninstall failed, %s", errors or "unknown reason")
end
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index b28381ccd..dcd7cca8b 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -50,6 +50,7 @@ os.SYSERR_UNKNOWN = -1
os.SYSERR_NONE = 0
os.SYSERR_NOT_PERM = 1
os.SYSERR_NOT_FILEDIR = 2
+os.SYSERR_NOT_ACCESS = 3
-- copy single file or directory
function os._cp(src, dst, rootdir, opt)
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index 28eba4471..ac860eac8 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -83,6 +83,7 @@ sandbox_os.SYSERR_UNKNOWN = os.SYSERR_UNKNOWN
sandbox_os.SYSERR_NONE = os.SYSERR_NONE
sandbox_os.SYSERR_NOT_PERM = os.SYSERR_NOT_PERM
sandbox_os.SYSERR_NOT_FILEDIR = os.SYSERR_NOT_FILEDIR
+sandbox_os.SYSERR_NOT_ACCESS = os.SYSERR_NOT_ACCESS
-- copy file or directory
function sandbox_os.cp(srcpath, dstpath, opt)