summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpportunity <[email protected]>2020-01-20 21:14:26 +0800
committerOpportunity <[email protected]>2020-01-20 22:21:47 +0800
commitcf67eeccd04f356f2fab9855d4c6eae97e22f1c2 (patch)
tree6109bcdedbad58bc40106dd8e886aa679cd34109
parent3364333877dc8a579f08b54099fda653948e07ab (diff)
check_repo for update
-rw-r--r--xmake/actions/update/main.lua17
1 files changed, 15 insertions, 2 deletions
diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua
index c8e95f5c3..86aca400f 100644
--- a/xmake/actions/update/main.lua
+++ b/xmake/actions/update/main.lua
@@ -248,6 +248,11 @@ function _install_script(sourcedir)
end
end
+function _check_repo(sourcedir)
+ -- this file will exists for long time
+ return os.isfile(path.join(sourcedir, "xmake/core/_xmake_main.lua"))
+end
+
-- main
function main()
@@ -308,6 +313,9 @@ function main()
local sourcedir = path.join(os.tmpdir(), "xmakesrc", version)
vprint("prepared to download to temp dir %s ..", sourcedir)
+ -- all user provided urls are considered as git url since check has been performed in fetch_version
+ local install_from_git = not is_official or git.checkurl(url)
+
local download_task = function ()
for idx, url in ipairs(mainurls) do
cprintf("\r${yellow} => ${clear}downloading %s .. ", url)
@@ -315,8 +323,7 @@ function main()
{
function ()
os.tryrm(sourcedir)
- -- all user provided urls are considered as git url since check has been performed in fetch_version
- if is_official and not git.checkurl(url) then
+ if not install_from_git then
os.mkdir(sourcedir)
http.download(url, path.join(sourcedir, win_installer_name))
else
@@ -353,6 +360,12 @@ function main()
-- leave environment
environment.leave()
+ if install_from_git then
+ if not _check_repo(sourcedir) then
+ raise("invalid xmake repo, please check your input!")
+ end
+ end
+
-- do install
if script_only then
_install_script(sourcedir)