diff options
author | V1K1NGbg <victor@ilchev.com> | 2024-07-05 13:12:46 +0300 |
---|---|---|
committer | V1K1NGbg <victor@ilchev.com> | 2024-08-05 20:49:17 +0300 |
commit | 95a1997f749b4b9e114632037fdcc28c8a8e417d (patch) | |
tree | d23ba1a449487973049c4d7255de457e21f24bf6 | |
parent | b537a1c1caa235d09698bd298be03996d8efaf14 (diff) | |
download | luarocks-95a1997f749b4b9e114632037fdcc28c8a8e417d.tar.gz luarocks-95a1997f749b4b9e114632037fdcc28c8a8e417d.tar.bz2 luarocks-95a1997f749b4b9e114632037fdcc28c8a8e417d.zip |
test 2 (code without manif)
-rw-r--r-- | src/luarocks/core/manif-incomplete.lua (renamed from src/luarocks/core/manif-original.lua) | 112 | ||||
-rw-r--r-- | src/luarocks/core/manif.lua | 112 |
2 files changed, 112 insertions, 112 deletions
diff --git a/src/luarocks/core/manif-original.lua b/src/luarocks/core/manif-incomplete.lua index 3925f636..758b76db 100644 --- a/src/luarocks/core/manif-original.lua +++ b/src/luarocks/core/manif-incomplete.lua | |||
@@ -1,62 +1,112 @@ | |||
1 | local _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 ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local table = _tl_compat and _tl_compat.table or table | ||
1 | 2 | ||
2 | --- Core functions for querying manifest files. | ||
3 | local manif = {} | 3 | local manif = {} |
4 | 4 | ||
5 | |||
6 | |||
7 | |||
8 | |||
9 | |||
10 | |||
11 | |||
12 | |||
13 | |||
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 | |||
44 | |||
45 | |||
46 | |||
47 | |||
48 | |||
49 | |||
50 | |||
51 | |||
52 | |||
53 | |||
54 | |||
55 | |||
56 | |||
5 | local persist = require("luarocks.core.persist") | 57 | local persist = require("luarocks.core.persist") |
6 | local cfg = require("luarocks.core.cfg") | 58 | local cfg = require("luarocks.core.cfg") |
7 | local dir = require("luarocks.core.dir") | 59 | local dir = require("luarocks.core.dir") |
8 | local util = require("luarocks.core.util") | 60 | local util = require("luarocks.core.util") |
9 | local vers = require("luarocks.core.vers") | 61 | local vers = require("luarocks.core.vers") |
10 | local path = require("luarocks.core.path") | 62 | local path = require("luarocks.core.path") |
11 | local require = nil | ||
12 | -------------------------------------------------------------------------------- | ||
13 | 63 | ||
14 | -- Table with repository identifiers as keys and tables mapping | 64 | |
15 | -- Lua versions to cached loaded manifests as values. | 65 | |
66 | |||
16 | local manifest_cache = {} | 67 | local manifest_cache = {} |
17 | 68 | ||
18 | --- Cache a loaded manifest. | 69 | |
19 | -- @param repo_url string: The repository identifier. | 70 | |
20 | -- @param lua_version string: Lua version in "5.x" format, defaults to installed version. | 71 | |
21 | -- @param manifest table: the manifest to be cached. | 72 | |
22 | function manif.cache_manifest(repo_url, lua_version, manifest) | 73 | function manif.cache_manifest(repo_url, lua_version, manifest) |
23 | lua_version = lua_version or cfg.lua_version | 74 | lua_version = lua_version or cfg.lua_version |
24 | manifest_cache[repo_url] = manifest_cache[repo_url] or {} | 75 | manifest_cache[repo_url] = manifest_cache[repo_url] or {} |
25 | manifest_cache[repo_url][lua_version] = manifest | 76 | manifest_cache[repo_url][lua_version] = manifest |
26 | end | 77 | end |
27 | 78 | ||
28 | --- Attempt to get cached loaded manifest. | 79 | |
29 | -- @param repo_url string: The repository identifier. | 80 | |
30 | -- @param lua_version string: Lua version in "5.x" format, defaults to installed version. | 81 | |
31 | -- @return table or nil: loaded manifest or nil if cache is empty. | 82 | |
32 | function manif.get_cached_manifest(repo_url, lua_version) | 83 | function manif.get_cached_manifest(repo_url, lua_version) |
33 | lua_version = lua_version or cfg.lua_version | 84 | lua_version = lua_version or cfg.lua_version |
34 | return manifest_cache[repo_url] and manifest_cache[repo_url][lua_version] | 85 | return manifest_cache[repo_url] and manifest_cache[repo_url][lua_version] |
35 | end | 86 | end |
36 | 87 | ||
37 | --- Back-end function that actually loads the manifest | 88 | |
38 | -- and stores it in the manifest cache. | 89 | |
39 | -- @param file string: The local filename of the manifest file. | 90 | |
40 | -- @param repo_url string: The repository identifier. | 91 | |
41 | -- @param lua_version string: Lua version in "5.x" format, defaults to installed version. | 92 | |
42 | -- @return table or (nil, string, string): the manifest or nil, | 93 | |
43 | -- error message and error code ("open", "load", "run"). | 94 | |
44 | function manif.manifest_loader(file, repo_url, lua_version) | 95 | function manif.manifest_loader(file, repo_url, lua_version) |
45 | local manifest, err, errcode = persist.load_into_table(file) | 96 | local manifest, err, errcode = persist.load_into_table(file) |
46 | if not manifest then | 97 | if not (type(manifest) == "table") then |
47 | return nil, "Failed loading manifest for "..repo_url..": "..err, errcode | 98 | return nil, "Failed loading manifest for " .. repo_url .. ": " .. err, errcode |
48 | end | 99 | end |
49 | manif.cache_manifest(repo_url, lua_version, manifest) | 100 | manif.cache_manifest(repo_url, lua_version, manifest) |
50 | return manifest, err, errcode | 101 | return manifest, err, errcode |
51 | end | 102 | end |
52 | 103 | ||
53 | --- Load a local manifest describing a repository. | 104 | |
54 | -- This is used by the luarocks.loader only. | 105 | |
55 | -- @param repo_url string: URL or pathname for the repository. | 106 | |
56 | -- @return table or (nil, string, string): A table representing the manifest, | 107 | |
57 | -- or nil followed by an error message and an error code, see manifest_loader. | 108 | |
58 | function manif.fast_load_local_manifest(repo_url) | 109 | function manif.fast_load_local_manifest(repo_url) |
59 | assert(type(repo_url) == "string") | ||
60 | 110 | ||
61 | local cached_manifest = manif.get_cached_manifest(repo_url) | 111 | local cached_manifest = manif.get_cached_manifest(repo_url) |
62 | if cached_manifest then | 112 | if cached_manifest then |
@@ -64,15 +114,15 @@ function manif.fast_load_local_manifest(repo_url) | |||
64 | end | 114 | end |
65 | 115 | ||
66 | local pathname = dir.path(repo_url, "manifest") | 116 | local pathname = dir.path(repo_url, "manifest") |
67 | return manif.manifest_loader(pathname, repo_url, nil, true) | 117 | return manif.manifest_loader(pathname, repo_url, nil) |
68 | end | 118 | end |
69 | 119 | ||
70 | function manif.load_rocks_tree_manifests(deps_mode) | 120 | function manif.load_rocks_tree_manifests(deps_mode) |
71 | local trees = {} | 121 | local trees = {} |
72 | path.map_trees(deps_mode, function(tree) | 122 | path.map_trees(deps_mode, function(tree) |
73 | local manifest, err = manif.fast_load_local_manifest(path.rocks_dir(tree)) | 123 | local manifest = manif.fast_load_local_manifest(path.rocks_dir(tree)) |
74 | if manifest then | 124 | if manifest then |
75 | table.insert(trees, {tree=tree, manifest=manifest}) | 125 | table.insert(trees, { tree = tree, manifest = manifest }) |
76 | end | 126 | end |
77 | end) | 127 | end) |
78 | return trees | 128 | return trees |
diff --git a/src/luarocks/core/manif.lua b/src/luarocks/core/manif.lua index 758b76db..3925f636 100644 --- a/src/luarocks/core/manif.lua +++ b/src/luarocks/core/manif.lua | |||
@@ -1,112 +1,62 @@ | |||
1 | local _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 ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local table = _tl_compat and _tl_compat.table or table | ||
2 | 1 | ||
2 | --- Core functions for querying manifest files. | ||
3 | local manif = {} | 3 | local manif = {} |
4 | 4 | ||
5 | |||
6 | |||
7 | |||
8 | |||
9 | |||
10 | |||
11 | |||
12 | |||
13 | |||
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 | |||
44 | |||
45 | |||
46 | |||
47 | |||
48 | |||
49 | |||
50 | |||
51 | |||
52 | |||
53 | |||
54 | |||
55 | |||
56 | |||
57 | local persist = require("luarocks.core.persist") | 5 | local persist = require("luarocks.core.persist") |
58 | local cfg = require("luarocks.core.cfg") | 6 | local cfg = require("luarocks.core.cfg") |
59 | local dir = require("luarocks.core.dir") | 7 | local dir = require("luarocks.core.dir") |
60 | local util = require("luarocks.core.util") | 8 | local util = require("luarocks.core.util") |
61 | local vers = require("luarocks.core.vers") | 9 | local vers = require("luarocks.core.vers") |
62 | local path = require("luarocks.core.path") | 10 | local path = require("luarocks.core.path") |
11 | local require = nil | ||
12 | -------------------------------------------------------------------------------- | ||
63 | 13 | ||
64 | 14 | -- Table with repository identifiers as keys and tables mapping | |
65 | 15 | -- Lua versions to cached loaded manifests as values. | |
66 | |||
67 | local manifest_cache = {} | 16 | local manifest_cache = {} |
68 | 17 | ||
69 | 18 | --- Cache a loaded manifest. | |
70 | 19 | -- @param repo_url string: The repository identifier. | |
71 | 20 | -- @param lua_version string: Lua version in "5.x" format, defaults to installed version. | |
72 | 21 | -- @param manifest table: the manifest to be cached. | |
73 | function manif.cache_manifest(repo_url, lua_version, manifest) | 22 | function manif.cache_manifest(repo_url, lua_version, manifest) |
74 | lua_version = lua_version or cfg.lua_version | 23 | lua_version = lua_version or cfg.lua_version |
75 | manifest_cache[repo_url] = manifest_cache[repo_url] or {} | 24 | manifest_cache[repo_url] = manifest_cache[repo_url] or {} |
76 | manifest_cache[repo_url][lua_version] = manifest | 25 | manifest_cache[repo_url][lua_version] = manifest |
77 | end | 26 | end |
78 | 27 | ||
79 | 28 | --- Attempt to get cached loaded manifest. | |
80 | 29 | -- @param repo_url string: The repository identifier. | |
81 | 30 | -- @param lua_version string: Lua version in "5.x" format, defaults to installed version. | |
82 | 31 | -- @return table or nil: loaded manifest or nil if cache is empty. | |
83 | function manif.get_cached_manifest(repo_url, lua_version) | 32 | function manif.get_cached_manifest(repo_url, lua_version) |
84 | lua_version = lua_version or cfg.lua_version | 33 | lua_version = lua_version or cfg.lua_version |
85 | 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] |
86 | end | 35 | end |
87 | 36 | ||
88 | 37 | --- Back-end function that actually loads the manifest | |
89 | 38 | -- and stores it in the manifest cache. | |
90 | 39 | -- @param file string: The local filename of the manifest file. | |
91 | 40 | -- @param repo_url string: The repository identifier. | |
92 | 41 | -- @param lua_version string: Lua version in "5.x" format, defaults to installed version. | |
93 | 42 | -- @return table or (nil, string, string): the manifest or nil, | |
94 | 43 | -- error message and error code ("open", "load", "run"). | |
95 | function manif.manifest_loader(file, repo_url, lua_version) | 44 | function manif.manifest_loader(file, repo_url, lua_version) |
96 | local manifest, err, errcode = persist.load_into_table(file) | 45 | local manifest, err, errcode = persist.load_into_table(file) |
97 | if not (type(manifest) == "table") then | 46 | if not manifest then |
98 | return nil, "Failed loading manifest for " .. repo_url .. ": " .. err, errcode | 47 | return nil, "Failed loading manifest for "..repo_url..": "..err, errcode |
99 | end | 48 | end |
100 | manif.cache_manifest(repo_url, lua_version, manifest) | 49 | manif.cache_manifest(repo_url, lua_version, manifest) |
101 | return manifest, err, errcode | 50 | return manifest, err, errcode |
102 | end | 51 | end |
103 | 52 | ||
104 | 53 | --- Load a local manifest describing a repository. | |
105 | 54 | -- This is used by the luarocks.loader only. | |
106 | 55 | -- @param repo_url string: URL or pathname for the repository. | |
107 | 56 | -- @return table or (nil, string, string): A table representing the manifest, | |
108 | 57 | -- or nil followed by an error message and an error code, see manifest_loader. | |
109 | function manif.fast_load_local_manifest(repo_url) | 58 | function manif.fast_load_local_manifest(repo_url) |
59 | assert(type(repo_url) == "string") | ||
110 | 60 | ||
111 | local cached_manifest = manif.get_cached_manifest(repo_url) | 61 | local cached_manifest = manif.get_cached_manifest(repo_url) |
112 | if cached_manifest then | 62 | if cached_manifest then |
@@ -114,15 +64,15 @@ function manif.fast_load_local_manifest(repo_url) | |||
114 | end | 64 | end |
115 | 65 | ||
116 | local pathname = dir.path(repo_url, "manifest") | 66 | local pathname = dir.path(repo_url, "manifest") |
117 | return manif.manifest_loader(pathname, repo_url, nil) | 67 | return manif.manifest_loader(pathname, repo_url, nil, true) |
118 | end | 68 | end |
119 | 69 | ||
120 | function manif.load_rocks_tree_manifests(deps_mode) | 70 | function manif.load_rocks_tree_manifests(deps_mode) |
121 | local trees = {} | 71 | local trees = {} |
122 | path.map_trees(deps_mode, function(tree) | 72 | path.map_trees(deps_mode, function(tree) |
123 | local manifest = manif.fast_load_local_manifest(path.rocks_dir(tree)) | 73 | local manifest, err = manif.fast_load_local_manifest(path.rocks_dir(tree)) |
124 | if manifest then | 74 | if manifest then |
125 | table.insert(trees, { tree = tree, manifest = manifest }) | 75 | table.insert(trees, {tree=tree, manifest=manifest}) |
126 | end | 76 | end |
127 | end) | 77 | end) |
128 | return trees | 78 | return trees |