summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-03-30 20:05:01 +0800
committerruki <[email protected]>2017-03-30 20:05:01 +0800
commit05674b34f0d608482b6539cab4a50de6d6778323 (patch)
treef038d659d75ca3d97226161245786d0207a7a769
parent23c20f5d27b1c912d22df4b6a2e09b2242b7a8e6 (diff)
check root and add make uninstall
-rw-r--r--CHANGELOG.md6
-rw-r--r--Makefile8
-rw-r--r--xmake/core/main.lua22
3 files changed, 33 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aa2262d08..6eb00e58a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,11 +6,12 @@
* [#61](https://github.com/tboox/xmake/pull/61): Provide safer `xmake install` and `xmake uninstall` task with administrator permission
* Provide `rpm`, `deb` and `osxpkg` install package
+* [#63](https://github.com/tboox/xmake/pull/63): More safer build and install xmake
## Bugs fixed
* Fix error tips for checking xmake min version
-* [#60](https://github.com/tboox/xmake/issues/60): Fix self-build for macosx
+* [#60](https://github.com/tboox/xmake/issues/60): Fix self-build for macosx and windows
## v2.1.2
@@ -236,11 +237,12 @@
* [#61](https://github.com/tboox/xmake/pull/61): 提供更加安全的`xmake install` and `xmake uninstall`任务,更友好的处理root安装问题
* 提供`rpm`, `deb`和`osxpkg`安装包
+* [#63](https://github.com/tboox/xmake/pull/63): 改进安装脚本,实现更加安全的构建和安装xmake
### Bugs修复
* 修复版本检测的错误提示信息
-* [#60](https://github.com/tboox/xmake/issues/60): 修复macosx平台的xmake自举编译
+* [#60](https://github.com/tboox/xmake/issues/60): 修复macosx和windows平台的xmake自举编译
## v2.1.2
diff --git a/Makefile b/Makefile
index e642f200c..1d7cf8947 100644
--- a/Makefile
+++ b/Makefile
@@ -76,4 +76,10 @@ install:
@# ok
@echo ok!
-.PHONY: tip build install
+uninstall:
+ @echo uninstalling from $(prefix) ...
+ @rm $(prefix)/bin/xmake
+ @rm -rf $(prefix)/share/xmake
+ @echo ok!
+
+.PHONY: tip build install uninstall
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index 0228e2b38..b00f2ea60 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -101,12 +101,34 @@ function main._init()
assert(projectfile)
end
+-- check run command as root
+function main._check_root()
+
+ -- check it
+ local ok, code = os.iorun("id -u")
+ if ok and code and code:trim() == '0' then
+ return false, [[Running xmake as root is extremely dangerous and no longer supported.
+ As xmake does not drop privileges on installation you would be giving all
+ build scripts full access to your system.]]
+ end
+
+ -- not root
+ return true
+end
+
-- the main function
function main.done()
-- init
main._init()
+ -- check run command as root
+ local ok, errors = main._check_root()
+ if not ok then
+ utils.error(errors)
+ return -1
+ end
+
-- init option
local ok, errors = option.init(menu)
if not ok then