summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-01-13 00:58:08 +0800
committerruki <[email protected]>2024-01-13 00:58:08 +0800
commit3c0b7f5a58dc48949793e78eee107c6c83f3b819 (patch)
treeda1e8cd2cda3cacd6e59d368a4d7607caf2cecd9
parent148b2358773a35d7b7ace9362eb6d4204596234f (diff)
improve versions
-rw-r--r--xmake/core/package/package.lua33
1 files changed, 30 insertions, 3 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 4190c43c1..e4114c089 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -307,7 +307,7 @@ end
-- set artifacts info
function _instance:artifacts_set(artifacts_info)
- local versions = self:get("versions")
+ local versions = self:_versions_list()
if versions then
-- backup previous package configuration
self._ARTIFACTS_BACKUP = {
@@ -467,7 +467,7 @@ end
-- get hash of the source package for the url_alias@version_str
function _instance:sourcehash(url_alias)
- local versions = self:get("versions")
+ local versions = self:_versions_list()
local version_str = self:version_str()
if versions and version_str then
local sourcehash = nil
@@ -1250,11 +1250,38 @@ function _instance:originfile_set(filepath)
self._ORIGINFILE = filepath
end
+-- get versions list
+function _instance:_versions_list()
+ if self._VERSIONS_LIST == nil then
+ local versions = self:get("versions")
+ if type(versions) == "string" then
+ local versionfile = versions
+ if not os.isfile(versionfile) then
+ versionfile = path.join(self:scriptdir(), versions)
+ end
+ versions = {}
+ if os.isfile(versionfile) then
+ local list = io.readfile(versionfile)
+ for _, line in ipairs(list:split("\n")) do
+ local splitinfo = line:split("%s+")
+ if #splitinfo == 2 then
+ local version = splitinfo[1]
+ local shasum = splitinfo[2]
+ versions[version] = shasum
+ end
+ end
+ end
+ end
+ self._VERSIONS_LIST = table.wrap(versions)
+ end
+ return self._VERSIONS_LIST
+end
+
-- get versions
function _instance:versions()
if self._VERSIONS == nil then
local versions = {}
- for version, _ in pairs(table.wrap(self:get("versions"))) do
+ for version, _ in pairs(self:_versions_list()) do
-- remove the url alias prefix if exists
local pos = version:find(':', 1, true)
if pos then