diff options
| author | V1K1NGbg <victor@ilchev.com> | 2024-08-06 19:45:49 +0300 |
|---|---|---|
| committer | V1K1NGbg <victor@ilchev.com> | 2024-08-06 19:45:49 +0300 |
| commit | 294f30af4f9af2cf1f7bbd2c787b132dcc954aa4 (patch) | |
| tree | 983dd2104919d0b7bc611f9d899d8f45fe5588ac /src | |
| parent | 57b4ab7209bf046544860b8106c4897df31c9dc4 (diff) | |
| download | luarocks-294f30af4f9af2cf1f7bbd2c787b132dcc954aa4.tar.gz luarocks-294f30af4f9af2cf1f7bbd2c787b132dcc954aa4.tar.bz2 luarocks-294f30af4f9af2cf1f7bbd2c787b132dcc954aa4.zip | |
removed more redefined variables and deps
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/core/manif.tl | 4 | ||||
| -rw-r--r-- | src/luarocks/core/util.tl | 6 | ||||
| -rw-r--r-- | src/luarocks/core/vers.tl | 6 | ||||
| -rw-r--r-- | src/luarocks/deps.tl | 7 | ||||
| -rw-r--r-- | src/luarocks/fetch/cvs.tl | 4 | ||||
| -rw-r--r-- | src/luarocks/fetch/svn.tl | 8 | ||||
| -rw-r--r-- | src/luarocks/queries.tl | 6 | ||||
| -rw-r--r-- | src/luarocks/rockspecs-original.lua | 183 | ||||
| -rw-r--r-- | src/luarocks/rockspecs.lua | 132 | ||||
| -rw-r--r-- | src/luarocks/rockspecs.tl | 5 | ||||
| -rw-r--r-- | src/luarocks/search.tl | 4 | ||||
| -rw-r--r-- | src/luarocks/tools/patch.tl | 2 | ||||
| -rw-r--r-- | src/luarocks/upload/api.tl | 5 |
13 files changed, 88 insertions, 284 deletions
diff --git a/src/luarocks/core/manif.tl b/src/luarocks/core/manif.tl index 7ef018db..683ec741 100644 --- a/src/luarocks/core/manif.tl +++ b/src/luarocks/core/manif.tl | |||
| @@ -12,8 +12,8 @@ local path = require("luarocks.core.path") | |||
| 12 | 12 | ||
| 13 | -------------------------------------------------------------------------------- | 13 | -------------------------------------------------------------------------------- |
| 14 | 14 | ||
| 15 | local type t = require("luarocks.core.types.tree") | 15 | local type tr = require("luarocks.core.types.tree") |
| 16 | local type Tree = t.Tree | 16 | local type Tree = tr.Tree |
| 17 | 17 | ||
| 18 | local type q = require("luarocks.core.types.query") | 18 | local type q = require("luarocks.core.types.query") |
| 19 | local type Query = q.Query | 19 | local type Query = q.Query |
diff --git a/src/luarocks/core/util.tl b/src/luarocks/core/util.tl index ede0e75f..183deaab 100644 --- a/src/luarocks/core/util.tl +++ b/src/luarocks/core/util.tl | |||
| @@ -4,9 +4,9 @@ end | |||
| 4 | 4 | ||
| 5 | -------------------------------------------------------------------------------- | 5 | -------------------------------------------------------------------------------- |
| 6 | 6 | ||
| 7 | local type o = require("luarocks.core.types.ordering") | 7 | local type ord = require("luarocks.core.types.ordering") |
| 8 | local type Ordering = o.Ordering | 8 | local type Ordering = ord.Ordering |
| 9 | local type SortBy = o.SortBy | 9 | local type SortBy = ord.SortBy |
| 10 | 10 | ||
| 11 | local dir_sep = package.config:sub(1, 1) | 11 | local dir_sep = package.config:sub(1, 1) |
| 12 | 12 | ||
diff --git a/src/luarocks/core/vers.tl b/src/luarocks/core/vers.tl index f7ecdb98..62701f74 100644 --- a/src/luarocks/core/vers.tl +++ b/src/luarocks/core/vers.tl | |||
| @@ -2,9 +2,9 @@ local record vers | |||
| 2 | end | 2 | end |
| 3 | 3 | ||
| 4 | local util = require("luarocks.core.util") | 4 | local util = require("luarocks.core.util") |
| 5 | local type v = require("luarocks.core.types.version") | 5 | local type ver = require("luarocks.core.types.version") |
| 6 | local type Version = v.Version | 6 | local type Version = ver.Version |
| 7 | local type Constraint = v.Constraint | 7 | local type Constraint = ver.Constraint |
| 8 | -------------------------------------------------------------------------------- | 8 | -------------------------------------------------------------------------------- |
| 9 | 9 | ||
| 10 | local deltas: {string: integer} = { | 10 | local deltas: {string: integer} = { |
diff --git a/src/luarocks/deps.tl b/src/luarocks/deps.tl index f65594fb..d9d66892 100644 --- a/src/luarocks/deps.tl +++ b/src/luarocks/deps.tl | |||
| @@ -26,10 +26,11 @@ local type Tree = t.Tree | |||
| 26 | local type q = require("luarocks.core.types.query") | 26 | local type q = require("luarocks.core.types.query") |
| 27 | local type Query = q.Query | 27 | local type Query = q.Query |
| 28 | 28 | ||
| 29 | local type Version = require("luarocks.core.types.version").Version | 29 | local type ver = require("luarocks.core.types.version") |
| 30 | local type Version = ver.Version | ||
| 30 | 31 | ||
| 31 | local type p = require("luarocks.core.types.persist") | 32 | local type per = require("luarocks.core.types.persist") |
| 32 | local type PersistableTable = p.PersistableTable | 33 | local type PersistableTable = per.PersistableTable |
| 33 | 34 | ||
| 34 | local type res = require("luarocks.core.types.result") | 35 | local type res = require("luarocks.core.types.result") |
| 35 | local type Result = res.Result | 36 | local type Result = res.Result |
diff --git a/src/luarocks/fetch/cvs.tl b/src/luarocks/fetch/cvs.tl index a2f67dcf..0532cecb 100644 --- a/src/luarocks/fetch/cvs.tl +++ b/src/luarocks/fetch/cvs.tl | |||
| @@ -41,8 +41,8 @@ function cvs.get_sources(rockspec: Rockspec, extract: boolean, dest_dir?: string | |||
| 41 | else | 41 | else |
| 42 | store_dir = dest_dir | 42 | store_dir = dest_dir |
| 43 | end | 43 | end |
| 44 | local ok, err = fs.change_dir(store_dir) | 44 | local okchange, err = fs.change_dir(store_dir) |
| 45 | if not ok then return nil, err end | 45 | if not okchange then return nil, err end |
| 46 | if not fs.execute(table.unpack(command)) then | 46 | if not fs.execute(table.unpack(command)) then |
| 47 | return nil, "Failed fetching files from CVS." | 47 | return nil, "Failed fetching files from CVS." |
| 48 | end | 48 | end |
diff --git a/src/luarocks/fetch/svn.tl b/src/luarocks/fetch/svn.tl index 3db136e9..fc4ba2a5 100644 --- a/src/luarocks/fetch/svn.tl +++ b/src/luarocks/fetch/svn.tl | |||
| @@ -43,13 +43,13 @@ function svn.get_sources(rockspec: Rockspec, extract: boolean, dest_dir?: string | |||
| 43 | else | 43 | else |
| 44 | store_dir = dest_dir | 44 | store_dir = dest_dir |
| 45 | end | 45 | end |
| 46 | local ok, err = fs.change_dir(store_dir) | 46 | local okchange, err = fs.change_dir(store_dir) |
| 47 | if not ok then return nil, err end | 47 | if not okchange then return nil, err end |
| 48 | if not fs.execute(table.unpack(command)) then | 48 | if not fs.execute(table.unpack(command)) then |
| 49 | return nil, "Failed fetching files from Subversion." | 49 | return nil, "Failed fetching files from Subversion." |
| 50 | end | 50 | end |
| 51 | ok, err = fs.change_dir(module) | 51 | okchange, err = fs.change_dir(module) |
| 52 | if not ok then return nil, err end | 52 | if not okchange then return nil, err end |
| 53 | for _, d in ipairs(fs.find(".")) do | 53 | for _, d in ipairs(fs.find(".")) do |
| 54 | if dir.base_name(d) == ".svn" then | 54 | if dir.base_name(d) == ".svn" then |
| 55 | fs.delete(dir.path(store_dir, module, d)) | 55 | fs.delete(dir.path(store_dir, module, d)) |
diff --git a/src/luarocks/queries.tl b/src/luarocks/queries.tl index bed7612c..b6e7a392 100644 --- a/src/luarocks/queries.tl +++ b/src/luarocks/queries.tl | |||
| @@ -9,9 +9,9 @@ local cfg = require("luarocks.core.cfg") | |||
| 9 | local type q = require("luarocks.core.types.query") | 9 | local type q = require("luarocks.core.types.query") |
| 10 | local type Query = q.Query | 10 | local type Query = q.Query |
| 11 | 11 | ||
| 12 | local type v = require("luarocks.core.types.version") | 12 | local type ver = require("luarocks.core.types.version") |
| 13 | local type Version = v.Version | 13 | local type Version = ver.Version |
| 14 | local type Constraint = v.Constraint | 14 | local type Constraint = ver.Constraint |
| 15 | 15 | ||
| 16 | local query_mt: metatable<Query> = {} | 16 | local query_mt: metatable<Query> = {} |
| 17 | 17 | ||
diff --git a/src/luarocks/rockspecs-original.lua b/src/luarocks/rockspecs-original.lua deleted file mode 100644 index 454bab77..00000000 --- a/src/luarocks/rockspecs-original.lua +++ /dev/null | |||
| @@ -1,183 +0,0 @@ | |||
| 1 | local rockspecs = {} | ||
| 2 | |||
| 3 | local cfg = require("luarocks.core.cfg") | ||
| 4 | local dir = require("luarocks.dir") | ||
| 5 | local path = require("luarocks.path") | ||
| 6 | local queries = require("luarocks.queries") | ||
| 7 | local type_rockspec = require("luarocks.type.rockspec") | ||
| 8 | local util = require("luarocks.util") | ||
| 9 | local vers = require("luarocks.core.vers") | ||
| 10 | |||
| 11 | local vendored_build_type_set = { | ||
| 12 | ["builtin"] = true, | ||
| 13 | ["cmake"] = true, | ||
| 14 | ["command"] = true, | ||
| 15 | ["make"] = true, | ||
| 16 | ["module"] = true, -- compatibility alias | ||
| 17 | ["none"] = true, | ||
| 18 | } | ||
| 19 | |||
| 20 | local rockspec_mt = {} | ||
| 21 | |||
| 22 | rockspec_mt.__index = rockspec_mt | ||
| 23 | |||
| 24 | function rockspec_mt.type() | ||
| 25 | return "rockspec" | ||
| 26 | end | ||
| 27 | |||
| 28 | --- Perform platform-specific overrides on a table. | ||
| 29 | -- Overrides values of table with the contents of the appropriate | ||
| 30 | -- subset of its "platforms" field. The "platforms" field should | ||
| 31 | -- be a table containing subtables keyed with strings representing | ||
| 32 | -- platform names. Names that match the contents of the global | ||
| 33 | -- detected platforms setting are used. For example, if | ||
| 34 | -- platform "unix" is detected, then the fields of | ||
| 35 | -- tbl.platforms.unix will overwrite those of tbl with the same | ||
| 36 | -- names. For table values, the operation is performed recursively | ||
| 37 | -- (tbl.platforms.foo.x.y.z overrides tbl.x.y.z; other contents of | ||
| 38 | -- tbl.x are preserved). | ||
| 39 | -- @param tbl table or nil: Table which may contain a "platforms" field; | ||
| 40 | -- if it doesn't (or if nil is passed), this function does nothing. | ||
| 41 | local function platform_overrides(tbl) | ||
| 42 | assert(type(tbl) == "table" or not tbl) | ||
| 43 | |||
| 44 | if not tbl then return end | ||
| 45 | |||
| 46 | if tbl.platforms then | ||
| 47 | for platform in cfg.each_platform() do | ||
| 48 | local platform_tbl = tbl.platforms[platform] | ||
| 49 | if platform_tbl then | ||
| 50 | util.deep_merge(tbl, platform_tbl) | ||
| 51 | end | ||
| 52 | end | ||
| 53 | end | ||
| 54 | tbl.platforms = nil | ||
| 55 | end | ||
| 56 | |||
| 57 | local function convert_dependencies(rockspec, key) | ||
| 58 | if rockspec[key] then | ||
| 59 | for i = 1, #rockspec[key] do | ||
| 60 | local parsed, err = queries.from_dep_string(rockspec[key][i]) | ||
| 61 | if not parsed then | ||
| 62 | return nil, "Parse error processing dependency '"..rockspec[key][i].."': "..tostring(err) | ||
| 63 | end | ||
| 64 | rockspec[key][i] = parsed | ||
| 65 | end | ||
| 66 | else | ||
| 67 | rockspec[key] = {} | ||
| 68 | end | ||
| 69 | return true | ||
| 70 | end | ||
| 71 | |||
| 72 | --- Set up path-related variables for a given rock. | ||
| 73 | -- Create a "variables" table in the rockspec table, containing | ||
| 74 | -- adjusted variables according to the configuration file. | ||
| 75 | -- @param rockspec table: The rockspec table. | ||
| 76 | local function configure_paths(rockspec) | ||
| 77 | local vars = {} | ||
| 78 | for k,v in pairs(cfg.variables) do | ||
| 79 | vars[k] = v | ||
| 80 | end | ||
| 81 | local name, version = rockspec.name, rockspec.version | ||
| 82 | vars.PREFIX = path.install_dir(name, version) | ||
| 83 | vars.LUADIR = path.lua_dir(name, version) | ||
| 84 | vars.LIBDIR = path.lib_dir(name, version) | ||
| 85 | vars.CONFDIR = path.conf_dir(name, version) | ||
| 86 | vars.BINDIR = path.bin_dir(name, version) | ||
| 87 | vars.DOCDIR = path.doc_dir(name, version) | ||
| 88 | rockspec.variables = vars | ||
| 89 | end | ||
| 90 | |||
| 91 | function rockspecs.from_persisted_table(filename, rockspec, globals, quick) | ||
| 92 | assert(type(rockspec) == "table") | ||
| 93 | assert(type(globals) == "table" or globals == nil) | ||
| 94 | assert(type(filename) == "string") | ||
| 95 | assert(type(quick) == "boolean" or quick == nil) | ||
| 96 | |||
| 97 | if rockspec.rockspec_format then | ||
| 98 | if vers.compare_versions(rockspec.rockspec_format, type_rockspec.rockspec_format) then | ||
| 99 | return nil, "Rockspec format "..rockspec.rockspec_format.." is not supported, please upgrade LuaRocks." | ||
| 100 | end | ||
| 101 | end | ||
| 102 | |||
| 103 | if not quick then | ||
| 104 | local ok, err = type_rockspec.check(rockspec, globals or {}) | ||
| 105 | if not ok then | ||
| 106 | return nil, err | ||
| 107 | end | ||
| 108 | end | ||
| 109 | |||
| 110 | --- Check if rockspec format version satisfies version requirement. | ||
| 111 | -- @param rockspec table: The rockspec table. | ||
| 112 | -- @param version string: required version. | ||
| 113 | -- @return boolean: true if rockspec format matches version or is newer, false otherwise. | ||
| 114 | do | ||
| 115 | local parsed_format = vers.parse_version(rockspec.rockspec_format or "1.0") | ||
| 116 | rockspec.format_is_at_least = function(self, version) | ||
| 117 | return parsed_format >= vers.parse_version(version) | ||
| 118 | end | ||
| 119 | end | ||
| 120 | |||
| 121 | platform_overrides(rockspec.build) | ||
| 122 | platform_overrides(rockspec.dependencies) | ||
| 123 | platform_overrides(rockspec.build_dependencies) | ||
| 124 | platform_overrides(rockspec.test_dependencies) | ||
| 125 | platform_overrides(rockspec.external_dependencies) | ||
| 126 | platform_overrides(rockspec.source) | ||
| 127 | platform_overrides(rockspec.hooks) | ||
| 128 | platform_overrides(rockspec.test) | ||
| 129 | |||
| 130 | rockspec.name = rockspec.package:lower() | ||
| 131 | |||
| 132 | local protocol, pathname = dir.split_url(rockspec.source.url) | ||
| 133 | if dir.is_basic_protocol(protocol) then | ||
| 134 | rockspec.source.file = rockspec.source.file or dir.base_name(rockspec.source.url) | ||
| 135 | end | ||
| 136 | rockspec.source.protocol, rockspec.source.pathname = protocol, pathname | ||
| 137 | |||
| 138 | -- Temporary compatibility | ||
| 139 | if rockspec.source.cvs_module then rockspec.source.module = rockspec.source.cvs_module end | ||
| 140 | if rockspec.source.cvs_tag then rockspec.source.tag = rockspec.source.cvs_tag end | ||
| 141 | |||
| 142 | rockspec.local_abs_filename = filename | ||
| 143 | rockspec.source.dir_set = rockspec.source.dir ~= nil | ||
| 144 | rockspec.source.dir = rockspec.source.dir or rockspec.source.module | ||
| 145 | |||
| 146 | rockspec.rocks_provided = util.get_rocks_provided(rockspec) | ||
| 147 | |||
| 148 | for _, key in ipairs({"dependencies", "build_dependencies", "test_dependencies"}) do | ||
| 149 | local ok, err = convert_dependencies(rockspec, key) | ||
| 150 | if not ok then | ||
| 151 | return nil, err | ||
| 152 | end | ||
| 153 | end | ||
| 154 | |||
| 155 | if rockspec.build | ||
| 156 | and rockspec.build.type | ||
| 157 | and not vendored_build_type_set[rockspec.build.type] then | ||
| 158 | local build_pkg_name = "luarocks-build-" .. rockspec.build.type | ||
| 159 | if not rockspec.build_dependencies then | ||
| 160 | rockspec.build_dependencies = {} | ||
| 161 | end | ||
| 162 | |||
| 163 | local found = false | ||
| 164 | for _, dep in ipairs(rockspec.build_dependencies) do | ||
| 165 | if dep.name == build_pkg_name then | ||
| 166 | found = true | ||
| 167 | break | ||
| 168 | end | ||
| 169 | end | ||
| 170 | |||
| 171 | if not found then | ||
| 172 | table.insert(rockspec.build_dependencies, queries.from_dep_string(build_pkg_name)) | ||
| 173 | end | ||
| 174 | end | ||
| 175 | |||
| 176 | if not quick then | ||
| 177 | configure_paths(rockspec) | ||
| 178 | end | ||
| 179 | |||
| 180 | return setmetatable(rockspec, rockspec_mt) | ||
| 181 | end | ||
| 182 | |||
| 183 | return rockspecs | ||
diff --git a/src/luarocks/rockspecs.lua b/src/luarocks/rockspecs.lua index 559a874a..454bab77 100644 --- a/src/luarocks/rockspecs.lua +++ b/src/luarocks/rockspecs.lua | |||
| @@ -1,5 +1,4 @@ | |||
| 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 pairs = _tl_compat and _tl_compat.pairs or pairs; local table = _tl_compat and _tl_compat.table or table; local rockspecs = {} | 1 | local rockspecs = {} |
| 2 | |||
| 3 | 2 | ||
| 4 | local cfg = require("luarocks.core.cfg") | 3 | local cfg = require("luarocks.core.cfg") |
| 5 | local dir = require("luarocks.dir") | 4 | local dir = require("luarocks.dir") |
| @@ -9,53 +8,45 @@ local type_rockspec = require("luarocks.type.rockspec") | |||
| 9 | local util = require("luarocks.util") | 8 | local util = require("luarocks.util") |
| 10 | local vers = require("luarocks.core.vers") | 9 | local vers = require("luarocks.core.vers") |
| 11 | 10 | ||
| 12 | local r = require("luarocks.core.types.rockspec") | ||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | local vendored_build_type_set = { | 11 | local vendored_build_type_set = { |
| 20 | ["builtin"] = true, | 12 | ["builtin"] = true, |
| 21 | ["cmake"] = true, | 13 | ["cmake"] = true, |
| 22 | ["command"] = true, | 14 | ["command"] = true, |
| 23 | ["make"] = true, | 15 | ["make"] = true, |
| 24 | ["module"] = true, | 16 | ["module"] = true, -- compatibility alias |
| 25 | ["none"] = true, | 17 | ["none"] = true, |
| 26 | } | 18 | } |
| 27 | 19 | ||
| 28 | local rockspec_mt = {} | 20 | local rockspec_mt = {} |
| 29 | 21 | ||
| 30 | rockspec_mt.__index = r.Rockspec | 22 | rockspec_mt.__index = rockspec_mt |
| 31 | 23 | ||
| 32 | function r.Rockspec.type() | 24 | function rockspec_mt.type() |
| 33 | return "rockspec" | 25 | return "rockspec" |
| 34 | end | 26 | end |
| 35 | 27 | ||
| 36 | 28 | --- Perform platform-specific overrides on a table. | |
| 37 | 29 | -- Overrides values of table with the contents of the appropriate | |
| 38 | 30 | -- subset of its "platforms" field. The "platforms" field should | |
| 39 | 31 | -- be a table containing subtables keyed with strings representing | |
| 40 | 32 | -- platform names. Names that match the contents of the global | |
| 41 | 33 | -- detected platforms setting are used. For example, if | |
| 42 | 34 | -- platform "unix" is detected, then the fields of | |
| 43 | 35 | -- tbl.platforms.unix will overwrite those of tbl with the same | |
| 44 | 36 | -- names. For table values, the operation is performed recursively | |
| 45 | 37 | -- (tbl.platforms.foo.x.y.z overrides tbl.x.y.z; other contents of | |
| 46 | 38 | -- tbl.x are preserved). | |
| 47 | 39 | -- @param tbl table or nil: Table which may contain a "platforms" field; | |
| 48 | 40 | -- if it doesn't (or if nil is passed), this function does nothing. | |
| 49 | local function platform_overrides(tbl) | 41 | local function platform_overrides(tbl) |
| 42 | assert(type(tbl) == "table" or not tbl) | ||
| 50 | 43 | ||
| 51 | if not tbl then return end | 44 | if not tbl then return end |
| 52 | 45 | ||
| 53 | local tblp = tbl.platforms | 46 | if tbl.platforms then |
| 54 | |||
| 55 | if type(tblp) == "table" then | ||
| 56 | for platform in cfg.each_platform() do | 47 | for platform in cfg.each_platform() do |
| 57 | local platform_tbl = tblp[platform] | 48 | local platform_tbl = tbl.platforms[platform] |
| 58 | if type(platform_tbl) == "table" then | 49 | if platform_tbl then |
| 59 | util.deep_merge(tbl, platform_tbl) | 50 | util.deep_merge(tbl, platform_tbl) |
| 60 | end | 51 | end |
| 61 | end | 52 | end |
| @@ -63,28 +54,28 @@ local function platform_overrides(tbl) | |||
| 63 | tbl.platforms = nil | 54 | tbl.platforms = nil |
| 64 | end | 55 | end |
| 65 | 56 | ||
| 66 | local function convert_dependencies(dependencies) | 57 | local function convert_dependencies(rockspec, key) |
| 67 | if not dependencies then | 58 | if rockspec[key] then |
| 68 | return {} | 59 | for i = 1, #rockspec[key] do |
| 69 | end | 60 | local parsed, err = queries.from_dep_string(rockspec[key][i]) |
| 70 | local qs = {} | 61 | if not parsed then |
| 71 | for i = 1, #dependencies do | 62 | return nil, "Parse error processing dependency '"..rockspec[key][i].."': "..tostring(err) |
| 72 | local parsed, err = queries.from_dep_string(dependencies[i]) | 63 | end |
| 73 | if not parsed then | 64 | rockspec[key][i] = parsed |
| 74 | return nil, "Parse error processing dependency '" .. dependencies[i] .. "': " .. tostring(err) | ||
| 75 | end | 65 | end |
| 76 | qs[i] = parsed | 66 | else |
| 67 | rockspec[key] = {} | ||
| 77 | end | 68 | end |
| 78 | return qs | 69 | return true |
| 79 | end | 70 | end |
| 80 | 71 | ||
| 81 | 72 | --- Set up path-related variables for a given rock. | |
| 82 | 73 | -- Create a "variables" table in the rockspec table, containing | |
| 83 | 74 | -- adjusted variables according to the configuration file. | |
| 84 | 75 | -- @param rockspec table: The rockspec table. | |
| 85 | local function configure_paths(rockspec) | 76 | local function configure_paths(rockspec) |
| 86 | local vars = {} | 77 | local vars = {} |
| 87 | for k, v in pairs(cfg.variables) do | 78 | for k,v in pairs(cfg.variables) do |
| 88 | vars[k] = v | 79 | vars[k] = v |
| 89 | end | 80 | end |
| 90 | local name, version = rockspec.name, rockspec.version | 81 | local name, version = rockspec.name, rockspec.version |
| @@ -98,10 +89,14 @@ local function configure_paths(rockspec) | |||
| 98 | end | 89 | end |
| 99 | 90 | ||
| 100 | function rockspecs.from_persisted_table(filename, rockspec, globals, quick) | 91 | function rockspecs.from_persisted_table(filename, rockspec, globals, quick) |
| 92 | assert(type(rockspec) == "table") | ||
| 93 | assert(type(globals) == "table" or globals == nil) | ||
| 94 | assert(type(filename) == "string") | ||
| 95 | assert(type(quick) == "boolean" or quick == nil) | ||
| 101 | 96 | ||
| 102 | if rockspec.rockspec_format then | 97 | if rockspec.rockspec_format then |
| 103 | if vers.compare_versions(rockspec.rockspec_format, type_rockspec.rockspec_format) then | 98 | if vers.compare_versions(rockspec.rockspec_format, type_rockspec.rockspec_format) then |
| 104 | return nil, "Rockspec format " .. rockspec.rockspec_format .. " is not supported, please upgrade LuaRocks." | 99 | return nil, "Rockspec format "..rockspec.rockspec_format.." is not supported, please upgrade LuaRocks." |
| 105 | end | 100 | end |
| 106 | end | 101 | end |
| 107 | 102 | ||
| @@ -112,10 +107,10 @@ function rockspecs.from_persisted_table(filename, rockspec, globals, quick) | |||
| 112 | end | 107 | end |
| 113 | end | 108 | end |
| 114 | 109 | ||
| 115 | 110 | --- Check if rockspec format version satisfies version requirement. | |
| 116 | 111 | -- @param rockspec table: The rockspec table. | |
| 117 | 112 | -- @param version string: required version. | |
| 118 | 113 | -- @return boolean: true if rockspec format matches version or is newer, false otherwise. | |
| 119 | do | 114 | do |
| 120 | local parsed_format = vers.parse_version(rockspec.rockspec_format or "1.0") | 115 | local parsed_format = vers.parse_version(rockspec.rockspec_format or "1.0") |
| 121 | rockspec.format_is_at_least = function(self, version) | 116 | rockspec.format_is_at_least = function(self, version) |
| @@ -140,7 +135,7 @@ function rockspecs.from_persisted_table(filename, rockspec, globals, quick) | |||
| 140 | end | 135 | end |
| 141 | rockspec.source.protocol, rockspec.source.pathname = protocol, pathname | 136 | rockspec.source.protocol, rockspec.source.pathname = protocol, pathname |
| 142 | 137 | ||
| 143 | 138 | -- Temporary compatibility | |
| 144 | if rockspec.source.cvs_module then rockspec.source.module = rockspec.source.cvs_module end | 139 | if rockspec.source.cvs_module then rockspec.source.module = rockspec.source.cvs_module end |
| 145 | if rockspec.source.cvs_tag then rockspec.source.tag = rockspec.source.cvs_tag end | 140 | if rockspec.source.cvs_tag then rockspec.source.tag = rockspec.source.cvs_tag end |
| 146 | 141 | ||
| @@ -150,32 +145,23 @@ function rockspecs.from_persisted_table(filename, rockspec, globals, quick) | |||
| 150 | 145 | ||
| 151 | rockspec.rocks_provided = util.get_rocks_provided(rockspec) | 146 | rockspec.rocks_provided = util.get_rocks_provided(rockspec) |
| 152 | 147 | ||
| 153 | local err | 148 | for _, key in ipairs({"dependencies", "build_dependencies", "test_dependencies"}) do |
| 154 | rockspec.dependencies.queries, err = convert_dependencies(rockspec.dependencies) | 149 | local ok, err = convert_dependencies(rockspec, key) |
| 155 | if err then | 150 | if not ok then |
| 156 | return nil, err | 151 | return nil, err |
| 157 | end | 152 | end |
| 158 | |||
| 159 | rockspec.build_dependencies.queries, err = convert_dependencies(rockspec.build_dependencies) | ||
| 160 | if err then | ||
| 161 | return nil, err | ||
| 162 | end | ||
| 163 | |||
| 164 | rockspec.test_dependencies.queries, err = convert_dependencies(rockspec.test_dependencies) | ||
| 165 | if err then | ||
| 166 | return nil, err | ||
| 167 | end | 153 | end |
| 168 | 154 | ||
| 169 | if rockspec.build and | 155 | if rockspec.build |
| 170 | rockspec.build.type and | 156 | and rockspec.build.type |
| 171 | not vendored_build_type_set[rockspec.build.type] then | 157 | and not vendored_build_type_set[rockspec.build.type] then |
| 172 | local build_pkg_name = "luarocks-build-" .. rockspec.build.type | 158 | local build_pkg_name = "luarocks-build-" .. rockspec.build.type |
| 173 | if not rockspec.build_dependencies then | 159 | if not rockspec.build_dependencies then |
| 174 | rockspec.build_dependencies = {} | 160 | rockspec.build_dependencies = {} |
| 175 | end | 161 | end |
| 176 | 162 | ||
| 177 | local found = false | 163 | local found = false |
| 178 | for _, dep in ipairs(rockspec.build_dependencies.queries) do | 164 | for _, dep in ipairs(rockspec.build_dependencies) do |
| 179 | if dep.name == build_pkg_name then | 165 | if dep.name == build_pkg_name then |
| 180 | found = true | 166 | found = true |
| 181 | break | 167 | break |
| @@ -183,11 +169,7 @@ function rockspecs.from_persisted_table(filename, rockspec, globals, quick) | |||
| 183 | end | 169 | end |
| 184 | 170 | ||
| 185 | if not found then | 171 | if not found then |
| 186 | local query, err = queries.from_dep_string(build_pkg_name) | 172 | table.insert(rockspec.build_dependencies, queries.from_dep_string(build_pkg_name)) |
| 187 | if err then | ||
| 188 | return nil, "Invalid dependency in rockspec: " .. err | ||
| 189 | end | ||
| 190 | table.insert(rockspec.build_dependencies.queries, query) | ||
| 191 | end | 173 | end |
| 192 | end | 174 | end |
| 193 | 175 | ||
diff --git a/src/luarocks/rockspecs.tl b/src/luarocks/rockspecs.tl index 3ea6c147..b65227da 100644 --- a/src/luarocks/rockspecs.tl +++ b/src/luarocks/rockspecs.tl | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | |||
| 1 | local record rockspecs | 2 | local record rockspecs |
| 2 | end | 3 | end |
| 3 | 4 | ||
| @@ -183,8 +184,8 @@ function rockspecs.from_persisted_table(filename: string, rockspec: Rockspec, gl | |||
| 183 | end | 184 | end |
| 184 | 185 | ||
| 185 | if not found then | 186 | if not found then |
| 186 | local query, err = queries.from_dep_string(build_pkg_name) | 187 | local query, errfromdep = queries.from_dep_string(build_pkg_name) |
| 187 | if err then | 188 | if errfromdep then |
| 188 | return nil, "Invalid dependency in rockspec: " .. err | 189 | return nil, "Invalid dependency in rockspec: " .. err |
| 189 | end | 190 | end |
| 190 | table.insert(rockspec.build_dependencies.queries, query) | 191 | table.insert(rockspec.build_dependencies.queries, query) |
diff --git a/src/luarocks/search.tl b/src/luarocks/search.tl index 7d8a9055..caf01221 100644 --- a/src/luarocks/search.tl +++ b/src/luarocks/search.tl | |||
| @@ -15,8 +15,8 @@ local type Result = r.Result | |||
| 15 | local type q = require("luarocks.core.types.query") | 15 | local type q = require("luarocks.core.types.query") |
| 16 | local type Query = q.Query | 16 | local type Query = q.Query |
| 17 | 17 | ||
| 18 | local type v = require("luarocks.core.types.version") | 18 | local type ver = require("luarocks.core.types.version") |
| 19 | local type Version = v.Version | 19 | local type Version = ver.Version |
| 20 | 20 | ||
| 21 | local type t = require("luarocks.core.types.tree") | 21 | local type t = require("luarocks.core.types.tree") |
| 22 | local type Tree = t.Tree | 22 | local type Tree = t.Tree |
diff --git a/src/luarocks/tools/patch.tl b/src/luarocks/tools/patch.tl index a5d67e18..f204cd63 100644 --- a/src/luarocks/tools/patch.tl +++ b/src/luarocks/tools/patch.tl | |||
| @@ -465,7 +465,7 @@ end | |||
| 465 | 465 | ||
| 466 | local function check_patched(file: {string}, hunks: {Hunk}): boolean | 466 | local function check_patched(file: {string}, hunks: {Hunk}): boolean |
| 467 | local lineno: integer = 1 | 467 | local lineno: integer = 1 |
| 468 | local ok, err: boolean, string = pcall(function() | 468 | local _, err: boolean, string = pcall(function() |
| 469 | if #file == 0 then | 469 | if #file == 0 then |
| 470 | error('nomatch', 0) | 470 | error('nomatch', 0) |
| 471 | end | 471 | end |
diff --git a/src/luarocks/upload/api.tl b/src/luarocks/upload/api.tl index 6863f6f0..4ea9f922 100644 --- a/src/luarocks/upload/api.tl +++ b/src/luarocks/upload/api.tl | |||
| @@ -35,6 +35,9 @@ local type Args = api.Args | |||
| 35 | local type Configuration = api.Configuration | 35 | local type Configuration = api.Configuration |
| 36 | local type File = multipart.File | 36 | local type File = multipart.File |
| 37 | 37 | ||
| 38 | local type p = require("luarocks.core.types.persist") | ||
| 39 | local type PersistableTable = p.PersistableTable | ||
| 40 | |||
| 38 | local function upload_config_file(): string | 41 | local function upload_config_file(): string |
| 39 | if not cfg.config_files.user.file then | 42 | if not cfg.config_files.user.file then |
| 40 | return nil | 43 | return nil |
| @@ -284,7 +287,7 @@ function api.Api:save_config(): boolean, string --! nil? | |||
| 284 | if not ok then | 287 | if not ok then |
| 285 | return nil, errmake | 288 | return nil, errmake |
| 286 | end | 289 | end |
| 287 | persist.save_from_table(upload_conf, self.config as persist.PersistableTable) | 290 | persist.save_from_table(upload_conf, self.config as PersistableTable) |
| 288 | fs.set_permissions(upload_conf, "read", "user") | 291 | fs.set_permissions(upload_conf, "read", "user") |
| 289 | return true | 292 | return true |
| 290 | end | 293 | end |
