aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-07-17 20:11:00 +0300
committerV1K1NGbg <victor@ilchev.com>2024-08-05 20:49:17 +0300
commitf051c0952e5fa4c1373dc1410c8da8c65ff7b9fc (patch)
treeaae33a6146d83d022efd6e45efc215a8075432fe
parentd6a17f7add82faf97d6a00c5b0f523f5b4401ba6 (diff)
downloadluarocks-f051c0952e5fa4c1373dc1410c8da8c65ff7b9fc.tar.gz
luarocks-f051c0952e5fa4c1373dc1410c8da8c65ff7b9fc.tar.bz2
luarocks-f051c0952e5fa4c1373dc1410c8da8c65ff7b9fc.zip
teal bug
-rw-r--r--src/luarocks/core/util.tl9
-rw-r--r--src/luarocks/path.tl21
-rw-r--r--src/luarocks/util.tl33
3 files changed, 32 insertions, 31 deletions
diff --git a/src/luarocks/core/util.tl b/src/luarocks/core/util.tl
index 30461566..e278ebf0 100644
--- a/src/luarocks/core/util.tl
+++ b/src/luarocks/core/util.tl
@@ -117,6 +117,15 @@ function util.show_table(t: {any:any}, tname: string, top_indent: string): strin
117 return cart .. autoref 117 return cart .. autoref
118end 118end
119 119
120--- Produce a Lua pattern that matches precisely the given string
121-- (this is suitable to be concatenating to other patterns,
122-- so it does not include beginning- and end-of-string markers (^$)
123-- @param s string: The input string
124-- @return string: The equivalent pattern
125function util.matchquote(s: string): string
126 return (s:gsub("[?%-+*%[%].%%()$^]","%%%1"))
127end
128
120--- Merges contents of src on top of dst's contents 129--- Merges contents of src on top of dst's contents
121-- (i.e. if an key from src already exists in dst, replace it). 130-- (i.e. if an key from src already exists in dst, replace it).
122-- @param dst Destination table, which will receive src's contents. 131-- @param dst Destination table, which will receive src's contents.
diff --git a/src/luarocks/path.tl b/src/luarocks/path.tl
index 93fb6aae..4bf2e47c 100644
--- a/src/luarocks/path.tl
+++ b/src/luarocks/path.tl
@@ -6,7 +6,7 @@
6local cfg = require("luarocks.core.cfg") 6local cfg = require("luarocks.core.cfg")
7local core = require("luarocks.core.path") 7local core = require("luarocks.core.path")
8local dir = require("luarocks.dir") 8local dir = require("luarocks.dir")
9-- local util = require("luarocks.util") --! crashes teal 9local util = require("luarocks.core.util")
10 10
11local type Tree = cfg.Tree 11local type Tree = cfg.Tree
12 12
@@ -28,6 +28,14 @@ path.deploy_lib_dir = core.deploy_lib_dir
28path.map_trees = core.map_trees 28path.map_trees = core.map_trees
29path.rocks_tree_to_string = core.rocks_tree_to_string 29path.rocks_tree_to_string = core.rocks_tree_to_string
30 30
31function path.root_dir(tree: string | Tree): string
32 if tree is string then
33 return tree
34 else
35 return tree.root
36 end
37end
38
31--- Infer rockspec filename from a rock filename. 39--- Infer rockspec filename from a rock filename.
32-- @param rock_name string: Pathname of a rock file. 40-- @param rock_name string: Pathname of a rock file.
33-- @return string: Filename of the rockspec, without path. 41-- @return string: Filename of the rockspec, without path.
@@ -37,16 +45,7 @@ function path.rockspec_name_from_rock(rock_name: string): string
37end 45end
38 46
39function path.root_from_rocks_dir(rocks_dir: string): string 47function path.root_from_rocks_dir(rocks_dir: string): string
40 return "" --! temp 48 return rocks_dir:match("(.*)" .. util.matchquote(cfg.rocks_subdir) .. ".*$")
41 -- return rocks_dir:match("(.*)" .. util.matchquote(cfg.rocks_subdir) .. ".*$") --! only depends here on util
42end
43
44function path.root_dir(tree: string | Tree): string
45 if tree is string then
46 return tree
47 else
48 return tree.root
49 end
50end 49end
51 50
52function path.deploy_bin_dir(tree: string | Tree): string 51function path.deploy_bin_dir(tree: string | Tree): string
diff --git a/src/luarocks/util.tl b/src/luarocks/util.tl
index 77d6f5c4..aff245b8 100644
--- a/src/luarocks/util.tl
+++ b/src/luarocks/util.tl
@@ -19,6 +19,7 @@ local record util
19 printerr: function(...: string | number) 19 printerr: function(...: string | number)
20 warning: function(string) 20 warning: function(string)
21 keys: function<K, V>({K : V}): {K} 21 keys: function<K, V>({K : V}): {K}
22 matchquote: function(string): string
22 23
23 record Fn 24 record Fn
24 fn: function(...: any) 25 fn: function(...: any)
@@ -63,16 +64,17 @@ local record util
63 end 64 end
64end 65end
65 66
66-- util.cleanup_path = core.cleanup_path --tlcheck acting funny 67util.cleanup_path = core.cleanup_path --tlcheck acting funny
67-- util.split_string = core.split_string 68util.split_string = core.split_string
68-- util.sortedpairs = core.sortedpairs 69util.sortedpairs = core.sortedpairs
69-- util.deep_merge = core.deep_merge 70util.deep_merge = core.deep_merge
70-- util.deep_merge_under = core.deep_merge_under 71util.deep_merge_under = core.deep_merge_under
71-- util.popen_read = core.popen_read 72util.popen_read = core.popen_read
72-- util.show_table = core.show_table 73util.show_table = core.show_table
73-- util.printerr = core.printerr 74util.printerr = core.printerr
74-- util.warning = core.warning 75util.warning = core.warning
75-- util.keys = core.keys 76util.keys = core.keys
77util.matchquote = core.matchquote
76 78
77local type Fn = util.Fn 79local type Fn = util.Fn
78local type Rockspec = util.Rockspec 80local type Rockspec = util.Rockspec
@@ -122,15 +124,6 @@ function util.run_scheduled_functions()
122 end 124 end
123end 125end
124 126
125--- Produce a Lua pattern that matches precisely the given string
126-- (this is suitable to be concatenating to other patterns,
127-- so it does not include beginning- and end-of-string markers (^$)
128-- @param s string: The input string
129-- @return string: The equivalent pattern
130function util.matchquote(s: string): string
131 return (s:gsub("[?%-+*%[%].%%()$^]","%%%1"))
132end
133
134local var_format_pattern = "%$%((%a[%a%d_]+)%)" 127local var_format_pattern = "%$%((%a[%a%d_]+)%)"
135 128
136-- Check if a set of needed variables are referenced 129-- Check if a set of needed variables are referenced
@@ -305,7 +298,7 @@ end
305 298
306function util.announce_install(rockspec: Rockspec) 299function util.announce_install(rockspec: Rockspec)
307 local cfg = require("luarocks.core.cfg") 300 local cfg = require("luarocks.core.cfg")
308 local path = require("luarocks.path") 301 local path = require("luarocks.core.path") --TEAL BUG?
309 302
310 local suffix = "" 303 local suffix = ""
311 if rockspec.description and rockspec.description.license then 304 if rockspec.description and rockspec.description.license then