diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2012-10-31 01:45:27 -0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-10-31 01:45:27 -0200 |
| commit | c7b9fe0fc863ff09716ff592f3ae96fa3b0e0ca1 (patch) | |
| tree | 39538787ae2caf9e702539498b4486b6361469d2 | |
| parent | 1f27702935b9bba1c0c3240a52a7ecaeca0ea81c (diff) | |
| download | luarocks-c7b9fe0fc863ff09716ff592f3ae96fa3b0e0ca1.tar.gz luarocks-c7b9fe0fc863ff09716ff592f3ae96fa3b0e0ca1.tar.bz2 luarocks-c7b9fe0fc863ff09716ff592f3ae96fa3b0e0ca1.zip | |
Clean up and make use of deps-mode / deps_mode consistent. --nodeps is now an alias to --deps-mode=none
| -rw-r--r-- | src/luarocks/build.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/cfg.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/command_line.lua | 6 | ||||
| -rw-r--r-- | src/luarocks/deps.lua | 43 | ||||
| -rw-r--r-- | src/luarocks/install.lua | 8 | ||||
| -rw-r--r-- | src/luarocks/make.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/make_manifest.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/manif.lua | 28 | ||||
| -rw-r--r-- | src/luarocks/manif_core.lua | 8 | ||||
| -rw-r--r-- | src/luarocks/path.lua | 10 | ||||
| -rw-r--r-- | src/luarocks/remove.lua | 14 |
11 files changed, 64 insertions, 65 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index d68acabd..d61d6611 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
| @@ -326,10 +326,10 @@ function run(...) | |||
| 326 | assert(type(version) == "string" or not version) | 326 | assert(type(version) == "string" or not version) |
| 327 | 327 | ||
| 328 | if flags["pack-binary-rock"] then | 328 | if flags["pack-binary-rock"] then |
| 329 | return pack.pack_binary_rock(name, version, do_build, name, version, deps.flags_to_deps_mode(flags)) | 329 | return pack.pack_binary_rock(name, version, do_build, name, version, deps.get_deps_mode(flags)) |
| 330 | else | 330 | else |
| 331 | local ok, err = fs.check_command_permissions(flags) | 331 | local ok, err = fs.check_command_permissions(flags) |
| 332 | if not ok then return nil, err end | 332 | if not ok then return nil, err end |
| 333 | return do_build(name, version, deps.flags_to_deps_mode(flags)) | 333 | return do_build(name, version, deps.get_deps_mode(flags)) |
| 334 | end | 334 | end |
| 335 | end | 335 | end |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 136ea6be..0e43768e 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -165,7 +165,7 @@ local defaults = { | |||
| 165 | use_extensions = false, | 165 | use_extensions = false, |
| 166 | accept_unknown_fields = false, | 166 | accept_unknown_fields = false, |
| 167 | fs_use_modules = true, | 167 | fs_use_modules = true, |
| 168 | use_trees = "one", | 168 | deps_mode = "one", |
| 169 | 169 | ||
| 170 | lua_modules_path = "/share/lua/"..lua_version, | 170 | lua_modules_path = "/share/lua/"..lua_version, |
| 171 | lib_modules_path = "/lib/lua/"..lua_version, | 171 | lib_modules_path = "/lib/lua/"..lua_version, |
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index d08ffdfe..b4b20f84 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
| @@ -7,6 +7,7 @@ local cfg = require("luarocks.cfg") | |||
| 7 | local fs = require("luarocks.fs") | 7 | local fs = require("luarocks.fs") |
| 8 | local path = require("luarocks.path") | 8 | local path = require("luarocks.path") |
| 9 | local dir = require("luarocks.dir") | 9 | local dir = require("luarocks.dir") |
| 10 | local deps = require("luarocks.deps") | ||
| 10 | 11 | ||
| 11 | --- Display an error message and exit. | 12 | --- Display an error message and exit. |
| 12 | -- @param message string: The error message. | 13 | -- @param message string: The error message. |
| @@ -50,6 +51,7 @@ function run_command(...) | |||
| 50 | if flags["only-from"] then flags["only-server"] = flags["only-from"] end | 51 | if flags["only-from"] then flags["only-server"] = flags["only-from"] end |
| 51 | if flags["only-sources-from"] then flags["only-sources"] = flags["only-sources-from"] end | 52 | if flags["only-sources-from"] then flags["only-sources"] = flags["only-sources-from"] end |
| 52 | if flags["to"] then flags["tree"] = flags["to"] end | 53 | if flags["to"] then flags["tree"] = flags["to"] end |
| 54 | if flags["nodeps"] then flags["deps-mode"] = "none" end | ||
| 53 | 55 | ||
| 54 | cfg.flags = flags | 56 | cfg.flags = flags |
| 55 | 57 | ||
| @@ -83,6 +85,10 @@ function run_command(...) | |||
| 83 | if cfg.local_by_default then | 85 | if cfg.local_by_default then |
| 84 | flags["local"] = true | 86 | flags["local"] = true |
| 85 | end | 87 | end |
| 88 | |||
| 89 | if flags["deps-mode"] and not deps.check_dep_trees_flag(flags["deps-mode"]) then | ||
| 90 | return nil, "Invalid entry for --deps-mode." | ||
| 91 | end | ||
| 86 | 92 | ||
| 87 | if flags["tree"] then | 93 | if flags["tree"] then |
| 88 | if flags["tree"] == true then | 94 | if flags["tree"] == true then |
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index a409920a..6d5f3fef 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
| @@ -312,14 +312,14 @@ end | |||
| 312 | -- @return table or nil: A table containing fields 'name' and 'version' | 312 | -- @return table or nil: A table containing fields 'name' and 'version' |
| 313 | -- representing an installed rock which matches the given dependency, | 313 | -- representing an installed rock which matches the given dependency, |
| 314 | -- or nil if it could not be matched. | 314 | -- or nil if it could not be matched. |
| 315 | local function match_dep(dep, blacklist, use_trees) | 315 | local function match_dep(dep, blacklist, deps_mode) |
| 316 | assert(type(dep) == "table") | 316 | assert(type(dep) == "table") |
| 317 | 317 | ||
| 318 | local versions | 318 | local versions |
| 319 | if dep.name == "lua" then | 319 | if dep.name == "lua" then |
| 320 | versions = { cfg.lua_version } | 320 | versions = { cfg.lua_version } |
| 321 | else | 321 | else |
| 322 | versions = manif_core.get_versions(dep.name, use_trees) | 322 | versions = manif_core.get_versions(dep.name, deps_mode) |
| 323 | end | 323 | end |
| 324 | if not versions then | 324 | if not versions then |
| 325 | return nil | 325 | return nil |
| @@ -361,13 +361,13 @@ end | |||
| 361 | -- in table format and values are tables containing fields 'name' and | 361 | -- in table format and values are tables containing fields 'name' and |
| 362 | -- version' representing matches, and a table of missing dependencies | 362 | -- version' representing matches, and a table of missing dependencies |
| 363 | -- parsed as tables. | 363 | -- parsed as tables. |
| 364 | function match_deps(rockspec, blacklist, use_trees) | 364 | function match_deps(rockspec, blacklist, deps_mode) |
| 365 | assert(type(rockspec) == "table") | 365 | assert(type(rockspec) == "table") |
| 366 | assert(type(blacklist) == "table" or not blacklist) | 366 | assert(type(blacklist) == "table" or not blacklist) |
| 367 | local matched, missing, no_upgrade = {}, {}, {} | 367 | local matched, missing, no_upgrade = {}, {}, {} |
| 368 | 368 | ||
| 369 | for _, dep in ipairs(rockspec.dependencies) do | 369 | for _, dep in ipairs(rockspec.dependencies) do |
| 370 | local found = match_dep(dep, blacklist and blacklist[dep.name] or nil, use_trees) | 370 | local found = match_dep(dep, blacklist and blacklist[dep.name] or nil, deps_mode) |
| 371 | if found then | 371 | if found then |
| 372 | if dep.name ~= "lua" then | 372 | if dep.name ~= "lua" then |
| 373 | matched[dep] = found | 373 | matched[dep] = found |
| @@ -401,7 +401,7 @@ end | |||
| 401 | -- @return boolean or (nil, string, [string]): True if no errors occurred, or | 401 | -- @return boolean or (nil, string, [string]): True if no errors occurred, or |
| 402 | -- nil and an error message if any test failed, followed by an optional | 402 | -- nil and an error message if any test failed, followed by an optional |
| 403 | -- error code. | 403 | -- error code. |
| 404 | function fulfill_dependencies(rockspec, use_trees) | 404 | function fulfill_dependencies(rockspec, deps_mode) |
| 405 | 405 | ||
| 406 | local search = require("luarocks.search") | 406 | local search = require("luarocks.search") |
| 407 | local install = require("luarocks.install") | 407 | local install = require("luarocks.install") |
| @@ -433,7 +433,7 @@ function fulfill_dependencies(rockspec, use_trees) | |||
| 433 | end | 433 | end |
| 434 | end | 434 | end |
| 435 | 435 | ||
| 436 | local matched, missing, no_upgrade = match_deps(rockspec, nil, use_trees) | 436 | local matched, missing, no_upgrade = match_deps(rockspec, nil, deps_mode) |
| 437 | 437 | ||
| 438 | if next(no_upgrade) then | 438 | if next(no_upgrade) then |
| 439 | util.printerr("Missing dependencies for "..rockspec.name.." "..rockspec.version..":") | 439 | util.printerr("Missing dependencies for "..rockspec.name.." "..rockspec.version..":") |
| @@ -467,7 +467,7 @@ function fulfill_dependencies(rockspec, use_trees) | |||
| 467 | 467 | ||
| 468 | for _, dep in pairs(missing) do | 468 | for _, dep in pairs(missing) do |
| 469 | -- Double-check in case dependency was filled during recursion. | 469 | -- Double-check in case dependency was filled during recursion. |
| 470 | if not match_dep(dep, nil, use_trees) then | 470 | if not match_dep(dep, nil, deps_mode) then |
| 471 | local rock = search.find_suitable_rock(dep) | 471 | local rock = search.find_suitable_rock(dep) |
| 472 | if not rock then | 472 | if not rock then |
| 473 | return nil, "Could not satisfy dependency: "..show_dep(dep) | 473 | return nil, "Could not satisfy dependency: "..show_dep(dep) |
| @@ -640,7 +640,7 @@ end | |||
| 640 | -- @param name string: Package name. | 640 | -- @param name string: Package name. |
| 641 | -- @param version string: Package version. | 641 | -- @param version string: Package version. |
| 642 | -- @return (table, table): The results and a table of missing dependencies. | 642 | -- @return (table, table): The results and a table of missing dependencies. |
| 643 | function scan_deps(results, missing, manifest, name, version, use_trees) | 643 | function scan_deps(results, missing, manifest, name, version, deps_mode) |
| 644 | assert(type(results) == "table") | 644 | assert(type(results) == "table") |
| 645 | assert(type(missing) == "table") | 645 | assert(type(missing) == "table") |
| 646 | assert(type(manifest) == "table") | 646 | assert(type(manifest) == "table") |
| @@ -669,9 +669,9 @@ function scan_deps(results, missing, manifest, name, version, use_trees) | |||
| 669 | else | 669 | else |
| 670 | rockspec = { dependencies = deplist } | 670 | rockspec = { dependencies = deplist } |
| 671 | end | 671 | end |
| 672 | local matched, failures = match_deps(rockspec, nil, use_trees) | 672 | local matched, failures = match_deps(rockspec, nil, deps_mode) |
| 673 | for _, match in pairs(matched) do | 673 | for _, match in pairs(matched) do |
| 674 | results, missing = scan_deps(results, missing, manifest, match.name, match.version, use_trees) | 674 | results, missing = scan_deps(results, missing, manifest, match.name, match.version, deps_mode) |
| 675 | end | 675 | end |
| 676 | if next(failures) then | 676 | if next(failures) then |
| 677 | for _, failure in pairs(failures) do | 677 | for _, failure in pairs(failures) do |
| @@ -682,30 +682,25 @@ function scan_deps(results, missing, manifest, name, version, use_trees) | |||
| 682 | return results, missing | 682 | return results, missing |
| 683 | end | 683 | end |
| 684 | 684 | ||
| 685 | local valid_trees = { | 685 | local valid_deps_modes = { |
| 686 | one = true, | 686 | one = true, |
| 687 | order = true, | 687 | order = true, |
| 688 | all = true, | 688 | all = true, |
| 689 | none = true, | ||
| 689 | } | 690 | } |
| 690 | 691 | ||
| 691 | function check_trees_flag(flag) | 692 | function check_deps_mode_flag(flag) |
| 692 | return valid_trees[flag] | 693 | return valid_deps_modes[flag] |
| 693 | end | 694 | end |
| 694 | 695 | ||
| 695 | function flags_to_deps_mode(flags) | 696 | function get_deps_mode(flags) |
| 696 | if flags["nodeps"] then | 697 | if flags["deps-mode"] then |
| 697 | return "none" | 698 | return flags["deps-mode"] |
| 698 | elseif flags["trees"] then | ||
| 699 | return flags["trees"] | ||
| 700 | else | 699 | else |
| 701 | return cfg.use_trees | 700 | return cfg.deps_mode |
| 702 | end | 701 | end |
| 703 | end | 702 | end |
| 704 | 703 | ||
| 705 | function deps_mode_to_flag(deps_mode) | 704 | function deps_mode_to_flag(deps_mode) |
| 706 | if deps_mode == "none" then | 705 | return "--deps-mode="..deps_mode |
| 707 | return "--nodeps" | ||
| 708 | else | ||
| 709 | return "--trees="..deps_mode | ||
| 710 | end | ||
| 711 | end | 706 | end |
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index 0ffb95ef..e633ea23 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua | |||
| @@ -127,13 +127,9 @@ function run(...) | |||
| 127 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then | 127 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then |
| 128 | util.printout("Using "..name.."... switching to 'build' mode") | 128 | util.printout("Using "..name.."... switching to 'build' mode") |
| 129 | local build = require("luarocks.build") | 129 | local build = require("luarocks.build") |
| 130 | local build_flags = {} | 130 | return build.run(name, deps.get_deps_mode(flags), flags["local"] and "--local") |
| 131 | if flags["local"] then table.insert(build_flags, "--local") end | ||
| 132 | if flags["nodeps"] then table.insert(build_flags, "--nodeps") end | ||
| 133 | if flags["trees"] then table.insert(build_flags, "--trees="..flags["trees"]) end | ||
| 134 | return build.run(name, unpack(build_flags)) | ||
| 135 | elseif name:match("%.rock$") then | 131 | elseif name:match("%.rock$") then |
| 136 | return install_binary_rock(name, deps.flags_to_deps_mode(flags)) | 132 | return install_binary_rock(name, deps.get_deps_mode(flags)) |
| 137 | else | 133 | else |
| 138 | local search = require("luarocks.search") | 134 | local search = require("luarocks.search") |
| 139 | local results, err = search.find_suitable_rock(search.make_query(name:lower(), version)) | 135 | local results, err = search.find_suitable_rock(search.make_query(name:lower(), version)) |
diff --git a/src/luarocks/make.lua b/src/luarocks/make.lua index 498445d8..69c2162f 100644 --- a/src/luarocks/make.lua +++ b/src/luarocks/make.lua | |||
| @@ -63,10 +63,10 @@ function run(...) | |||
| 63 | if not rspec then | 63 | if not rspec then |
| 64 | return nil, err | 64 | return nil, err |
| 65 | end | 65 | end |
| 66 | return pack.pack_binary_rock(rspec.name, rspec.version, build.build_rockspec, rockspec, false, true, deps.flags_to_deps_mode(flags)) | 66 | return pack.pack_binary_rock(rspec.name, rspec.version, build.build_rockspec, rockspec, false, true, deps.get_deps_mode(flags)) |
| 67 | else | 67 | else |
| 68 | local ok, err = fs.check_command_permissions(flags) | 68 | local ok, err = fs.check_command_permissions(flags) |
| 69 | if not ok then return nil, err end | 69 | if not ok then return nil, err end |
| 70 | return build.build_rockspec(rockspec, false, true, deps.flags_to_deps_mode(flags)) | 70 | return build.build_rockspec(rockspec, false, true, deps.get_deps_mode(flags)) |
| 71 | end | 71 | end |
| 72 | end | 72 | end |
diff --git a/src/luarocks/make_manifest.lua b/src/luarocks/make_manifest.lua index e629b9de..845c9f8a 100644 --- a/src/luarocks/make_manifest.lua +++ b/src/luarocks/make_manifest.lua | |||
| @@ -28,7 +28,7 @@ function run(...) | |||
| 28 | 28 | ||
| 29 | util.printout("Making manifest for "..repo) | 29 | util.printout("Making manifest for "..repo) |
| 30 | 30 | ||
| 31 | local ok, err = manif.make_manifest(repo, deps.flags_to_deps_mode(flags)) | 31 | local ok, err = manif.make_manifest(repo, deps.get_deps_mode(flags)) |
| 32 | if ok then | 32 | if ok then |
| 33 | util.printout("Generating index.html for "..repo) | 33 | util.printout("Generating index.html for "..repo) |
| 34 | index.make_index(repo) | 34 | index.make_index(repo) |
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index b7554a33..414c3262 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
| @@ -185,14 +185,17 @@ end | |||
| 185 | -- and any dependency inconsistencies or missing dependencies are reported to | 185 | -- and any dependency inconsistencies or missing dependencies are reported to |
| 186 | -- standard error. | 186 | -- standard error. |
| 187 | -- @param manifest table: a manifest table. | 187 | -- @param manifest table: a manifest table. |
| 188 | local function update_dependencies(manifest, use_trees) | 188 | local function update_dependencies(manifest, deps_mode) |
| 189 | assert(type(manifest) == "table") | ||
| 190 | assert(type(deps_mode) == "string") | ||
| 191 | |||
| 189 | for pkg, versions in pairs(manifest.repository) do | 192 | for pkg, versions in pairs(manifest.repository) do |
| 190 | for version, repositories in pairs(versions) do | 193 | for version, repositories in pairs(versions) do |
| 191 | local current = pkg.." "..version | 194 | local current = pkg.." "..version |
| 192 | for _, repo in ipairs(repositories) do | 195 | for _, repo in ipairs(repositories) do |
| 193 | if repo.arch == "installed" then | 196 | if repo.arch == "installed" then |
| 194 | local missing | 197 | local missing |
| 195 | repo.dependencies, missing = deps.scan_deps({}, {}, manifest, pkg, version, use_trees) | 198 | repo.dependencies, missing = deps.scan_deps({}, {}, manifest, pkg, version, deps_mode) |
| 196 | repo.dependencies[pkg] = nil | 199 | repo.dependencies[pkg] = nil |
| 197 | if missing then | 200 | if missing then |
| 198 | for miss, err in pairs(missing) do | 201 | for miss, err in pairs(missing) do |
| @@ -214,9 +217,10 @@ end | |||
| 214 | -- @param manifest table: A manifest table (must contain repository, modules, commands tables). | 217 | -- @param manifest table: A manifest table (must contain repository, modules, commands tables). |
| 215 | -- It will be altered to include the search results. | 218 | -- It will be altered to include the search results. |
| 216 | -- @return boolean or (nil, string): true in case of success, or nil followed by an error message. | 219 | -- @return boolean or (nil, string): true in case of success, or nil followed by an error message. |
| 217 | local function store_results(results, manifest, use_trees) | 220 | local function store_results(results, manifest, deps_mode) |
| 218 | assert(type(results) == "table") | 221 | assert(type(results) == "table") |
| 219 | assert(type(manifest) == "table") | 222 | assert(type(manifest) == "table") |
| 223 | assert(type(deps_mode) == "string") | ||
| 220 | 224 | ||
| 221 | for name, versions in pairs(results) do | 225 | for name, versions in pairs(results) do |
| 222 | local pkgtable = manifest.repository[name] or {} | 226 | local pkgtable = manifest.repository[name] or {} |
| @@ -239,7 +243,7 @@ local function store_results(results, manifest, use_trees) | |||
| 239 | end | 243 | end |
| 240 | manifest.repository[name] = pkgtable | 244 | manifest.repository[name] = pkgtable |
| 241 | end | 245 | end |
| 242 | update_dependencies(manifest, use_trees) | 246 | update_dependencies(manifest, deps_mode) |
| 243 | sort_package_matching_table(manifest.modules) | 247 | sort_package_matching_table(manifest.modules) |
| 244 | sort_package_matching_table(manifest.commands) | 248 | sort_package_matching_table(manifest.commands) |
| 245 | return true | 249 | return true |
| @@ -251,10 +255,11 @@ end | |||
| 251 | -- @param repo A local repository directory. | 255 | -- @param repo A local repository directory. |
| 252 | -- @return boolean or (nil, string): True if manifest was generated, | 256 | -- @return boolean or (nil, string): True if manifest was generated, |
| 253 | -- or nil and an error message. | 257 | -- or nil and an error message. |
| 254 | function make_manifest(repo, use_trees) | 258 | function make_manifest(repo, deps_mode) |
| 255 | assert(type(repo) == "string") | 259 | assert(type(repo) == "string") |
| 260 | assert(type(deps_mode) == "string") | ||
| 256 | 261 | ||
| 257 | if use_trees == "none" then use_trees = cfg.use_trees end | 262 | if deps_mode == "none" then deps_mode = cfg.deps_mode end |
| 258 | 263 | ||
| 259 | if not fs.is_dir(repo) then | 264 | if not fs.is_dir(repo) then |
| 260 | return nil, "Cannot access repository at "..repo | 265 | return nil, "Cannot access repository at "..repo |
| @@ -267,7 +272,7 @@ function make_manifest(repo, use_trees) | |||
| 267 | local manifest = { repository = {}, modules = {}, commands = {} } | 272 | local manifest = { repository = {}, modules = {}, commands = {} } |
| 268 | manif_core.manifest_cache[repo] = manifest | 273 | manif_core.manifest_cache[repo] = manifest |
| 269 | 274 | ||
| 270 | local ok, err = store_results(results, manifest, use_trees) | 275 | local ok, err = store_results(results, manifest, deps_mode) |
| 271 | if not ok then return nil, err end | 276 | if not ok then return nil, err end |
| 272 | 277 | ||
| 273 | return save_table(repo, "manifest", manifest) | 278 | return save_table(repo, "manifest", manifest) |
| @@ -283,19 +288,20 @@ end | |||
| 283 | -- the default local repository configured as cfg.rocks_dir is used. | 288 | -- the default local repository configured as cfg.rocks_dir is used. |
| 284 | -- @return boolean or (nil, string): True if manifest was generated, | 289 | -- @return boolean or (nil, string): True if manifest was generated, |
| 285 | -- or nil and an error message. | 290 | -- or nil and an error message. |
| 286 | function update_manifest(name, version, repo, use_trees) | 291 | function update_manifest(name, version, repo, deps_mode) |
| 287 | assert(type(name) == "string") | 292 | assert(type(name) == "string") |
| 288 | assert(type(version) == "string") | 293 | assert(type(version) == "string") |
| 289 | repo = path.rocks_dir(repo or cfg.root_dir) | 294 | repo = path.rocks_dir(repo or cfg.root_dir) |
| 295 | assert(type(deps_mode) == "string") | ||
| 290 | 296 | ||
| 291 | if use_trees == "none" then use_trees = cfg.use_trees end | 297 | if deps_mode == "none" then deps_mode = cfg.deps_mode end |
| 292 | 298 | ||
| 293 | util.printout("Updating manifest for "..repo) | 299 | util.printout("Updating manifest for "..repo) |
| 294 | 300 | ||
| 295 | local manifest, err = load_manifest(repo) | 301 | local manifest, err = load_manifest(repo) |
| 296 | if not manifest then | 302 | if not manifest then |
| 297 | util.printerr("No existing manifest. Attempting to rebuild...") | 303 | util.printerr("No existing manifest. Attempting to rebuild...") |
| 298 | local ok, err = make_manifest(repo, use_trees) | 304 | local ok, err = make_manifest(repo, deps_mode) |
| 299 | if not ok then | 305 | if not ok then |
| 300 | return nil, err | 306 | return nil, err |
| 301 | end | 307 | end |
| @@ -307,7 +313,7 @@ function update_manifest(name, version, repo, use_trees) | |||
| 307 | 313 | ||
| 308 | local results = {[name] = {[version] = {{arch = "installed", repo = repo}}}} | 314 | local results = {[name] = {[version] = {{arch = "installed", repo = repo}}}} |
| 309 | 315 | ||
| 310 | local ok, err = store_results(results, manifest, use_trees) | 316 | local ok, err = store_results(results, manifest, deps_mode) |
| 311 | if not ok then return nil, err end | 317 | if not ok then return nil, err end |
| 312 | 318 | ||
| 313 | return save_table(repo, "manifest", manifest) | 319 | return save_table(repo, "manifest", manifest) |
diff --git a/src/luarocks/manif_core.lua b/src/luarocks/manif_core.lua index 6af99fe7..6424a1e8 100644 --- a/src/luarocks/manif_core.lua +++ b/src/luarocks/manif_core.lua | |||
| @@ -53,18 +53,18 @@ end | |||
| 53 | 53 | ||
| 54 | --- Get all versions of a package listed in a manifest file. | 54 | --- Get all versions of a package listed in a manifest file. |
| 55 | -- @param name string: a package name. | 55 | -- @param name string: a package name. |
| 56 | -- @param use_trees string: "one", to use only the currently | 56 | -- @param deps_mode string: "one", to use only the currently |
| 57 | -- configured tree; "order" to select trees based on order | 57 | -- configured tree; "order" to select trees based on order |
| 58 | -- (use the current tree and all trees below it on the list) | 58 | -- (use the current tree and all trees below it on the list) |
| 59 | -- or "all", to use all trees. | 59 | -- or "all", to use all trees. |
| 60 | -- @return table: An array of strings listing installed | 60 | -- @return table: An array of strings listing installed |
| 61 | -- versions of a package. | 61 | -- versions of a package. |
| 62 | function get_versions(name, use_trees) | 62 | function get_versions(name, deps_mode) |
| 63 | assert(type(name) == "string") | 63 | assert(type(name) == "string") |
| 64 | assert(type(use_trees) == "string") | 64 | assert(type(deps_mode) == "string") |
| 65 | 65 | ||
| 66 | local manifest = {} | 66 | local manifest = {} |
| 67 | path.map_trees(use_trees, function(tree) | 67 | path.map_trees(deps_mode, function(tree) |
| 68 | local loaded = load_local_manifest(path.rocks_dir(tree)) | 68 | local loaded = load_local_manifest(path.rocks_dir(tree)) |
| 69 | if loaded then | 69 | if loaded then |
| 70 | util.deep_merge(manifest, loaded) | 70 | util.deep_merge(manifest, loaded) |
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index 42d3b8f1..64a203ef 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
| @@ -306,13 +306,13 @@ function use_tree(tree) | |||
| 306 | cfg.deploy_lib_dir = deploy_lib_dir(tree) | 306 | cfg.deploy_lib_dir = deploy_lib_dir(tree) |
| 307 | end | 307 | end |
| 308 | 308 | ||
| 309 | function map_trees(use_trees, fn, ...) | 309 | function map_trees(deps_mode, fn, ...) |
| 310 | local result = {} | 310 | local result = {} |
| 311 | if use_trees == "one" then | 311 | if deps_mode == "one" then |
| 312 | table.insert(result, (fn(cfg.root_dir, ...)) or 0) | 312 | table.insert(result, (fn(cfg.root_dir, ...)) or 0) |
| 313 | elseif use_trees == "all" or use_trees == "order" then | 313 | elseif deps_mode == "all" or deps_mode == "order" then |
| 314 | local use = false | 314 | local use = false |
| 315 | if use_trees == "all" then | 315 | if deps_mode == "all" then |
| 316 | use = true | 316 | use = true |
| 317 | end | 317 | end |
| 318 | for _, tree in ipairs(cfg.rocks_trees) do | 318 | for _, tree in ipairs(cfg.rocks_trees) do |
| @@ -374,7 +374,7 @@ end | |||
| 374 | -- @return boolean This function always succeeds. | 374 | -- @return boolean This function always succeeds. |
| 375 | function run(...) | 375 | function run(...) |
| 376 | local flags = util.parse_flags(...) | 376 | local flags = util.parse_flags(...) |
| 377 | local deps_mode = deps.flags_to_deps_mode(flags) | 377 | local deps_mode = deps.get_deps_mode(flags) |
| 378 | 378 | ||
| 379 | util.printout(cfg.export_lua_path:format(util.remove_path_dupes(package.path, ';'))) | 379 | util.printout(cfg.export_lua_path:format(util.remove_path_dupes(package.path, ';'))) |
| 380 | util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(package.cpath, ';'))) | 380 | util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(package.cpath, ';'))) |
diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua index 261dc1c4..126cfdc8 100644 --- a/src/luarocks/remove.lua +++ b/src/luarocks/remove.lua | |||
| @@ -28,7 +28,7 @@ To override this check and force the removal, use --force. | |||
| 28 | -- @param versions array of string: the versions to be deleted. | 28 | -- @param versions array of string: the versions to be deleted. |
| 29 | -- @return array of string: an empty table if no packages depend on any | 29 | -- @return array of string: an empty table if no packages depend on any |
| 30 | -- of the given list, or an array of strings in "name/version" format. | 30 | -- of the given list, or an array of strings in "name/version" format. |
| 31 | local function check_dependents(name, versions, use_trees) | 31 | local function check_dependents(name, versions, deps_mode) |
| 32 | local dependents = {} | 32 | local dependents = {} |
| 33 | local blacklist = {} | 33 | local blacklist = {} |
| 34 | blacklist[name] = {} | 34 | blacklist[name] = {} |
| @@ -44,7 +44,7 @@ local function check_dependents(name, versions, use_trees) | |||
| 44 | for rock_version, _ in pairs(rock_versions) do | 44 | for rock_version, _ in pairs(rock_versions) do |
| 45 | local rockspec, err = fetch.load_rockspec(path.rockspec_file(rock_name, rock_version)) | 45 | local rockspec, err = fetch.load_rockspec(path.rockspec_file(rock_name, rock_version)) |
| 46 | if rockspec then | 46 | if rockspec then |
| 47 | local _, missing = deps.match_deps(rockspec, blacklist, use_trees) | 47 | local _, missing = deps.match_deps(rockspec, blacklist, deps_mode) |
| 48 | if missing[name] then | 48 | if missing[name] then |
| 49 | table.insert(dependents, { name = rock_name, version = rock_version }) | 49 | table.insert(dependents, { name = rock_name, version = rock_version }) |
| 50 | end | 50 | end |
| @@ -78,16 +78,12 @@ end | |||
| 78 | -- successful, nil and an error message otherwise. | 78 | -- successful, nil and an error message otherwise. |
| 79 | function run(...) | 79 | function run(...) |
| 80 | local flags, name, version = util.parse_flags(...) | 80 | local flags, name, version = util.parse_flags(...) |
| 81 | |||
| 82 | if flags["trees"] and type(flags["trees"]) ~= "string" then | ||
| 83 | return nil, "Invalid entry for --trees." | ||
| 84 | end | ||
| 85 | 81 | ||
| 86 | if type(name) ~= "string" then | 82 | if type(name) ~= "string" then |
| 87 | return nil, "Argument missing, see help." | 83 | return nil, "Argument missing, see help." |
| 88 | end | 84 | end |
| 89 | 85 | ||
| 90 | local use_trees = flags["trees"] or cfg.use_trees | 86 | local deps_mode = flags["deps-mode"] or cfg.deps_mode |
| 91 | 87 | ||
| 92 | local ok, err = fs.check_command_permissions(flags) | 88 | local ok, err = fs.check_command_permissions(flags) |
| 93 | if not ok then return nil, err end | 89 | if not ok then return nil, err end |
| @@ -106,7 +102,7 @@ function run(...) | |||
| 106 | util.printout(name.." "..table.concat(util.keys(versions), ", ").."...") | 102 | util.printout(name.." "..table.concat(util.keys(versions), ", ").."...") |
| 107 | util.printout() | 103 | util.printout() |
| 108 | 104 | ||
| 109 | local dependents = check_dependents(name, versions, use_trees) | 105 | local dependents = check_dependents(name, versions, deps_mode) |
| 110 | 106 | ||
| 111 | if #dependents == 0 or flags["force"] then | 107 | if #dependents == 0 or flags["force"] then |
| 112 | if #dependents > 0 then | 108 | if #dependents > 0 then |
| @@ -118,7 +114,7 @@ function run(...) | |||
| 118 | end | 114 | end |
| 119 | local ok, err = delete_versions(name, versions) | 115 | local ok, err = delete_versions(name, versions) |
| 120 | if not ok then return nil, err end | 116 | if not ok then return nil, err end |
| 121 | ok, err = manif.make_manifest(cfg.rocks_dir, use_trees) | 117 | ok, err = manif.make_manifest(cfg.rocks_dir, deps_mode) |
| 122 | if not ok then return nil, err end | 118 | if not ok then return nil, err end |
| 123 | else | 119 | else |
| 124 | if not second then | 120 | if not second then |
