@@ -34,6 +34,17 @@ import("net.proxy")
3434import (" devel.git" )
3535import (" utils.archive" )
3636
37+ -- get url extension
38+ function _url_extension (url )
39+ local extension = archive .extension (url )
40+ if extension == " " then
41+ -- maybe non-archive file, e.g. .exe, .sh, ..
42+ local urlpath = url :split (' ?' , {plain = true })[1 ]
43+ extension = path .extension (urlpath )
44+ end
45+ return extension
46+ end
47+
3748-- checkout codes from git
3849function _checkout (package , url , sourcedir , opt )
3950 opt = opt or {}
@@ -153,7 +164,7 @@ function _download(package, url, sourcedir, opt)
153164 if not packagefile then
154165 packagefile = url_filename (url )
155166 if not os .isfile (packagefile ) then -- we need to be compatible with the old file names
156- packagefile = package :name () .. " -" .. package :version_str () .. archive . extension (packagefile )
167+ packagefile = package :name () .. " -" .. package :version_str () .. _url_extension (packagefile )
157168 end
158169 end
159170
@@ -181,7 +192,7 @@ function _download(package, url, sourcedir, opt)
181192 os .cp (url , packagefile )
182193 else
183194 local localfile
184- local searchnames = {package :name () .. " -" .. package :version_str () .. archive . extension (url ),
195+ local searchnames = {package :name () .. " -" .. package :version_str () .. _url_extension (url ),
185196 packagefile }
186197
187198 -- match github name mangling https://github.com/xmake-io/xmake/issues/1343
@@ -267,6 +278,7 @@ function _download(package, url, sourcedir, opt)
267278 raise (errors or string.format (" cannot extract %s, maybe missing extractor or invalid package file!" , packagefile ))
268279 else
269280 -- if it is not archive file, we only need to create empty source directory and use package:originfile()
281+ -- e.g. .exe, .sh
270282 os .tryrm (sourcedir )
271283 os .mkdir (sourcedir )
272284 end
@@ -424,7 +436,7 @@ function main(package, opt)
424436 searchnames :insert (package :name () .. archive .extension (url_failed ))
425437 searchnames :insert (path .basename (url_filename (url_failed )))
426438 else
427- local extension = archive . extension (url_failed )
439+ local extension = _url_extension (url_failed )
428440 if extension then
429441 searchnames :insert (package :name () .. " -" .. package :version_str () .. extension )
430442 end
0 commit comments