Skip to content

Commit

Permalink
Return missing deps listing in luarocks install output
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeterv committed May 14, 2016
1 parent a268625 commit 2b02e99
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/luarocks/deps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ local function values_set(tbl)
return set
end

local function rock_status(name, deps_mode)
local search = require("luarocks.search")
local installed = match_dep(search.make_query(name), nil, deps_mode)
local installation_type = cfg.rocks_provided[name] and "provided by VM" or "installed"
return installed and installed.version.." "..installation_type or "not installed"
end

--- Check dependencies of a rock and attempt to install any missing ones.
-- Packages are installed using the LuaRocks "install" command.
-- Aborts the program if a dependency could not be fulfilled.
Expand Down Expand Up @@ -451,18 +458,28 @@ function deps.fulfill_dependencies(rockspec, deps_mode)

local first_missing_dep = true

for _, dep in ipairs(rockspec.dependencies) do
if not match_dep(dep, nil, deps_mode) then
if first_missing_dep then
util.printout(("Missing dependencies for %s %s:"):format(rockspec.name, rockspec.version))
first_missing_dep = false
end

util.printout((" %s (%s)"):format(deps.show_dep(dep), rock_status(dep.name, deps_mode)))
end
end

first_missing_dep = true

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

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))
rockspec.name, rockspec.version, deps.show_dep(dep), rock_status(dep.name, deps_mode)))

if dep.constraints[1] and dep.constraints[1].no_upgrade then
util.printerr("This version of "..rockspec.name.." is designed for use with")
Expand Down

0 comments on commit 2b02e99

Please sign in to comment.