aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-08-05 22:45:47 +0300
committerV1K1NGbg <victor@ilchev.com>2024-08-05 22:45:47 +0300
commitbc6cd0f6064738fd8da57b59fac5c457d2ef62b7 (patch)
tree57cd288ce4d7711091a7c7597d5843098e88dc55
parente33a230018ef6a8df918d061180ccf8d79921447 (diff)
downloadluarocks-bc6cd0f6064738fd8da57b59fac5c457d2ef62b7.tar.gz
luarocks-bc6cd0f6064738fd8da57b59fac5c457d2ef62b7.tar.bz2
luarocks-bc6cd0f6064738fd8da57b59fac5c457d2ef62b7.zip
new types propagated more
-rw-r--r--src/luarocks/core/util.tl4
-rw-r--r--src/luarocks/deps.tl4
-rw-r--r--src/luarocks/fs.d.tl2
-rw-r--r--src/luarocks/manif.tl26
-rw-r--r--src/luarocks/rockspecs.tl55
-rw-r--r--src/luarocks/type/manifest.tl7
-rw-r--r--src/luarocks/type/rockspec.tl12
7 files changed, 74 insertions, 36 deletions
diff --git a/src/luarocks/core/util.tl b/src/luarocks/core/util.tl
index ad6d8f9e..56c0072e 100644
--- a/src/luarocks/core/util.tl
+++ b/src/luarocks/core/util.tl
@@ -5,8 +5,8 @@ end
5-------------------------------------------------------------------------------- 5--------------------------------------------------------------------------------
6 6
7local type ordering = require("luarocks.core.types.ordering") 7local type ordering = require("luarocks.core.types.ordering")
8local type Ordering<K> = ordering.Ordering<K> 8local type Ordering = ordering.Ordering
9local type SortBy<K> = ordering.SortBy<K> 9local type SortBy = ordering.SortBy
10 10
11local dir_sep = package.config:sub(1, 1) 11local dir_sep = package.config:sub(1, 1)
12 12
diff --git a/src/luarocks/deps.tl b/src/luarocks/deps.tl
index 8fe9feff..622f9b42 100644
--- a/src/luarocks/deps.tl
+++ b/src/luarocks/deps.tl
@@ -245,7 +245,9 @@ function deps.fulfill_dependency(dep, deps_mode, rocks_provided, verify, depskey
245 end 245 end
246 246
247 found, where = match_dep(dep, get_versions) 247 found, where = match_dep(dep, get_versions)
248 assert(found) 248 if not found then
249 return nil, "Repository inconsistency detected (previously unfinished/corrupted installation?)"
250 end
249 return true, found, where 251 return true, found, where
250end 252end
251 253
diff --git a/src/luarocks/fs.d.tl b/src/luarocks/fs.d.tl
index ee471b72..e5047af7 100644
--- a/src/luarocks/fs.d.tl
+++ b/src/luarocks/fs.d.tl
@@ -25,7 +25,7 @@ local record fs
25 tmpname: function(): string 25 tmpname: function(): string
26 execute_string: function(string): boolean 26 execute_string: function(string): boolean
27 Q: function(string): string 27 Q: function(string): string
28 download: function(string, string, ?boolean): boolean, string, string 28 download: function(string, string, ?boolean): boolean, string, boolean
29 set_permissions: function(string, string, string) 29 set_permissions: function(string, string, string)
30 -- patch 30 -- patch
31 absolute_name: function(string, ?string): string 31 absolute_name: function(string, ?string): string
diff --git a/src/luarocks/manif.tl b/src/luarocks/manif.tl
index f0f838b8..d55be0e5 100644
--- a/src/luarocks/manif.tl
+++ b/src/luarocks/manif.tl
@@ -6,8 +6,18 @@ local record manif
6 cache_manifest: function(string, string, Manifest) 6 cache_manifest: function(string, string, Manifest)
7 load_rocks_tree_manifests: function(? string): {Tree_manifest} 7 load_rocks_tree_manifests: function(? string): {Tree_manifest}
8 scan_dependencies: function(string, string, {Tree_manifest}, {any : any}) 8 scan_dependencies: function(string, string, {Tree_manifest}, {any : any})
9 rock_manifest_cache: {string: RockManifest}
10
11 record RockManifest
12 type Entry = string | {string: Entry}
13 rock_manifest: {string: Entry}
14 end
15
9end 16end
10 17
18local type RockManifest = manif.RockManifest
19local type Entry = manif.RockManifest.Entry
20
11local core = require("luarocks.core.manif") 21local core = require("luarocks.core.manif")
12local persist = require("luarocks.persist") 22local persist = require("luarocks.persist")
13local fetch = require("luarocks.fetch") 23local fetch = require("luarocks.fetch")
@@ -21,9 +31,11 @@ local type_manifest = require("luarocks.type.manifest")
21 31
22local type tree = require("luarocks.core.types.tree") 32local type tree = require("luarocks.core.types.tree")
23local type Tree = tree.Tree 33local type Tree = tree.Tree
24local type Manifest = core.Manifest 34local type manifest = require("luarocks.core.types.manifest")
25local type Tree_manifest = core.Tree_manifest 35local type Manifest = manifest.Manifest
26local type DependencyVersion = core.DependencyVersion --! 36local type Tree_manifest = manifest.Tree_manifest
37local type query = require("luarocks.core.types.query")
38local type Query = query.Query
27 39
28manif.cache_manifest = core.cache_manifest 40manif.cache_manifest = core.cache_manifest
29manif.load_rocks_tree_manifests = core.load_rocks_tree_manifests 41manif.load_rocks_tree_manifests = core.load_rocks_tree_manifests
@@ -31,7 +43,7 @@ manif.scan_dependencies = core.scan_dependencies
31 43
32manif.rock_manifest_cache = {} 44manif.rock_manifest_cache = {}
33 45
34local function check_manifest(repo_url: string, manifest: {any: any}, globals: {string: any}): Manifest, string, string 46local function check_manifest(repo_url: string, manifest: Manifest, globals: {string: any}): Manifest, string, string
35 local ok, err = type_manifest.check(manifest, globals) 47 local ok, err = type_manifest.check(manifest, globals)
36 if not ok then 48 if not ok then
37 core.cache_manifest(repo_url, cfg.lua_version, nil) 49 core.cache_manifest(repo_url, cfg.lua_version, nil)
@@ -60,7 +72,7 @@ do
60 end 72 end
61end 73end
62 74
63function manif.load_rock_manifest(name: string, version: string, root?: string | Tree) 75function manif.load_rock_manifest(name: string, version: string, root?: string | Tree): {string: Entry}, string
64 assert(not name:match("/")) 76 assert(not name:match("/"))
65 77
66 local name_version = name.."/"..version 78 local name_version = name.."/"..version
@@ -68,7 +80,7 @@ function manif.load_rock_manifest(name: string, version: string, root?: string |
68 return manif.rock_manifest_cache[name_version].rock_manifest 80 return manif.rock_manifest_cache[name_version].rock_manifest
69 end 81 end
70 local pathname = path.rock_manifest_file(name, version, root) 82 local pathname = path.rock_manifest_file(name, version, root)
71 local rock_manifest = persist.load_into_table(pathname) 83 local rock_manifest = persist.load_into_table(pathname) as RockManifest
72 if not rock_manifest then 84 if not rock_manifest then
73 return nil, "rock_manifest file not found for "..name.." "..version.." - not a LuaRocks tree?" 85 return nil, "rock_manifest file not found for "..name.." "..version.." - not a LuaRocks tree?"
74 end 86 end
@@ -192,7 +204,7 @@ end
192-- or "all", to use all trees. 204-- or "all", to use all trees.
193-- @return table: An array of strings listing installed 205-- @return table: An array of strings listing installed
194-- versions of a package, and a table indicating where they are found. 206-- versions of a package, and a table indicating where they are found.
195function manif.get_versions(dep: DependencyVersion, deps_mode: string): {string}, {string: string | Tree} 207function manif.get_versions(dep: Query, deps_mode: string): {string}, {string: string | Tree}
196 208
197 local name: string = dep.name 209 local name: string = dep.name
198 local namespace: string = dep.namespace 210 local namespace: string = dep.namespace
diff --git a/src/luarocks/rockspecs.tl b/src/luarocks/rockspecs.tl
index cdd0dcff..175428c4 100644
--- a/src/luarocks/rockspecs.tl
+++ b/src/luarocks/rockspecs.tl
@@ -11,6 +11,12 @@ local vers = require("luarocks.core.vers")
11 11
12local type rockspec = require("luarocks.core.types.rockspec") 12local type rockspec = require("luarocks.core.types.rockspec")
13local type Rockspec = rockspec.Rockspec 13local type Rockspec = rockspec.Rockspec
14
15-- local type Query = require("luarocks.core.types.query").Query --TEAL BUG #778
16
17local type query = require("luarocks.core.types.query")
18local type Query = query.Query
19
14local type Variables = rockspec.Variables 20local type Variables = rockspec.Variables
15 21
16local vendored_build_type_set: {string: boolean} = { 22local vendored_build_type_set: {string: boolean} = {
@@ -60,19 +66,19 @@ local function platform_overrides(tbl?: {any: any})
60 tbl.platforms = nil 66 tbl.platforms = nil
61end 67end
62 68
63local function convert_dependencies(rockspec: {string: {string}}, key: string): boolean, string 69local function convert_dependencies(dependencies: {string}): {Query}, string
64 if rockspec[key] then 70 if not dependencies then
65 for i = 1, #rockspec[key] do 71 return {}
66 local parsed, err = queries.from_dep_string(rockspec[key][i]) 72 end
67 if not parsed then 73 local qs: {Query} = {}
68 return nil, "Parse error processing dependency '"..rockspec[key][i].."': "..tostring(err) 74 for i = 1, #dependencies do
69 end 75 local parsed, err = queries.from_dep_string(dependencies[i])
70 rockspec[key][i] = parsed 76 if not parsed then
77 return nil, "Parse error processing dependency '"..dependencies[i].."': "..tostring(err)
71 end 78 end
72 else 79 qs[i] = parsed
73 rockspec[key] = {}
74 end 80 end
75 return true 81 return qs
76end 82end
77 83
78--- Set up path-related variables for a given rock. 84--- Set up path-related variables for a given rock.
@@ -147,11 +153,20 @@ function rockspecs.from_persisted_table(filename: string, rockspec: Rockspec, gl
147 153
148 rockspec.rocks_provided = util.get_rocks_provided(rockspec) 154 rockspec.rocks_provided = util.get_rocks_provided(rockspec)
149 155
150 for _, key in ipairs({"dependencies", "build_dependencies", "test_dependencies"}) do 156 local err: string
151 local ok, err = convert_dependencies(rockspec, key) 157 rockspec.dependencies.queries, err = convert_dependencies(rockspec.dependencies)
152 if not ok then 158 if err then
153 return nil, err 159 return nil, err
154 end 160 end
161
162 rockspec.build_dependencies.queries, err = convert_dependencies(rockspec.build_dependencies)
163 if err then
164 return nil, err
165 end
166
167 rockspec.test_dependencies.queries, err = convert_dependencies(rockspec.test_dependencies)
168 if err then
169 return nil, err
155 end 170 end
156 171
157 if rockspec.build 172 if rockspec.build
@@ -163,7 +178,7 @@ function rockspecs.from_persisted_table(filename: string, rockspec: Rockspec, gl
163 end 178 end
164 179
165 local found = false 180 local found = false
166 for _, dep in ipairs(rockspec.build_dependencies) do 181 for _, dep in ipairs(rockspec.build_dependencies.queries) do
167 if dep.name == build_pkg_name then 182 if dep.name == build_pkg_name then
168 found = true 183 found = true
169 break 184 break
@@ -171,7 +186,11 @@ function rockspecs.from_persisted_table(filename: string, rockspec: Rockspec, gl
171 end 186 end
172 187
173 if not found then 188 if not found then
174 table.insert(rockspec.build_dependencies, queries.from_dep_string(build_pkg_name)) 189 local query, err = queries.from_dep_string(build_pkg_name)
190 if err then
191 return nil, "Invalid dependency in rockspec: " .. err
192 end
193 table.insert(rockspec.build_dependencies.queries, query)
175 end 194 end
176 end 195 end
177 196
diff --git a/src/luarocks/type/manifest.tl b/src/luarocks/type/manifest.tl
index f379f1e0..3114b82a 100644
--- a/src/luarocks/type/manifest.tl
+++ b/src/luarocks/type/manifest.tl
@@ -1,6 +1,9 @@
1local record type_manifest 1local record type_manifest
2end 2end
3 3
4local type manifest = require("luarocks.core.types.manifest")
5local type Manifest = manifest.Manifest
6
4local type_check = require("luarocks.type_check") 7local type_check = require("luarocks.type_check")
5 8
6local manifest_formats = type_check.declare_schemas({ 9local manifest_formats = type_check.declare_schemas({
@@ -80,11 +83,11 @@ local manifest_formats = type_check.declare_schemas({
80-- mismatches. 83-- mismatches.
81-- @return boolean or (nil, string): true if type checking 84-- @return boolean or (nil, string): true if type checking
82-- succeeded, or nil and an error message if it failed. 85-- succeeded, or nil and an error message if it failed.
83function type_manifest.check(manifest: {any: any}, globals: {string: any}): boolean, string --! 86function type_manifest.check(manifest: Manifest, globals: {string: any}): boolean, string --!
84 local format = manifest_formats["3.0"] 87 local format = manifest_formats["3.0"]
85 local ok, err = type_check.check_undeclared_globals(globals, format) 88 local ok, err = type_check.check_undeclared_globals(globals, format)
86 if not ok then return nil, err end 89 if not ok then return nil, err end
87 return type_check.type_check_table("3.0", manifest, format, "") 90 return type_check.type_check_table("3.0", manifest as {any: any}, format, "")
88end 91end
89 92
90return type_manifest 93return type_manifest
diff --git a/src/luarocks/type/rockspec.tl b/src/luarocks/type/rockspec.tl
index 1b03736d..014dc4d3 100644
--- a/src/luarocks/type/rockspec.tl
+++ b/src/luarocks/type/rockspec.tl
@@ -6,8 +6,10 @@ end
6local type ordering = require("luarocks.core.types.ordering") 6local type ordering = require("luarocks.core.types.ordering")
7local type Ordering = ordering.Ordering 7local type Ordering = ordering.Ordering
8 8
9local type rockspec = require("luarocks.core.types.rockspec")
10local type Rockspec = rockspec.Rockspec
11
9local type_check = require("luarocks.type_check") 12local type_check = require("luarocks.type_check")
10local util = require("luarocks.core.util") --!
11 13
12-- local type TableSchema = type_check.TableSchema 14-- local type TableSchema = type_check.TableSchema
13 15
@@ -206,14 +208,14 @@ type_rockspec.order = {
206 } 208 }
207} 209}
208 210
209local function check_rockspec_using_version(rockspec: {any: any}, globals: {string: any}, version: string): boolean, string 211local function check_rockspec_using_version(rockspec: Rockspec, globals: {string: any}, version: string): boolean, string
210 local schema = rockspec_formats[version] 212 local schema = rockspec_formats[version]
211 if not schema then 213 if not schema then
212 return nil, "unknown rockspec format " .. version 214 return nil, "unknown rockspec format " .. version
213 end 215 end
214 local ok, err = type_check.check_undeclared_globals(globals, schema) 216 local ok, err = type_check.check_undeclared_globals(globals, schema)
215 if ok then 217 if ok then
216 ok, err = type_check.type_check_table(version, rockspec, schema, "") 218 ok, err = type_check.type_check_table(version, rockspec as {any: any}, schema, "")
217 end 219 end
218 if ok then 220 if ok then
219 return true 221 return true
@@ -228,9 +230,9 @@ end
228-- mismatches. 230-- mismatches.
229-- @return boolean or (nil, string): true if type checking 231-- @return boolean or (nil, string): true if type checking
230-- succeeded, or nil and an error message if it failed. 232-- succeeded, or nil and an error message if it failed.
231function type_rockspec.check(rockspec: {any: any}, globals: {string: any}): boolean, string 233function type_rockspec.check(rockspec: Rockspec, globals: {string: any}): boolean, string
232 234
233 local version: string = rockspec.rockspec_format as string or "1.0" --! tostring 235 local version: string = rockspec.rockspec_format as string or "1.0"
234 local ok, err = check_rockspec_using_version(rockspec, globals, version) 236 local ok, err = check_rockspec_using_version(rockspec, globals, version)
235 if ok then 237 if ok then
236 return true 238 return true