aboutsummaryrefslogtreecommitdiff
path: root/src/luarocks/deps.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/luarocks/deps.lua')
-rw-r--r--src/luarocks/deps.lua84
1 files changed, 46 insertions, 38 deletions
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua
index 812e6d18..3c580623 100644
--- a/src/luarocks/deps.lua
+++ b/src/luarocks/deps.lua
@@ -410,6 +410,13 @@ local function values_set(tbl)
410 return set 410 return set
411end 411end
412 412
413local function rock_status(name, deps_mode)
414 local search = require("luarocks.search")
415 local installed = match_dep(search.make_query(name), nil, deps_mode)
416 local installation_type = cfg.rocks_provided[name] and "provided by VM" or "installed"
417 return installed and installed.version.." "..installation_type or "not installed"
418end
419
413--- Check dependencies of a rock and attempt to install any missing ones. 420--- Check dependencies of a rock and attempt to install any missing ones.
414-- Packages are installed using the LuaRocks "install" command. 421-- Packages are installed using the LuaRocks "install" command.
415-- Aborts the program if a dependency could not be fulfilled. 422-- Aborts the program if a dependency could not be fulfilled.
@@ -449,52 +456,53 @@ function deps.fulfill_dependencies(rockspec, deps_mode)
449 end 456 end
450 end 457 end
451 458
452 local _, missing, no_upgrade = deps.match_deps(rockspec, nil, deps_mode) 459 local first_missing_dep = true
453 460
454 if next(no_upgrade) then 461 for _, dep in ipairs(rockspec.dependencies) do
455 util.printerr("Missing dependencies for "..rockspec.name.." "..rockspec.version..":") 462 if not match_dep(dep, nil, deps_mode) then
456 for _, dep in pairs(no_upgrade) do 463 if first_missing_dep then
457 util.printerr(deps.show_dep(dep)) 464 util.printout(("Missing dependencies for %s %s:"):format(rockspec.name, rockspec.version))
458 end 465 first_missing_dep = false
459 if next(missing) then
460 for _, dep in pairs(missing) do
461 util.printerr(deps.show_dep(dep))
462 end 466 end
467
468 util.printout((" %s (%s)"):format(deps.show_dep(dep), rock_status(dep.name, deps_mode)))
463 end 469 end
464 util.printerr()
465 for _, dep in pairs(no_upgrade) do
466 util.printerr("This version of "..rockspec.name.." is designed for use with")
467 util.printerr(deps.show_dep(dep)..", but is configured to avoid upgrading it")
468 util.printerr("automatically. Please upgrade "..dep.name.." with")
469 util.printerr(" luarocks install "..dep.name)
470 util.printerr("or choose an older version of "..rockspec.name.." with")
471 util.printerr(" luarocks search "..rockspec.name)
472 end
473 return nil, "Failed matching dependencies."
474 end 470 end
475 471
476 if next(missing) then 472 first_missing_dep = true
477 util.printerr() 473
478 util.printerr("Missing dependencies for "..rockspec.name..":") 474 for _, dep in ipairs(rockspec.dependencies) do
479 for _, dep in pairs(missing) do 475 if not match_dep(dep, nil, deps_mode) then
480 util.printerr(deps.show_dep(dep)) 476 if first_missing_dep then
481 end 477 util.printout()
482 util.printerr() 478 first_missing_dep = false
483 479 end
484 for _, dep in pairs(missing) do 480
485 -- Double-check in case dependency was filled during recursion. 481 util.printout(("%s %s depends on %s (%s)"):format(
486 if not match_dep(dep, nil, deps_mode) then 482 rockspec.name, rockspec.version, deps.show_dep(dep), rock_status(dep.name, deps_mode)))
487 local url, err = search.find_suitable_rock(dep) 483
488 if not url then 484 if dep.constraints[1] and dep.constraints[1].no_upgrade then
489 return nil, "Could not satisfy dependency "..deps.show_dep(dep)..": "..err 485 util.printerr("This version of "..rockspec.name.." is designed for use with")
490 end 486 util.printerr(deps.show_dep(dep)..", but is configured to avoid upgrading it")
491 local ok, err, errcode = install.run(url, deps.deps_mode_to_flag(deps_mode)) 487 util.printerr("automatically. Please upgrade "..dep.name.." with")
492 if not ok then 488 util.printerr(" luarocks install "..dep.name)
493 return nil, "Failed installing dependency: "..url.." - "..err, errcode 489 util.printerr("or choose an older version of "..rockspec.name.." with")
494 end 490 util.printerr(" luarocks search "..rockspec.name)
491 return nil, "Failed matching dependencies"
492 end
493
494 local url, search_err = search.find_suitable_rock(dep)
495 if not url then
496 return nil, "Could not satisfy dependency "..deps.show_dep(dep)..": "..search_err
497 end
498 util.printout("Installing "..url)
499 local ok, install_err, errcode = install.run(url, deps.deps_mode_to_flag(deps_mode))
500 if not ok then
501 return nil, "Failed installing dependency: "..url.." - "..install_err, errcode
495 end 502 end
496 end 503 end
497 end 504 end
505
498 return true 506 return true
499end 507end
500 508