summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2021-08-27 00:34:13 +0800
committerruki <[email protected]>2021-08-27 00:34:13 +0800
commit3bcc30765c2a337016ae8a992ce2d5a65ecd2d0a (patch)
tree92995b8abc3cbb2086aa9bf9397b4d72e483fa67 /xmake/modules
parentf31f70694d9cb10d002a7af0806d2a0809c64866 (diff)
improve download url
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/private/action/require/impl/actions/download.lua12
-rw-r--r--xmake/modules/private/action/require/impl/actions/download_resources.lua6
-rw-r--r--xmake/modules/private/action/require/impl/actions/patch_sources.lua3
3 files changed, 15 insertions, 6 deletions
diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua
index bee421052..e4cf8f0cc 100644
--- a/xmake/modules/private/action/require/impl/actions/download.lua
+++ b/xmake/modules/private/action/require/impl/actions/download.lua
@@ -66,17 +66,18 @@ function _checkout(package, url, sourcedir, url_alias)
local longpaths = package:policy("platform.longpaths")
-- download package from branches?
+ url = proxy.mirror(url) or url
packagedir = path.join(sourcedir .. ".tmp", package:name())
if package:branch() then
-- only shadow clone this branch
- git.clone(proxy.mirror(url) or url, {depth = 1, recursive = true, longpaths = longpaths, branch = package:branch(), outputdir = packagedir})
+ git.clone(url, {depth = 1, recursive = true, longpaths = longpaths, branch = package:branch(), outputdir = packagedir})
-- download package from revision or tag?
else
-- clone whole history and tags
- git.clone(proxy.mirror(url) or url, {longpaths = longpaths, outputdir = packagedir})
+ git.clone(url, {longpaths = longpaths, outputdir = packagedir})
-- attempt to checkout the given version
local revision = package:revision(url_alias) or package:tag() or package:version_str()
@@ -103,6 +104,11 @@ function _download(package, url, sourcedir, url_alias, url_excludes)
-- get package file
local packagefile = url_filename(url)
+ -- use proxy url?
+ if not os.isfile(url) then
+ url = proxy.mirror(url) or url
+ end
+
-- get sourcehash from the given url
--
-- we need not sourcehash and skip checksum to try download it directly if no version list in package()
@@ -139,7 +145,7 @@ function _download(package, url, sourcedir, url_alias, url_excludes)
-- we can use local package from the search directories directly if network is too slow
os.cp(localfile, packagefile)
else
- http.download(proxy.mirror(url) or url, packagefile)
+ http.download(url, packagefile)
end
end
diff --git a/xmake/modules/private/action/require/impl/actions/download_resources.lua b/xmake/modules/private/action/require/impl/actions/download_resources.lua
index fa115c04a..c6af29151 100644
--- a/xmake/modules/private/action/require/impl/actions/download_resources.lua
+++ b/xmake/modules/private/action/require/impl/actions/download_resources.lua
@@ -32,6 +32,7 @@ import("utils.archive")
function _checkout(package, resource_name, resource_url, resource_revision)
-- trace
+ resource_url = proxy.mirror(resource_url) or resource_url
vprint("cloning resource(%s: %s) to %s-%s ..", resource_name, resource_revision, package:name(), package:version_str())
-- get the resource directory
@@ -62,7 +63,7 @@ function _checkout(package, resource_name, resource_url, resource_revision)
local longpaths = package:policy("platform.longpaths")
-- clone whole history and tags
- git.clone(proxy.mirror(resource_url) or resource_url, {longpaths = longpaths, outputdir = resourcedir})
+ git.clone(resource_url, {longpaths = longpaths, outputdir = resourcedir})
-- attempt to checkout the given version
git.checkout(resource_revision, {repodir = resourcedir})
@@ -77,6 +78,7 @@ end
function _download(package, resource_name, resource_url, resource_hash)
-- trace
+ resource_url = proxy.mirror(resource_url) or resource_url
vprint("downloading resource(%s: %s) to %s-%s ..", resource_name, resource_url, package:name(), package:version_str())
-- get the resource file
@@ -103,7 +105,7 @@ function _download(package, resource_name, resource_url, resource_hash)
-- we can use local resource from the search directories directly if network is too slow
os.cp(localfile, resource_file)
elseif resource_url:find(string.ipattern("https-://")) or resource_url:find(string.ipattern("ftps-://")) then
- http.download(proxy.mirror(resource_url) or resource_url, resource_file)
+ http.download(resource_url, resource_file)
else
raise("invalid resource url(%s)", resource_url)
end
diff --git a/xmake/modules/private/action/require/impl/actions/patch_sources.lua b/xmake/modules/private/action/require/impl/actions/patch_sources.lua
index 23d46f3d3..d5874f8f5 100644
--- a/xmake/modules/private/action/require/impl/actions/patch_sources.lua
+++ b/xmake/modules/private/action/require/impl/actions/patch_sources.lua
@@ -50,6 +50,7 @@ end
function _patch(package, patch_url, patch_hash)
-- trace
+ patch_url = proxy.mirror(patch_url) or patch_url
vprint("patching %s to %s-%s ..", patch_url, package:name(), package:version_str())
-- get the patch file
@@ -72,7 +73,7 @@ function _patch(package, patch_url, patch_hash)
-- download the patch file
if patch_url:find(string.ipattern("https-://")) or patch_url:find(string.ipattern("ftps-://")) then
- http.download(proxy.mirror(patch_url) or patch_url, patch_file)
+ http.download(patch_url, patch_file)
else
-- copy the patch file
if os.isfile(patch_url) then