aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/build.lua10
-rw-r--r--src/luarocks/deps.lua84
-rw-r--r--src/luarocks/install.lua13
-rw-r--r--src/luarocks/manif.lua2
-rw-r--r--src/luarocks/util.lua14
5 files changed, 63 insertions, 60 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua
index a1aeb501..c62e4694 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
332 ok, err = manif.update_manifest(name, version, nil, deps_mode) 332 ok, err = manif.update_manifest(name, version, nil, deps_mode)
333 if err then return nil, err end 333 if err then return nil, err end
334 334
335 local license = "" 335 util.announce_install(rockspec)
336 if rockspec.description and rockspec.description.license then
337 license = ("(license: "..rockspec.description.license..")")
338 end
339
340 local root_dir = path.root_dir(cfg.rocks_dir)
341 util.printout(name.." "..version.." is now built and installed in "..root_dir.." "..license)
342 util.printout()
343
344 util.remove_scheduled_function(rollback) 336 util.remove_scheduled_function(rollback)
345 return name, version 337 return name, version
346end 338end
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
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua
index b6af43cc..e3ab6fac 100644
--- a/src/luarocks/install.lua
+++ b/src/luarocks/install.lua
@@ -98,15 +98,7 @@ function install.install_binary_rock(rock_file, deps_mode)
98 ok, err = manif.update_manifest(name, version, nil, deps_mode) 98 ok, err = manif.update_manifest(name, version, nil, deps_mode)
99 if err then return nil, err end 99 if err then return nil, err end
100 100
101 local license = "" 101 util.announce_install(rockspec)
102 if rockspec.description.license then
103 license = ("(license: "..rockspec.description.license..")")
104 end
105
106 local root_dir = path.root_dir(cfg.rocks_dir)
107 util.printout()
108 util.printout(name.." "..version.." is now installed in "..root_dir.." "..license)
109
110 util.remove_scheduled_function(rollback) 102 util.remove_scheduled_function(rollback)
111 return name, version 103 return name, version
112end 104end
@@ -168,7 +160,6 @@ function install.run(...)
168 if not ok then return nil, err, cfg.errorcodes.PERMISSIONDENIED end 160 if not ok then return nil, err, cfg.errorcodes.PERMISSIONDENIED end
169 161
170 if name:match("%.rockspec$") or name:match("%.src%.rock$") then 162 if name:match("%.rockspec$") or name:match("%.src%.rock$") then
171 util.printout("Using "..name.."... switching to 'build' mode")
172 local build = require("luarocks.build") 163 local build = require("luarocks.build")
173 return build.run(name, util.forward_flags(flags, "local", "keep", "deps-mode", "only-deps", "force", "force-fast")) 164 return build.run(name, util.forward_flags(flags, "local", "keep", "deps-mode", "only-deps", "force", "force-fast"))
174 elseif name:match("%.rock$") then 165 elseif name:match("%.rock$") then
@@ -190,7 +181,7 @@ function install.run(...)
190 if not url then 181 if not url then
191 return nil, err 182 return nil, err
192 end 183 end
193 util.printout("Installing "..url.."...") 184 util.printout("Installing "..url)
194 return install.run(url, util.forward_flags(flags)) 185 return install.run(url, util.forward_flags(flags))
195 end 186 end
196end 187end
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)
432 432
433 if deps_mode == "none" then deps_mode = cfg.deps_mode end 433 if deps_mode == "none" then deps_mode = cfg.deps_mode end
434 434
435 util.printout("Updating manifest for "..repo)
436
437 local manifest, err = manif.load_manifest(repo) 435 local manifest, err = manif.load_manifest(repo)
438 if not manifest then 436 if not manifest then
439 util.printerr("No existing manifest. Attempting to rebuild...") 437 util.printerr("No existing manifest. Attempting to rebuild...")
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua
index 80f1684a..520625c0 100644
--- a/src/luarocks/util.lua
+++ b/src/luarocks/util.lua
@@ -506,6 +506,20 @@ function util.see_help(command, program)
506 return "See '"..util.this_program(program or "luarocks")..' help'..(command and " "..command or "").."'." 506 return "See '"..util.this_program(program or "luarocks")..' help'..(command and " "..command or "").."'."
507end 507end
508 508
509function util.announce_install(rockspec)
510 local cfg = require("luarocks.cfg")
511 local path = require("luarocks.path")
512
513 local suffix = ""
514 if rockspec.description and rockspec.description.license then
515 suffix = " (license: "..rockspec.description.license..")"
516 end
517
518 local root_dir = path.root_dir(cfg.rocks_dir)
519 util.printout(rockspec.name.." "..rockspec.version.." is now installed in "..root_dir..suffix)
520 util.printout()
521end
522
509-- from http://lua-users.org/wiki/SplitJoin 523-- from http://lua-users.org/wiki/SplitJoin
510-- by PhilippeLhoste 524-- by PhilippeLhoste
511function util.split_string(str, delim, maxNb) 525function util.split_string(str, delim, maxNb)