From 6beb0ef346cc7fd097a4736a7b27755a84165287 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Tue, 10 May 2016 15:48:33 +0300 Subject: Shorten logging for `luarocks install` Instead of mentioning URL twice in Installing URL... Using URL... switching to 'build' mode simply print Installing URL and don't print URL at all when it's the argument to `luarocks install` (it's a bit redundant), only when it's a result of a search. --- src/luarocks/deps.lua | 1 + src/luarocks/install.lua | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 812e6d18..ac294f54 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua @@ -488,6 +488,7 @@ function deps.fulfill_dependencies(rockspec, deps_mode) 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 diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index c938aa9f..ae162b86 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua @@ -168,7 +168,6 @@ function install.run(...) if not ok then return nil, err, cfg.errorcodes.PERMISSIONDENIED end if name:match("%.rockspec$") or name:match("%.src%.rock$") then - util.printout("Using "..name.."... switching to 'build' mode") local build = require("luarocks.build") return build.run(name, util.forward_flags(flags, "local", "keep", "deps-mode", "only-deps")) elseif name:match("%.rock$") then @@ -190,7 +189,7 @@ function install.run(...) if not url then return nil, err end - util.printout("Installing "..url.."...") + util.printout("Installing "..url) return install.run(url, util.forward_flags(flags)) end end -- cgit v1.2.3-55-g6feb From 4800159347ac79a30180d778ac02ee24a181e41a Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Tue, 10 May 2016 16:31:16 +0300 Subject: Use same messages for installing binary and source rocks Move successful installation announcement into an util function. Don't print that the rock was "built": sometimes there is nothing to build (pure Lua rocks), and for C rocks compilation commands are printed already. --- src/luarocks/build.lua | 10 +--------- src/luarocks/install.lua | 10 +--------- src/luarocks/util.lua | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index bdc3b57a..38a269dd 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua @@ -332,15 +332,7 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m ok, err = manif.update_manifest(name, version, nil, deps_mode) if err then return nil, err end - local license = "" - if rockspec.description and rockspec.description.license then - license = ("(license: "..rockspec.description.license..")") - end - - local root_dir = path.root_dir(cfg.rocks_dir) - util.printout(name.." "..version.." is now built and installed in "..root_dir.." "..license) - util.printout() - + util.announce_install(rockspec) util.remove_scheduled_function(rollback) return name, version end diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index ae162b86..8960c102 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua @@ -98,15 +98,7 @@ function install.install_binary_rock(rock_file, deps_mode) ok, err = manif.update_manifest(name, version, nil, deps_mode) if err then return nil, err end - local license = "" - if rockspec.description.license then - license = ("(license: "..rockspec.description.license..")") - end - - local root_dir = path.root_dir(cfg.rocks_dir) - util.printout() - util.printout(name.." "..version.." is now installed in "..root_dir.." "..license) - + util.announce_install(rockspec) util.remove_scheduled_function(rollback) return name, version end diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index c06c8354..a92297ce 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -505,6 +505,20 @@ function util.see_help(command, program) return "See '"..util.this_program(program or "luarocks")..' help'..(command and " "..command or "").."'." end +function util.announce_install(rockspec) + local cfg = require("luarocks.cfg") + local path = require("luarocks.path") + + local suffix = "" + if rockspec.description and rockspec.description.license then + suffix = " (license: "..rockspec.description.license..")" + end + + local root_dir = path.root_dir(cfg.rocks_dir) + util.printout(rockspec.name.." "..rockspec.version.." is now installed in "..root_dir..suffix) + util.printout() +end + -- from http://lua-users.org/wiki/SplitJoin -- by PhilippeLhoste function util.split_string(str, delim, maxNb) -- cgit v1.2.3-55-g6feb From 277b7bc9f1ce46740de1c167294e235737a6e305 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Tue, 10 May 2016 16:38:11 +0300 Subject: Don't spam 'Updating manifest for...' Installation success message is enough and is more important (what's a manifest and why users should care?) --- src/luarocks/manif.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 05621315..bc202be3 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua @@ -432,8 +432,6 @@ function manif.update_manifest(name, version, repo, deps_mode) if deps_mode == "none" then deps_mode = cfg.deps_mode end - util.printout("Updating manifest for "..repo) - local manifest, err = manif.load_manifest(repo) if not manifest then util.printerr("No existing manifest. Attempting to rebuild...") -- cgit v1.2.3-55-g6feb 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(-) (limited to 'src') 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 From 2b02e999c5b04148fd88a67a2be93378c7225956 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Sat, 14 May 2016 19:09:15 +0300 Subject: Return missing deps listing in `luarocks install` output --- src/luarocks/deps.lua | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 73eab2c2..3c580623 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua @@ -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. @@ -451,6 +458,19 @@ 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 @@ -458,11 +478,8 @@ function deps.fulfill_dependencies(rockspec, deps_mode) 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") -- cgit v1.2.3-55-g6feb