summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpportunity <[email protected]>2020-01-20 21:41:33 +0800
committerOpportunity <[email protected]>2020-01-20 22:21:47 +0800
commitd3e45885b8fa8e905e061b9c14f0cc34ba35b5f5 (patch)
tree044d27317a0f58a638e1b419b128ef8a1ae52110
parentcf67eeccd04f356f2fab9855d4c6eae97e22f1c2 (diff)
fix
-rw-r--r--xmake/actions/update/main.lua32
-rw-r--r--xmake/actions/update/xmake.lua5
2 files changed, 32 insertions, 5 deletions
diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua
index 86aca400f..63e650abd 100644
--- a/xmake/actions/update/main.lua
+++ b/xmake/actions/update/main.lua
@@ -250,7 +250,29 @@ end
function _check_repo(sourcedir)
-- this file will exists for long time
- return os.isfile(path.join(sourcedir, "xmake/core/_xmake_main.lua"))
+ if not os.isfile(path.join(sourcedir, "xmake/core/_xmake_main.lua")) then
+ raise("invalid xmake repo, please check your input!")
+ end
+end
+
+function _check_win_installer(sourcedir)
+ local file = path.join(sourcedir, win_installer_name)
+ if not os.isfile(file) then
+ raise("installer not found at " .. sourcedir)
+ end
+
+ local fp = io.open(file, "rb")
+ local header = fp:read(math.min(1000, fp:size()))
+ fp:close()
+ if header:startswith("MZ") then
+ return
+ end
+ if header:find('\0', 1, true) or not option.get("verbose") then
+ raise("installer is broken")
+ else
+ -- may be a text file, print content for debug
+ raise("installer is broken: " .. header)
+ end
end
-- main
@@ -314,7 +336,7 @@ function main()
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 install_from_git = not is_official or git.checkurl(mainurls[1])
local download_task = function ()
for idx, url in ipairs(mainurls) do
@@ -361,9 +383,9 @@ function main()
environment.leave()
if install_from_git then
- if not _check_repo(sourcedir) then
- raise("invalid xmake repo, please check your input!")
- end
+ _check_repo(sourcedir)
+ else
+ _check_win_installer(sourcedir)
end
-- do install
diff --git a/xmake/actions/update/xmake.lua b/xmake/actions/update/xmake.lua
index 0995abf2c..c4b281638 100644
--- a/xmake/actions/update/xmake.lua
+++ b/xmake/actions/update/xmake.lua
@@ -68,6 +68,11 @@ task("update")
local versions = fetch_version(seg[1])
if versions.is_official then
+ for i,v in ipairs(versions.tags) do
+ if v:startswith("v") and #v > 5 then
+ versions.tags[i] = v:sub(2)
+ end
+ end
return table.join(versions.branches, table.reverse(versions.tags))
else
local values = table.join(versions.branches, table.reverse(versions.tags))