diff options
author | V1K1NGbg <victor@ilchev.com> | 2024-08-01 17:00:24 +0300 |
---|---|---|
committer | V1K1NGbg <victor@ilchev.com> | 2024-08-05 20:51:31 +0300 |
commit | ee55c132b3415b1cd6993b6cf80a7c03a1090651 (patch) | |
tree | a7f00702395256617dc0d9621d545ecc903d32f5 | |
parent | 2b70116b944dec1a6946c4aa1a2c8aa0d07667a6 (diff) | |
download | luarocks-ee55c132b3415b1cd6993b6cf80a7c03a1090651.tar.gz luarocks-ee55c132b3415b1cd6993b6cf80a7c03a1090651.tar.bz2 luarocks-ee55c132b3415b1cd6993b6cf80a7c03a1090651.zip |
csv finished
-rw-r--r-- | src/luarocks/core/cfg.d.tl | 20 | ||||
-rw-r--r-- | src/luarocks/fetch/cvs-original.lua | 55 | ||||
-rw-r--r-- | src/luarocks/fetch/cvs.lua | 27 | ||||
-rw-r--r-- | src/luarocks/fetch/cvs.tl | 54 | ||||
-rw-r--r-- | src/luarocks/fs.d.tl | 3 |
5 files changed, 140 insertions, 19 deletions
diff --git a/src/luarocks/core/cfg.d.tl b/src/luarocks/core/cfg.d.tl index eff86971..97f10a35 100644 --- a/src/luarocks/core/cfg.d.tl +++ b/src/luarocks/core/cfg.d.tl | |||
@@ -22,10 +22,6 @@ local record cfg | |||
22 | lib_dir: string | 22 | lib_dir: string |
23 | end | 23 | end |
24 | -- util | 24 | -- util |
25 | record Source | ||
26 | url: string | ||
27 | end | ||
28 | |||
29 | record Description | 25 | record Description |
30 | summary: string | 26 | summary: string |
31 | detailed: string | 27 | detailed: string |
@@ -44,11 +40,19 @@ local record cfg | |||
44 | rockspec_format: string | 40 | rockspec_format: string |
45 | name: string --? package | 41 | name: string --? package |
46 | version: string | 42 | version: string |
47 | source: {Source} | 43 | record source |
44 | url: string | ||
45 | module: string | ||
46 | pathname: string | ||
47 | tag: string | ||
48 | end | ||
48 | description: Description | 49 | description: Description |
49 | test_dependencies: {string} | 50 | test_dependencies: {string} |
50 | test: Test | 51 | test: Test |
51 | format_is_at_least: function(Rockspec, string): boolean | 52 | format_is_at_least: function(Rockspec, string): boolean |
53 | record variables | ||
54 | CVS: string | ||
55 | end | ||
52 | end | 56 | end |
53 | 57 | ||
54 | record cache | 58 | record cache |
@@ -66,6 +70,12 @@ local record cfg | |||
66 | home: string | 70 | home: string |
67 | -- queries | 71 | -- queries |
68 | arch: string | 72 | arch: string |
73 | -- api | ||
74 | record config_files | ||
75 | record user | ||
76 | file: string | ||
77 | end | ||
78 | end | ||
69 | end | 79 | end |
70 | 80 | ||
71 | return cfg \ No newline at end of file | 81 | return cfg \ No newline at end of file |
diff --git a/src/luarocks/fetch/cvs-original.lua b/src/luarocks/fetch/cvs-original.lua new file mode 100644 index 00000000..d78e6e60 --- /dev/null +++ b/src/luarocks/fetch/cvs-original.lua | |||
@@ -0,0 +1,55 @@ | |||
1 | |||
2 | --- Fetch back-end for retrieving sources from CVS. | ||
3 | local cvs = {} | ||
4 | |||
5 | local unpack = unpack or table.unpack | ||
6 | |||
7 | local fs = require("luarocks.fs") | ||
8 | local dir = require("luarocks.dir") | ||
9 | local util = require("luarocks.util") | ||
10 | |||
11 | --- Download sources for building a rock, using CVS. | ||
12 | -- @param rockspec table: The rockspec table | ||
13 | -- @param extract boolean: Unused in this module (required for API purposes.) | ||
14 | -- @param dest_dir string or nil: If set, will extract to the given directory. | ||
15 | -- @return (string, string) or (nil, string): The absolute pathname of | ||
16 | -- the fetched source tarball and the temporary directory created to | ||
17 | -- store it; or nil and an error message. | ||
18 | function cvs.get_sources(rockspec, extract, dest_dir) | ||
19 | assert(rockspec:type() == "rockspec") | ||
20 | assert(type(dest_dir) == "string" or not dest_dir) | ||
21 | |||
22 | local cvs_cmd = rockspec.variables.CVS | ||
23 | local ok, err_msg = fs.is_tool_available(cvs_cmd, "CVS") | ||
24 | if not ok then | ||
25 | return nil, err_msg | ||
26 | end | ||
27 | |||
28 | local name_version = rockspec.name .. "-" .. rockspec.version | ||
29 | local module = rockspec.source.module or dir.base_name(rockspec.source.url) | ||
30 | local command = {cvs_cmd, "-d"..rockspec.source.pathname, "export", module} | ||
31 | if rockspec.source.tag then | ||
32 | table.insert(command, 4, "-r") | ||
33 | table.insert(command, 5, rockspec.source.tag) | ||
34 | end | ||
35 | local store_dir | ||
36 | if not dest_dir then | ||
37 | store_dir = fs.make_temp_dir(name_version) | ||
38 | if not store_dir then | ||
39 | return nil, "Failed creating temporary directory." | ||
40 | end | ||
41 | util.schedule_function(fs.delete, store_dir) | ||
42 | else | ||
43 | store_dir = dest_dir | ||
44 | end | ||
45 | local ok, err = fs.change_dir(store_dir) | ||
46 | if not ok then return nil, err end | ||
47 | if not fs.execute(unpack(command)) then | ||
48 | return nil, "Failed fetching files from CVS." | ||
49 | end | ||
50 | fs.pop_dir() | ||
51 | return module, store_dir | ||
52 | end | ||
53 | |||
54 | |||
55 | return cvs | ||
diff --git a/src/luarocks/fetch/cvs.lua b/src/luarocks/fetch/cvs.lua index d78e6e60..1c6616ff 100644 --- a/src/luarocks/fetch/cvs.lua +++ b/src/luarocks/fetch/cvs.lua | |||
@@ -1,24 +1,23 @@ | |||
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 table = _tl_compat and _tl_compat.table or table; local _tl_table_unpack = unpack or table.unpack | ||
1 | 2 | ||
2 | --- Fetch back-end for retrieving sources from CVS. | ||
3 | local cvs = {} | 3 | local cvs = {} |
4 | 4 | ||
5 | local unpack = unpack or table.unpack | ||
6 | 5 | ||
7 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
8 | local dir = require("luarocks.dir") | 7 | local dir = require("luarocks.dir") |
9 | local util = require("luarocks.util") | 8 | local util = require("luarocks.util") |
9 | local cfg = require("luarocks.core.cfg") | ||
10 | |||
11 | |||
12 | |||
13 | |||
10 | 14 | ||
11 | --- Download sources for building a rock, using CVS. | ||
12 | -- @param rockspec table: The rockspec table | ||
13 | -- @param extract boolean: Unused in this module (required for API purposes.) | ||
14 | -- @param dest_dir string or nil: If set, will extract to the given directory. | ||
15 | -- @return (string, string) or (nil, string): The absolute pathname of | ||
16 | -- the fetched source tarball and the temporary directory created to | ||
17 | -- store it; or nil and an error message. | ||
18 | function cvs.get_sources(rockspec, extract, dest_dir) | ||
19 | assert(rockspec:type() == "rockspec") | ||
20 | assert(type(dest_dir) == "string" or not dest_dir) | ||
21 | 15 | ||
16 | |||
17 | |||
18 | |||
19 | |||
20 | function cvs.get_sources(rockspec, extract, dest_dir) | ||
22 | local cvs_cmd = rockspec.variables.CVS | 21 | local cvs_cmd = rockspec.variables.CVS |
23 | local ok, err_msg = fs.is_tool_available(cvs_cmd, "CVS") | 22 | local ok, err_msg = fs.is_tool_available(cvs_cmd, "CVS") |
24 | if not ok then | 23 | if not ok then |
@@ -27,7 +26,7 @@ function cvs.get_sources(rockspec, extract, dest_dir) | |||
27 | 26 | ||
28 | local name_version = rockspec.name .. "-" .. rockspec.version | 27 | local name_version = rockspec.name .. "-" .. rockspec.version |
29 | local module = rockspec.source.module or dir.base_name(rockspec.source.url) | 28 | local module = rockspec.source.module or dir.base_name(rockspec.source.url) |
30 | local command = {cvs_cmd, "-d"..rockspec.source.pathname, "export", module} | 29 | local command = { cvs_cmd, "-d" .. rockspec.source.pathname, "export", module } |
31 | if rockspec.source.tag then | 30 | if rockspec.source.tag then |
32 | table.insert(command, 4, "-r") | 31 | table.insert(command, 4, "-r") |
33 | table.insert(command, 5, rockspec.source.tag) | 32 | table.insert(command, 5, rockspec.source.tag) |
@@ -44,7 +43,7 @@ function cvs.get_sources(rockspec, extract, dest_dir) | |||
44 | end | 43 | end |
45 | local ok, err = fs.change_dir(store_dir) | 44 | local ok, err = fs.change_dir(store_dir) |
46 | if not ok then return nil, err end | 45 | if not ok then return nil, err end |
47 | if not fs.execute(unpack(command)) then | 46 | if not fs.execute(_tl_table_unpack(command)) then |
48 | return nil, "Failed fetching files from CVS." | 47 | return nil, "Failed fetching files from CVS." |
49 | end | 48 | end |
50 | fs.pop_dir() | 49 | fs.pop_dir() |
diff --git a/src/luarocks/fetch/cvs.tl b/src/luarocks/fetch/cvs.tl new file mode 100644 index 00000000..1d874daf --- /dev/null +++ b/src/luarocks/fetch/cvs.tl | |||
@@ -0,0 +1,54 @@ | |||
1 | |||
2 | --- Fetch back-end for retrieving sources from CVS. | ||
3 | local record cvs | ||
4 | end | ||
5 | |||
6 | local fs = require("luarocks.fs") | ||
7 | local dir = require("luarocks.dir") | ||
8 | local util = require("luarocks.util") | ||
9 | local cfg = require("luarocks.core.cfg") --! import for Rockspec | ||
10 | |||
11 | local type Rockspec = cfg.Rockspec | ||
12 | |||
13 | --- Download sources for building a rock, using CVS. | ||
14 | -- @param rockspec table: The rockspec table | ||
15 | -- @param extract boolean: Unused in this module (required for API purposes.) | ||
16 | -- @param dest_dir string or nil: If set, will extract to the given directory. | ||
17 | -- @return (string, string) or (nil, string): The absolute pathname of | ||
18 | -- the fetched source tarball and the temporary directory created to | ||
19 | -- store it; or nil and an error message. | ||
20 | function cvs.get_sources(rockspec: Rockspec, extract, dest_dir?: string): string, string --? extract not needed | ||
21 | local cvs_cmd = rockspec.variables.CVS | ||
22 | local ok, err_msg = fs.is_tool_available(cvs_cmd, "CVS") | ||
23 | if not ok then | ||
24 | return nil, err_msg | ||
25 | end | ||
26 | |||
27 | local name_version = rockspec.name .. "-" .. rockspec.version | ||
28 | local module = rockspec.source.module or dir.base_name(rockspec.source.url) | ||
29 | local command = {cvs_cmd, "-d"..rockspec.source.pathname, "export", module} | ||
30 | if rockspec.source.tag then | ||
31 | table.insert(command, 4, "-r") | ||
32 | table.insert(command, 5, rockspec.source.tag) | ||
33 | end | ||
34 | local store_dir: string | ||
35 | if not dest_dir then | ||
36 | store_dir = fs.make_temp_dir(name_version) | ||
37 | if not store_dir then | ||
38 | return nil, "Failed creating temporary directory." | ||
39 | end | ||
40 | util.schedule_function(fs.delete, store_dir) | ||
41 | else | ||
42 | store_dir = dest_dir | ||
43 | end | ||
44 | local ok, err = fs.change_dir(store_dir) | ||
45 | if not ok then return nil, err end | ||
46 | if not fs.execute(table.unpack(command)) then | ||
47 | return nil, "Failed fetching files from CVS." | ||
48 | end | ||
49 | fs.pop_dir() | ||
50 | return module, store_dir | ||
51 | end | ||
52 | |||
53 | |||
54 | return cvs | ||
diff --git a/src/luarocks/fs.d.tl b/src/luarocks/fs.d.tl index 88034b65..24f3e61f 100644 --- a/src/luarocks/fs.d.tl +++ b/src/luarocks/fs.d.tl | |||
@@ -17,6 +17,9 @@ local record fs | |||
17 | -- signing | 17 | -- signing |
18 | is_tool_available: function(string, string): string, string | 18 | is_tool_available: function(string, string): string, string |
19 | execute: function(...: string): boolean --? boolean? src/luarocks/signing.tl: 27 | 19 | execute: function(...: string): boolean --? boolean? src/luarocks/signing.tl: 27 |
20 | make_temp_dir: function(string): string, string | ||
21 | change_dir: function(string): boolean, string | ||
22 | pop_dir: function(): boolean | ||
20 | end | 23 | end |
21 | 24 | ||
22 | return fs | 25 | return fs |