aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-07-13 00:48:48 +0300
committerV1K1NGbg <victor@ilchev.com>2024-08-05 20:49:17 +0300
commit61976586cebcbfbd69db83342bc9f96e9454b08c (patch)
treed3feefffa09f7081d23bf1b56c10225d4e457409
parent390fc098b73a3a0c4a21965afea06e86db970bef (diff)
downloadluarocks-61976586cebcbfbd69db83342bc9f96e9454b08c.tar.gz
luarocks-61976586cebcbfbd69db83342bc9f96e9454b08c.tar.bz2
luarocks-61976586cebcbfbd69db83342bc9f96e9454b08c.zip
possible fix
-rw-r--r--src/luarocks/core/manif-original.lua (renamed from src/luarocks/core/manif-incomplete.lua)93
-rw-r--r--src/luarocks/core/manif.lua93
-rw-r--r--src/luarocks/core/manif.tl8
3 files changed, 97 insertions, 97 deletions
diff --git a/src/luarocks/core/manif-incomplete.lua b/src/luarocks/core/manif-original.lua
index da4aef9f..3925f636 100644
--- a/src/luarocks/core/manif-incomplete.lua
+++ b/src/luarocks/core/manif-original.lua
@@ -1,4 +1,6 @@
1local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local assert = _tl_compat and _tl_compat.assert or assert; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local table = _tl_compat and _tl_compat.table or table 1
2--- Core functions for querying manifest files.
3local manif = {}
2 4
3local persist = require("luarocks.core.persist") 5local persist = require("luarocks.core.persist")
4local cfg = require("luarocks.core.cfg") 6local cfg = require("luarocks.core.cfg")
@@ -6,84 +8,53 @@ local dir = require("luarocks.core.dir")
6local util = require("luarocks.core.util") 8local util = require("luarocks.core.util")
7local vers = require("luarocks.core.vers") 9local vers = require("luarocks.core.vers")
8local path = require("luarocks.core.path") 10local path = require("luarocks.core.path")
11local require = nil
12--------------------------------------------------------------------------------
9 13
10 14-- Table with repository identifiers as keys and tables mapping
11 15-- Lua versions to cached loaded manifests as values.
12
13local manif = {DependencyVersion = {}, Manifest = {}, Tree_manifest = {}, }
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44local manifest_cache = {} 16local manifest_cache = {}
45 17
46 18--- Cache a loaded manifest.
47 19-- @param repo_url string: The repository identifier.
48 20-- @param lua_version string: Lua version in "5.x" format, defaults to installed version.
49 21-- @param manifest table: the manifest to be cached.
50function manif.cache_manifest(repo_url, lua_version, manifest) 22function manif.cache_manifest(repo_url, lua_version, manifest)
51 lua_version = lua_version or cfg.lua_version 23 lua_version = lua_version or cfg.lua_version
52 manifest_cache[repo_url] = manifest_cache[repo_url] or {} 24 manifest_cache[repo_url] = manifest_cache[repo_url] or {}
53 manifest_cache[repo_url][lua_version] = manifest 25 manifest_cache[repo_url][lua_version] = manifest
54end 26end
55 27
56 28--- Attempt to get cached loaded manifest.
57 29-- @param repo_url string: The repository identifier.
58 30-- @param lua_version string: Lua version in "5.x" format, defaults to installed version.
59 31-- @return table or nil: loaded manifest or nil if cache is empty.
60function manif.get_cached_manifest(repo_url, lua_version) 32function manif.get_cached_manifest(repo_url, lua_version)
61 lua_version = lua_version or cfg.lua_version 33 lua_version = lua_version or cfg.lua_version
62 return manifest_cache[repo_url] and manifest_cache[repo_url][lua_version] 34 return manifest_cache[repo_url] and manifest_cache[repo_url][lua_version]
63end 35end
64 36
65 37--- Back-end function that actually loads the manifest
66 38-- and stores it in the manifest cache.
67 39-- @param file string: The local filename of the manifest file.
68 40-- @param repo_url string: The repository identifier.
69 41-- @param lua_version string: Lua version in "5.x" format, defaults to installed version.
70 42-- @return table or (nil, string, string): the manifest or nil,
71 43-- error message and error code ("open", "load", "run").
72function manif.manifest_loader(file, repo_url, lua_version) 44function manif.manifest_loader(file, repo_url, lua_version)
73 local manifest, err, errcode = persist.load_into_table(file) 45 local manifest, err, errcode = persist.load_into_table(file)
74 if not manifest then 46 if not manifest then
75 return nil, "Failed loading manifest for " .. repo_url .. ": " .. tostring(err), errcode 47 return nil, "Failed loading manifest for "..repo_url..": "..err, errcode
76 end 48 end
77
78 manif.cache_manifest(repo_url, lua_version, manifest) 49 manif.cache_manifest(repo_url, lua_version, manifest)
79 return manifest, nil, nil 50 return manifest, err, errcode
80end 51end
81 52
82 53--- Load a local manifest describing a repository.
83 54-- This is used by the luarocks.loader only.
84 55-- @param repo_url string: URL or pathname for the repository.
85 56-- @return table or (nil, string, string): A table representing the manifest,
86 57-- or nil followed by an error message and an error code, see manifest_loader.
87function manif.fast_load_local_manifest(repo_url) 58function manif.fast_load_local_manifest(repo_url)
88 assert(type(repo_url) == "string") 59 assert(type(repo_url) == "string")
89 60
@@ -93,15 +64,15 @@ function manif.fast_load_local_manifest(repo_url)
93 end 64 end
94 65
95 local pathname = dir.path(repo_url, "manifest") 66 local pathname = dir.path(repo_url, "manifest")
96 return manif.manifest_loader(pathname, repo_url, nil) 67 return manif.manifest_loader(pathname, repo_url, nil, true)
97end 68end
98 69
99function manif.load_rocks_tree_manifests(deps_mode) 70function manif.load_rocks_tree_manifests(deps_mode)
100 local trees = {} 71 local trees = {}
101 path.map_trees(deps_mode, function(tree) 72 path.map_trees(deps_mode, function(tree)
102 local manifest = manif.fast_load_local_manifest(path.rocks_dir(tree)) 73 local manifest, err = manif.fast_load_local_manifest(path.rocks_dir(tree))
103 if manifest then 74 if manifest then
104 table.insert(trees, { tree = tree, manifest = manifest }) 75 table.insert(trees, {tree=tree, manifest=manifest})
105 end 76 end
106 end) 77 end)
107 return trees 78 return trees
diff --git a/src/luarocks/core/manif.lua b/src/luarocks/core/manif.lua
index 3925f636..197b4725 100644
--- a/src/luarocks/core/manif.lua
+++ b/src/luarocks/core/manif.lua
@@ -1,6 +1,4 @@
1 1local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local assert = _tl_compat and _tl_compat.assert or assert; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local table = _tl_compat and _tl_compat.table or table
2--- Core functions for querying manifest files.
3local manif = {}
4 2
5local persist = require("luarocks.core.persist") 3local persist = require("luarocks.core.persist")
6local cfg = require("luarocks.core.cfg") 4local cfg = require("luarocks.core.cfg")
@@ -8,53 +6,84 @@ local dir = require("luarocks.core.dir")
8local util = require("luarocks.core.util") 6local util = require("luarocks.core.util")
9local vers = require("luarocks.core.vers") 7local vers = require("luarocks.core.vers")
10local path = require("luarocks.core.path") 8local path = require("luarocks.core.path")
11local require = nil
12--------------------------------------------------------------------------------
13 9
14-- Table with repository identifiers as keys and tables mapping 10
15-- Lua versions to cached loaded manifests as values. 11
12
13local manif = {DependencyVersion = {}, Manifest = {}, Tree_manifest = {}, }
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
16local manifest_cache = {} 44local manifest_cache = {}
17 45
18--- Cache a loaded manifest. 46
19-- @param repo_url string: The repository identifier. 47
20-- @param lua_version string: Lua version in "5.x" format, defaults to installed version. 48
21-- @param manifest table: the manifest to be cached. 49
22function manif.cache_manifest(repo_url, lua_version, manifest) 50function manif.cache_manifest(repo_url, lua_version, manifest)
23 lua_version = lua_version or cfg.lua_version 51 lua_version = lua_version or cfg.lua_version
24 manifest_cache[repo_url] = manifest_cache[repo_url] or {} 52 manifest_cache[repo_url] = manifest_cache[repo_url] or {}
25 manifest_cache[repo_url][lua_version] = manifest 53 manifest_cache[repo_url][lua_version] = manifest
26end 54end
27 55
28--- Attempt to get cached loaded manifest. 56
29-- @param repo_url string: The repository identifier. 57
30-- @param lua_version string: Lua version in "5.x" format, defaults to installed version. 58
31-- @return table or nil: loaded manifest or nil if cache is empty. 59
32function manif.get_cached_manifest(repo_url, lua_version) 60function manif.get_cached_manifest(repo_url, lua_version)
33 lua_version = lua_version or cfg.lua_version 61 lua_version = lua_version or cfg.lua_version
34 return manifest_cache[repo_url] and manifest_cache[repo_url][lua_version] 62 return manifest_cache[repo_url] and manifest_cache[repo_url][lua_version]
35end 63end
36 64
37--- Back-end function that actually loads the manifest 65
38-- and stores it in the manifest cache. 66
39-- @param file string: The local filename of the manifest file. 67
40-- @param repo_url string: The repository identifier. 68
41-- @param lua_version string: Lua version in "5.x" format, defaults to installed version. 69
42-- @return table or (nil, string, string): the manifest or nil, 70
43-- error message and error code ("open", "load", "run"). 71
44function manif.manifest_loader(file, repo_url, lua_version) 72function manif.manifest_loader(file, repo_url, lua_version)
45 local manifest, err, errcode = persist.load_into_table(file) 73 local manifest, err, errcode = persist.load_into_table(file)
46 if not manifest then 74 if not manifest and type(err) == "string" then
47 return nil, "Failed loading manifest for "..repo_url..": "..err, errcode 75 return nil, "Failed loading manifest for " .. repo_url .. ": " .. err, errcode
48 end 76 end
77
49 manif.cache_manifest(repo_url, lua_version, manifest) 78 manif.cache_manifest(repo_url, lua_version, manifest)
50 return manifest, err, errcode 79 return manifest, err, errcode
51end 80end
52 81
53--- Load a local manifest describing a repository. 82
54-- This is used by the luarocks.loader only. 83
55-- @param repo_url string: URL or pathname for the repository. 84
56-- @return table or (nil, string, string): A table representing the manifest, 85
57-- or nil followed by an error message and an error code, see manifest_loader. 86
58function manif.fast_load_local_manifest(repo_url) 87function manif.fast_load_local_manifest(repo_url)
59 assert(type(repo_url) == "string") 88 assert(type(repo_url) == "string")
60 89
@@ -64,15 +93,15 @@ function manif.fast_load_local_manifest(repo_url)
64 end 93 end
65 94
66 local pathname = dir.path(repo_url, "manifest") 95 local pathname = dir.path(repo_url, "manifest")
67 return manif.manifest_loader(pathname, repo_url, nil, true) 96 return manif.manifest_loader(pathname, repo_url, nil)
68end 97end
69 98
70function manif.load_rocks_tree_manifests(deps_mode) 99function manif.load_rocks_tree_manifests(deps_mode)
71 local trees = {} 100 local trees = {}
72 path.map_trees(deps_mode, function(tree) 101 path.map_trees(deps_mode, function(tree)
73 local manifest, err = manif.fast_load_local_manifest(path.rocks_dir(tree)) 102 local manifest = manif.fast_load_local_manifest(path.rocks_dir(tree))
74 if manifest then 103 if manifest then
75 table.insert(trees, {tree=tree, manifest=manifest}) 104 table.insert(trees, { tree = tree, manifest = manifest })
76 end 105 end
77 end) 106 end)
78 return trees 107 return trees
diff --git a/src/luarocks/core/manif.tl b/src/luarocks/core/manif.tl
index f3ba3c20..503fc2e5 100644
--- a/src/luarocks/core/manif.tl
+++ b/src/luarocks/core/manif.tl
@@ -69,14 +69,14 @@ end
69-- @param lua_version string: Lua version in "5.x" format, defaults to installed version. 69-- @param lua_version string: Lua version in "5.x" format, defaults to installed version.
70-- @return table or (nil, string, string): the manifest or nil, 70-- @return table or (nil, string, string): the manifest or nil,
71-- error message and error code ("open", "load", "run"). 71-- error message and error code ("open", "load", "run").
72function manif.manifest_loader(file: string, repo_url: string, lua_version: string): Manifest, string, string 72function manif.manifest_loader(file: string, repo_url: string, lua_version: string): Manifest, string | {any: any}, string
73 local manifest, err, errcode: {any: any}, {any: any} | string, string = persist.load_into_table(file) 73 local manifest, err, errcode: {any: any}, {any: any} | string, string = persist.load_into_table(file)
74 if not manifest then 74 if not manifest and err is string then
75 return nil, "Failed loading manifest for "..repo_url..": " ..tostring(err), errcode 75 return nil, "Failed loading manifest for "..repo_url..": " .. err, errcode
76 end 76 end
77 77
78 manif.cache_manifest(repo_url, lua_version, manifest as Manifest) -- No runtime check if manifest is actually a Manifest! 78 manif.cache_manifest(repo_url, lua_version, manifest as Manifest) -- No runtime check if manifest is actually a Manifest!
79 return manifest as Manifest, nil, nil 79 return manifest as Manifest, err, errcode
80end 80end
81 81
82--- Load a local manifest describing a repository. 82--- Load a local manifest describing a repository.