diff options
Diffstat (limited to 'src/luarocks/deps.lua')
-rw-r--r-- | src/luarocks/deps.lua | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 00e796b0..6d5f3fef 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
@@ -312,14 +312,14 @@ end | |||
312 | -- @return table or nil: A table containing fields 'name' and 'version' | 312 | -- @return table or nil: A table containing fields 'name' and 'version' |
313 | -- representing an installed rock which matches the given dependency, | 313 | -- representing an installed rock which matches the given dependency, |
314 | -- or nil if it could not be matched. | 314 | -- or nil if it could not be matched. |
315 | local function match_dep(dep, blacklist) | 315 | local function match_dep(dep, blacklist, deps_mode) |
316 | assert(type(dep) == "table") | 316 | assert(type(dep) == "table") |
317 | 317 | ||
318 | local versions | 318 | local versions |
319 | if dep.name == "lua" then | 319 | if dep.name == "lua" then |
320 | versions = { cfg.lua_version } | 320 | versions = { cfg.lua_version } |
321 | else | 321 | else |
322 | versions = manif_core.get_versions(dep.name) | 322 | versions = manif_core.get_versions(dep.name, deps_mode) |
323 | end | 323 | end |
324 | if not versions then | 324 | if not versions then |
325 | return nil | 325 | return nil |
@@ -361,13 +361,13 @@ end | |||
361 | -- in table format and values are tables containing fields 'name' and | 361 | -- in table format and values are tables containing fields 'name' and |
362 | -- version' representing matches, and a table of missing dependencies | 362 | -- version' representing matches, and a table of missing dependencies |
363 | -- parsed as tables. | 363 | -- parsed as tables. |
364 | function match_deps(rockspec, blacklist) | 364 | function match_deps(rockspec, blacklist, deps_mode) |
365 | assert(type(rockspec) == "table") | 365 | assert(type(rockspec) == "table") |
366 | assert(type(blacklist) == "table" or not blacklist) | 366 | assert(type(blacklist) == "table" or not blacklist) |
367 | local matched, missing, no_upgrade = {}, {}, {} | 367 | local matched, missing, no_upgrade = {}, {}, {} |
368 | 368 | ||
369 | for _, dep in ipairs(rockspec.dependencies) do | 369 | for _, dep in ipairs(rockspec.dependencies) do |
370 | local found = match_dep(dep, blacklist and blacklist[dep.name] or nil) | 370 | local found = match_dep(dep, blacklist and blacklist[dep.name] or nil, deps_mode) |
371 | if found then | 371 | if found then |
372 | if dep.name ~= "lua" then | 372 | if dep.name ~= "lua" then |
373 | matched[dep] = found | 373 | matched[dep] = found |
@@ -401,7 +401,7 @@ end | |||
401 | -- @return boolean or (nil, string, [string]): True if no errors occurred, or | 401 | -- @return boolean or (nil, string, [string]): True if no errors occurred, or |
402 | -- nil and an error message if any test failed, followed by an optional | 402 | -- nil and an error message if any test failed, followed by an optional |
403 | -- error code. | 403 | -- error code. |
404 | function fulfill_dependencies(rockspec) | 404 | function fulfill_dependencies(rockspec, deps_mode) |
405 | 405 | ||
406 | local search = require("luarocks.search") | 406 | local search = require("luarocks.search") |
407 | local install = require("luarocks.install") | 407 | local install = require("luarocks.install") |
@@ -433,7 +433,7 @@ function fulfill_dependencies(rockspec) | |||
433 | end | 433 | end |
434 | end | 434 | end |
435 | 435 | ||
436 | local matched, missing, no_upgrade = match_deps(rockspec) | 436 | local matched, missing, no_upgrade = match_deps(rockspec, nil, deps_mode) |
437 | 437 | ||
438 | if next(no_upgrade) then | 438 | if next(no_upgrade) then |
439 | util.printerr("Missing dependencies for "..rockspec.name.." "..rockspec.version..":") | 439 | util.printerr("Missing dependencies for "..rockspec.name.." "..rockspec.version..":") |
@@ -467,7 +467,7 @@ function fulfill_dependencies(rockspec) | |||
467 | 467 | ||
468 | for _, dep in pairs(missing) do | 468 | for _, dep in pairs(missing) do |
469 | -- Double-check in case dependency was filled during recursion. | 469 | -- Double-check in case dependency was filled during recursion. |
470 | if not match_dep(dep) then | 470 | if not match_dep(dep, nil, deps_mode) then |
471 | local rock = search.find_suitable_rock(dep) | 471 | local rock = search.find_suitable_rock(dep) |
472 | if not rock then | 472 | if not rock then |
473 | return nil, "Could not satisfy dependency: "..show_dep(dep) | 473 | return nil, "Could not satisfy dependency: "..show_dep(dep) |
@@ -640,7 +640,7 @@ end | |||
640 | -- @param name string: Package name. | 640 | -- @param name string: Package name. |
641 | -- @param version string: Package version. | 641 | -- @param version string: Package version. |
642 | -- @return (table, table): The results and a table of missing dependencies. | 642 | -- @return (table, table): The results and a table of missing dependencies. |
643 | function scan_deps(results, missing, manifest, name, version) | 643 | function scan_deps(results, missing, manifest, name, version, deps_mode) |
644 | assert(type(results) == "table") | 644 | assert(type(results) == "table") |
645 | assert(type(missing) == "table") | 645 | assert(type(missing) == "table") |
646 | assert(type(manifest) == "table") | 646 | assert(type(manifest) == "table") |
@@ -669,9 +669,9 @@ function scan_deps(results, missing, manifest, name, version) | |||
669 | else | 669 | else |
670 | rockspec = { dependencies = deplist } | 670 | rockspec = { dependencies = deplist } |
671 | end | 671 | end |
672 | local matched, failures = match_deps(rockspec) | 672 | local matched, failures = match_deps(rockspec, nil, deps_mode) |
673 | for _, match in pairs(matched) do | 673 | for _, match in pairs(matched) do |
674 | results, missing = scan_deps(results, missing, manifest, match.name, match.version) | 674 | results, missing = scan_deps(results, missing, manifest, match.name, match.version, deps_mode) |
675 | end | 675 | end |
676 | if next(failures) then | 676 | if next(failures) then |
677 | for _, failure in pairs(failures) do | 677 | for _, failure in pairs(failures) do |
@@ -681,3 +681,26 @@ function scan_deps(results, missing, manifest, name, version) | |||
681 | results[name] = version | 681 | results[name] = version |
682 | return results, missing | 682 | return results, missing |
683 | end | 683 | end |
684 | |||
685 | local valid_deps_modes = { | ||
686 | one = true, | ||
687 | order = true, | ||
688 | all = true, | ||
689 | none = true, | ||
690 | } | ||
691 | |||
692 | function check_deps_mode_flag(flag) | ||
693 | return valid_deps_modes[flag] | ||
694 | end | ||
695 | |||
696 | function get_deps_mode(flags) | ||
697 | if flags["deps-mode"] then | ||
698 | return flags["deps-mode"] | ||
699 | else | ||
700 | return cfg.deps_mode | ||
701 | end | ||
702 | end | ||
703 | |||
704 | function deps_mode_to_flag(deps_mode) | ||
705 | return "--deps-mode="..deps_mode | ||
706 | end | ||