diff options
Diffstat (limited to 'src/luarocks/deps.lua')
-rw-r--r-- | src/luarocks/deps.lua | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 7e7b69e6..1457224e 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
@@ -14,7 +14,8 @@ local builtin = require("luarocks.build.builtin") | |||
14 | local deplocks = require("luarocks.deplocks") | 14 | local deplocks = require("luarocks.deplocks") |
15 | 15 | ||
16 | --- Generate a function that matches dep queries against the manifest, | 16 | --- Generate a function that matches dep queries against the manifest, |
17 | -- taking into account rocks_provided, the blacklist and the lockfile. | 17 | -- taking into account rocks_provided, the list of versions to skip, |
18 | -- and the lockfile. | ||
18 | -- @param deps_mode "one", "none", "all" or "order" | 19 | -- @param deps_mode "one", "none", "all" or "order" |
19 | -- @param rocks_provided a one-level table mapping names to versions, | 20 | -- @param rocks_provided a one-level table mapping names to versions, |
20 | -- listing rocks to consider provided by the VM | 21 | -- listing rocks to consider provided by the VM |
@@ -22,18 +23,18 @@ local deplocks = require("luarocks.deplocks") | |||
22 | -- by this Lua implementation for the given dependency. | 23 | -- by this Lua implementation for the given dependency. |
23 | -- @param depskey key to use when matching the lockfile ("dependencies", | 24 | -- @param depskey key to use when matching the lockfile ("dependencies", |
24 | -- "build_dependencies", etc.) | 25 | -- "build_dependencies", etc.) |
25 | -- @param blacklist a two-level table mapping names to versions to boolean, | 26 | -- @param skip_set a two-level table mapping names to versions to |
26 | -- listing rocks to not match | 27 | -- boolean, listing rocks that should not be matched |
27 | -- @return function(dep): {string}, {string:string}, string, boolean | 28 | -- @return function(dep): {string}, {string:string}, string, boolean |
28 | -- * array of matching versions | 29 | -- * array of matching versions |
29 | -- * map of versions to locations | 30 | -- * map of versions to locations |
30 | -- * version matched via lockfile if any | 31 | -- * version matched via lockfile if any |
31 | -- * true if rock matched via rocks_provided | 32 | -- * true if rock matched via rocks_provided |
32 | local function prepare_get_versions(deps_mode, rocks_provided, depskey, blacklist) | 33 | local function prepare_get_versions(deps_mode, rocks_provided, depskey, skip_set) |
33 | assert(type(deps_mode) == "string") | 34 | assert(type(deps_mode) == "string") |
34 | assert(type(rocks_provided) == "table") | 35 | assert(type(rocks_provided) == "table") |
35 | assert(type(depskey) == "string") | 36 | assert(type(depskey) == "string") |
36 | assert(type(blacklist) == "table" or blacklist == nil) | 37 | assert(type(skip_set) == "table" or skip_set == nil) |
37 | 38 | ||
38 | return function(dep) | 39 | return function(dep) |
39 | local versions, locations | 40 | local versions, locations |
@@ -48,12 +49,11 @@ local function prepare_get_versions(deps_mode, rocks_provided, depskey, blacklis | |||
48 | versions, locations = manif.get_versions(dep, deps_mode) | 49 | versions, locations = manif.get_versions(dep, deps_mode) |
49 | end | 50 | end |
50 | 51 | ||
51 | if blacklist and blacklist[dep.name] then | 52 | if skip_set and skip_set[dep.name] then |
52 | local orig_versions = versions | 53 | for i = #versions, 1, -1 do |
53 | versions = {} | 54 | local v = versions[i] |
54 | for _, v in ipairs(orig_versions) do | 55 | if skip_set[dep.name][v] then |
55 | if not blacklist[dep.name][v] then | 56 | table.remove(versions, i) |
56 | table.insert(versions, v) | ||
57 | end | 57 | end |
58 | end | 58 | end |
59 | end | 59 | end |
@@ -65,8 +65,6 @@ local function prepare_get_versions(deps_mode, rocks_provided, depskey, blacklis | |||
65 | end | 65 | end |
66 | 66 | ||
67 | --- Attempt to match a dependency to an installed rock. | 67 | --- Attempt to match a dependency to an installed rock. |
68 | -- @param blacklist table: Versions that can't be accepted. Table where keys | ||
69 | -- are program versions and values are 'true'. | ||
70 | -- @param get_versions a getter function obtained via prepare_get_versions | 68 | -- @param get_versions a getter function obtained via prepare_get_versions |
71 | -- @return (string, string, table) or (nil, nil, table): | 69 | -- @return (string, string, table) or (nil, nil, table): |
72 | -- 1. latest installed version of the rock matching the dependency | 70 | -- 1. latest installed version of the rock matching the dependency |
@@ -135,7 +133,7 @@ end | |||
135 | --- Attempt to match dependencies of a rockspec to installed rocks. | 133 | --- Attempt to match dependencies of a rockspec to installed rocks. |
136 | -- @param dependencies table: The table of dependencies. | 134 | -- @param dependencies table: The table of dependencies. |
137 | -- @param rocks_provided table: The table of auto-provided dependencies. | 135 | -- @param rocks_provided table: The table of auto-provided dependencies. |
138 | -- @param blacklist table or nil: Program versions to not use as valid matches. | 136 | -- @param skip_set table or nil: Program versions to not use as valid matches. |
139 | -- Table where keys are program names and values are tables where keys | 137 | -- Table where keys are program names and values are tables where keys |
140 | -- are program versions and values are 'true'. | 138 | -- are program versions and values are 'true'. |
141 | -- @param deps_mode string: Which trees to check dependencies for | 139 | -- @param deps_mode string: Which trees to check dependencies for |
@@ -145,13 +143,13 @@ end | |||
145 | -- parsed as tables; and a table of "no-upgrade" missing dependencies | 143 | -- parsed as tables; and a table of "no-upgrade" missing dependencies |
146 | -- (to be used in plugin modules so that a plugin does not force upgrade of | 144 | -- (to be used in plugin modules so that a plugin does not force upgrade of |
147 | -- its parent application). | 145 | -- its parent application). |
148 | function deps.match_deps(dependencies, rocks_provided, blacklist, deps_mode) | 146 | function deps.match_deps(dependencies, rocks_provided, skip_set, deps_mode) |
149 | assert(type(dependencies) == "table") | 147 | assert(type(dependencies) == "table") |
150 | assert(type(rocks_provided) == "table") | 148 | assert(type(rocks_provided) == "table") |
151 | assert(type(blacklist) == "table" or blacklist == nil) | 149 | assert(type(skip_set) == "table" or skip_set == nil) |
152 | assert(type(deps_mode) == "string") | 150 | assert(type(deps_mode) == "string") |
153 | 151 | ||
154 | local get_versions = prepare_get_versions(deps_mode, rocks_provided, "dependencies", blacklist) | 152 | local get_versions = prepare_get_versions(deps_mode, rocks_provided, "dependencies", skip_set) |
155 | return match_all_deps(dependencies, get_versions) | 153 | return match_all_deps(dependencies, get_versions) |
156 | end | 154 | end |
157 | 155 | ||
@@ -278,7 +276,8 @@ end | |||
278 | -- Packages are installed using the LuaRocks "install" command. | 276 | -- Packages are installed using the LuaRocks "install" command. |
279 | -- Aborts the program if a dependency could not be fulfilled. | 277 | -- Aborts the program if a dependency could not be fulfilled. |
280 | -- @param rockspec table: A rockspec in table format. | 278 | -- @param rockspec table: A rockspec in table format. |
281 | -- @param depskey string: Rockspec key to fetch to get dependency table. | 279 | -- @param depskey string: Rockspec key to fetch to get dependency table |
280 | -- ("dependencies", "build_dependencies", etc.). | ||
282 | -- @param deps_mode string | 281 | -- @param deps_mode string |
283 | -- @param verify boolean | 282 | -- @param verify boolean |
284 | -- @param deplock_dir string: dirname of the deplock file | 283 | -- @param deplock_dir string: dirname of the deplock file |