summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-02-03 22:35:08 +0800
committerruki <[email protected]>2021-02-03 22:35:08 +0800
commit659b1d101aa05cff29f36b01d5d9f192edb30997 (patch)
treeaf6ce333d0596db5bc34174cfa79ea7a08e4a83b
parent70bc1847d47935ea48b68afc64ce13a337911409 (diff)
improve to download package
-rw-r--r--xmake/actions/require/impl/actions/download.lua9
-rw-r--r--xmake/actions/require/impl/utils/url_filename.lua25
-rw-r--r--xmake/actions/require/info.lua7
3 files changed, 30 insertions, 11 deletions
diff --git a/xmake/actions/require/impl/actions/download.lua b/xmake/actions/require/impl/actions/download.lua
index 8c645eb80..af1c96b75 100644
--- a/xmake/actions/require/impl/actions/download.lua
+++ b/xmake/actions/require/impl/actions/download.lua
@@ -27,6 +27,7 @@ import("core.package.package", {alias = "core_package"})
import("lib.detect.find_file")
import("lib.detect.find_directory")
import(".utils.filter")
+import(".utils.url_filename")
import("net.http")
import("devel.git")
import("utils.archive")
@@ -88,7 +89,7 @@ end
function _download(package, url, sourcedir, url_alias, url_excludes)
-- get package file
- local packagefile = package:name() .. "-" .. package:version_str() .. archive.extension(url)
+ local packagefile = url_filename(url)
-- get sourcehash from the given url
--
@@ -240,11 +241,7 @@ function main(package)
local searchnames = hashset.new()
for _, url_failed in ipairs(urls_failed) do
cprint(" ${yellow}- %s", url_failed)
- if git.checkurl(url_failed) then
- searchnames:insert(package:name() .. archive.extension(url_failed))
- else
- searchnames:insert(package:name() .. "-" .. package:version_str() .. archive.extension(url_failed))
- end
+ searchnames:insert(url_filename(url_failed))
end
cprint("to the local search directories: ${bright}%s", table.concat(table.wrap(core_package.searchdirs()), path.envsep()))
cprint(" ${bright}- %s", table.concat(searchnames:to_array(), ", "))
diff --git a/xmake/actions/require/impl/utils/url_filename.lua b/xmake/actions/require/impl/utils/url_filename.lua
new file mode 100644
index 000000000..e17e8673b
--- /dev/null
+++ b/xmake/actions/require/impl/utils/url_filename.lua
@@ -0,0 +1,25 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file url_filename.lua
+--
+
+-- get filename from url
+function main(url)
+ local urlpath = url:split('?', {plain = true})[1]
+ return path.filename(urlpath)
+end
diff --git a/xmake/actions/require/info.lua b/xmake/actions/require/info.lua
index 080436fe2..c35dc283f 100644
--- a/xmake/actions/require/info.lua
+++ b/xmake/actions/require/info.lua
@@ -27,6 +27,7 @@ import("core.package.package", {alias = "core_package"})
import("devel.git")
import("utils.archive")
import("impl.utils.filter")
+import("impl.utils.url_filename")
import("impl.package")
import("impl.repository")
import("impl.environment")
@@ -152,11 +153,7 @@ function main(requires_raw)
cprint(" -> ${magenta}searchdirs${clear}: %s", table.concat(table.wrap(core_package.searchdirs()), path.envsep()))
local searchnames = hashset.new()
for _, url in ipairs(instance:urls()) do
- if git.checkurl(url) then
- searchnames:insert(instance:name() .. archive.extension(url))
- else
- searchnames:insert(instance:name() .. "-" .. instance:version_str() .. archive.extension(url))
- end
+ searchnames:insert(url_filename(url))
end
cprint(" -> ${magenta}searchnames${clear}: %s", table.concat(searchnames:to_array(), ", "))