From a26862545e0eccbbc5fba15edd2a00dedf069a3f Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Tue, 10 May 2016 17:33:44 +0300 Subject: Announce each missing dep before its install Instead of lising all missing deps before installing all of them, announce each missing dep right before installing it. Also show current rock versions for missing deps. --- src/luarocks/deps.lua | 72 ++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 41 deletions(-) diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index ac294f54..73eab2c2 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua @@ -449,53 +449,43 @@ function deps.fulfill_dependencies(rockspec, deps_mode) end end - local _, missing, no_upgrade = deps.match_deps(rockspec, nil, deps_mode) + local first_missing_dep = true - if next(no_upgrade) then - util.printerr("Missing dependencies for "..rockspec.name.." "..rockspec.version..":") - for _, dep in pairs(no_upgrade) do - util.printerr(deps.show_dep(dep)) - end - if next(missing) then - for _, dep in pairs(missing) do - util.printerr(deps.show_dep(dep)) + for _, dep in ipairs(rockspec.dependencies) do + if not match_dep(dep, nil, deps_mode) then + if first_missing_dep then + util.printout() + first_missing_dep = false end - end - util.printerr() - for _, dep in pairs(no_upgrade) do - util.printerr("This version of "..rockspec.name.." is designed for use with") - util.printerr(deps.show_dep(dep)..", but is configured to avoid upgrading it") - util.printerr("automatically. Please upgrade "..dep.name.." with") - util.printerr(" luarocks install "..dep.name) - util.printerr("or choose an older version of "..rockspec.name.." with") - util.printerr(" luarocks search "..rockspec.name) - end - return nil, "Failed matching dependencies." - end - if next(missing) then - util.printerr() - util.printerr("Missing dependencies for "..rockspec.name..":") - for _, dep in pairs(missing) do - util.printerr(deps.show_dep(dep)) - end - util.printerr() - - for _, dep in pairs(missing) do - -- Double-check in case dependency was filled during recursion. - if not match_dep(dep, nil, deps_mode) then - local url, err = search.find_suitable_rock(dep) - if not url then - return nil, "Could not satisfy dependency "..deps.show_dep(dep)..": "..err - end - util.printout("Installing "..url) - local ok, err, errcode = install.run(url, deps.deps_mode_to_flag(deps_mode)) - if not ok then - return nil, "Failed installing dependency: "..url.." - "..err, errcode - end + local any_installed = match_dep(search.make_query(dep.name), nil, deps_mode) + local installation_type = cfg.rocks_provided[dep.name] and "provided by VM" or "installed" + local status = any_installed and any_installed.version.." "..installation_type or "missing" + util.printout(("%s %s depends on %s (%s)"):format( + rockspec.name, rockspec.version, deps.show_dep(dep), status)) + + if dep.constraints[1] and dep.constraints[1].no_upgrade then + util.printerr("This version of "..rockspec.name.." is designed for use with") + util.printerr(deps.show_dep(dep)..", but is configured to avoid upgrading it") + util.printerr("automatically. Please upgrade "..dep.name.." with") + util.printerr(" luarocks install "..dep.name) + util.printerr("or choose an older version of "..rockspec.name.." with") + util.printerr(" luarocks search "..rockspec.name) + return nil, "Failed matching dependencies" + end + + local url, search_err = search.find_suitable_rock(dep) + if not url then + return nil, "Could not satisfy dependency "..deps.show_dep(dep)..": "..search_err + end + util.printout("Installing "..url) + local ok, install_err, errcode = install.run(url, deps.deps_mode_to_flag(deps_mode)) + if not ok then + return nil, "Failed installing dependency: "..url.." - "..install_err, errcode end end end + return true end -- cgit v1.2.3-55-g6feb