diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2012-09-25 15:44:03 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-09-25 15:44:03 -0300 |
| commit | 233a9af0f19e00cc8aa488cc1557497c76d2a7b0 (patch) | |
| tree | 990b3911c8eea46a9483ff81b8af04f25036ad50 | |
| parent | 9d678494d9e627cd0f58cb90cbb621a6b2e406eb (diff) | |
| download | luarocks-233a9af0f19e00cc8aa488cc1557497c76d2a7b0.tar.gz luarocks-233a9af0f19e00cc8aa488cc1557497c76d2a7b0.tar.bz2 luarocks-233a9af0f19e00cc8aa488cc1557497c76d2a7b0.zip | |
unfinished work on multi-tree support
| -rw-r--r-- | src/luarocks/add.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/admin_remove.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/build.lua | 35 | ||||
| -rw-r--r-- | src/luarocks/cfg.lua | 1 | ||||
| -rw-r--r-- | src/luarocks/deps.lua | 48 | ||||
| -rw-r--r-- | src/luarocks/install.lua | 21 | ||||
| -rw-r--r-- | src/luarocks/make.lua | 5 | ||||
| -rw-r--r-- | src/luarocks/make_manifest.lua | 7 | ||||
| -rw-r--r-- | src/luarocks/manif.lua | 22 | ||||
| -rw-r--r-- | src/luarocks/manif_core.lua | 35 | ||||
| -rw-r--r-- | src/luarocks/purge.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/remove.lua | 14 | ||||
| -rw-r--r-- | src/luarocks/repos.lua | 6 | ||||
| -rw-r--r-- | src/luarocks/validate.lua | 8 |
14 files changed, 139 insertions, 69 deletions
diff --git a/src/luarocks/add.lua b/src/luarocks/add.lua index bf3f8979..48b9964c 100644 --- a/src/luarocks/add.lua +++ b/src/luarocks/add.lua | |||
| @@ -65,7 +65,7 @@ local function add_files_to_server(refresh, rockfiles, server, upload_server) | |||
| 65 | fs.change_dir(local_cache) | 65 | fs.change_dir(local_cache) |
| 66 | 66 | ||
| 67 | util.printout("Updating manifest...") | 67 | util.printout("Updating manifest...") |
| 68 | manif.make_manifest(local_cache) | 68 | manif.make_manifest(local_cache, "one") |
| 69 | util.printout("Updating index.html...") | 69 | util.printout("Updating index.html...") |
| 70 | index.make_index(local_cache) | 70 | index.make_index(local_cache) |
| 71 | 71 | ||
diff --git a/src/luarocks/admin_remove.lua b/src/luarocks/admin_remove.lua index f1268576..dc36e16e 100644 --- a/src/luarocks/admin_remove.lua +++ b/src/luarocks/admin_remove.lua | |||
| @@ -61,7 +61,7 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve | |||
| 61 | fs.change_dir(local_cache) | 61 | fs.change_dir(local_cache) |
| 62 | 62 | ||
| 63 | util.printout("Updating manifest...") | 63 | util.printout("Updating manifest...") |
| 64 | manif.make_manifest(local_cache) | 64 | manif.make_manifest(local_cache, "one") |
| 65 | util.printout("Updating index.html...") | 65 | util.printout("Updating index.html...") |
| 66 | index.make_index(local_cache) | 66 | index.make_index(local_cache) |
| 67 | 67 | ||
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 6ffa0e79..d68acabd 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
| @@ -111,10 +111,11 @@ end | |||
| 111 | -- @param minimal_mode boolean: true if there's no need to fetch, | 111 | -- @param minimal_mode boolean: true if there's no need to fetch, |
| 112 | -- unpack or change dir (this is used by "luarocks make"). Implies | 112 | -- unpack or change dir (this is used by "luarocks make"). Implies |
| 113 | -- need_to_fetch = false. | 113 | -- need_to_fetch = false. |
| 114 | -- @param no_deps boolean: true if dependency check needs to be skipped | 114 | -- @param deps_mode: string: Which trees to check dependencies for: |
| 115 | -- "none", "one", "order" or "all". | ||
| 115 | -- @return boolean or (nil, string, [string]): True if succeeded or | 116 | -- @return boolean or (nil, string, [string]): True if succeeded or |
| 116 | -- nil and an error message followed by an error code. | 117 | -- nil and an error message followed by an error code. |
| 117 | function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, no_deps) | 118 | function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_mode) |
| 118 | assert(type(rockspec_file) == "string") | 119 | assert(type(rockspec_file) == "string") |
| 119 | assert(type(need_to_fetch) == "boolean") | 120 | assert(type(need_to_fetch) == "boolean") |
| 120 | 121 | ||
| @@ -127,10 +128,10 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, no_deps) | |||
| 127 | return nil, "Rockspec error: build type not specified" | 128 | return nil, "Rockspec error: build type not specified" |
| 128 | end | 129 | end |
| 129 | 130 | ||
| 130 | if no_deps then | 131 | if deps_mode == "none" then |
| 131 | util.printerr("Warning: skipping dependency checks.") | 132 | util.printerr("Warning: skipping dependency checks.") |
| 132 | else | 133 | else |
| 133 | local ok, err, errcode = deps.fulfill_dependencies(rockspec) | 134 | local ok, err, errcode = deps.fulfill_dependencies(rockspec, deps_mode) |
| 134 | if err then | 135 | if err then |
| 135 | return nil, err, errcode | 136 | return nil, err, errcode |
| 136 | end | 137 | end |
| @@ -253,7 +254,7 @@ function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, no_deps) | |||
| 253 | ok, err = repos.run_hook(rockspec, "post_install") | 254 | ok, err = repos.run_hook(rockspec, "post_install") |
| 254 | if err then return nil, err end | 255 | if err then return nil, err end |
| 255 | 256 | ||
| 256 | ok, err = manif.update_manifest(name, version) | 257 | ok, err = manif.update_manifest(name, version, nil, deps_mode) |
| 257 | if err then return nil, err end | 258 | if err then return nil, err end |
| 258 | 259 | ||
| 259 | local license = "" | 260 | local license = "" |
| @@ -273,9 +274,11 @@ end | |||
| 273 | -- @param rock_file string: local or remote filename of a rock. | 274 | -- @param rock_file string: local or remote filename of a rock. |
| 274 | -- @param need_to_fetch boolean: true if sources need to be fetched, | 275 | -- @param need_to_fetch boolean: true if sources need to be fetched, |
| 275 | -- false if the rockspec was obtained from inside a source rock. | 276 | -- false if the rockspec was obtained from inside a source rock. |
| 277 | -- @param deps_mode: string: Which trees to check dependencies for: | ||
| 278 | -- "none", "one", "order" or "all". | ||
| 276 | -- @return boolean or (nil, string, [string]): True if build was successful, | 279 | -- @return boolean or (nil, string, [string]): True if build was successful, |
| 277 | -- or false and an error message and an optional error code. | 280 | -- or false and an error message and an optional error code. |
| 278 | function build_rock(rock_file, need_to_fetch, no_deps) | 281 | function build_rock(rock_file, need_to_fetch, deps_mode) |
| 279 | assert(type(rock_file) == "string") | 282 | assert(type(rock_file) == "string") |
| 280 | assert(type(need_to_fetch) == "boolean") | 283 | assert(type(need_to_fetch) == "boolean") |
| 281 | 284 | ||
| @@ -285,24 +288,24 @@ function build_rock(rock_file, need_to_fetch, no_deps) | |||
| 285 | end | 288 | end |
| 286 | local rockspec_file = path.rockspec_name_from_rock(rock_file) | 289 | local rockspec_file = path.rockspec_name_from_rock(rock_file) |
| 287 | fs.change_dir(unpack_dir) | 290 | fs.change_dir(unpack_dir) |
| 288 | local ok, err, errcode = build_rockspec(rockspec_file, need_to_fetch, false, no_deps) | 291 | local ok, err, errcode = build_rockspec(rockspec_file, need_to_fetch, false, deps_mode) |
| 289 | fs.pop_dir() | 292 | fs.pop_dir() |
| 290 | return ok, err, errcode | 293 | return ok, err, errcode |
| 291 | end | 294 | end |
| 292 | 295 | ||
| 293 | local function do_build(name, version, no_deps) | 296 | local function do_build(name, version, deps_mode) |
| 294 | if name:match("%.rockspec$") then | 297 | if name:match("%.rockspec$") then |
| 295 | return build_rockspec(name, true, false, no_deps) | 298 | return build_rockspec(name, true, false, deps_mode) |
| 296 | elseif name:match("%.src%.rock$") then | 299 | elseif name:match("%.src%.rock$") then |
| 297 | return build_rock(name, false, no_deps) | 300 | return build_rock(name, false, deps_mode) |
| 298 | elseif name:match("%.all%.rock$") then | 301 | elseif name:match("%.all%.rock$") then |
| 299 | local install = require("luarocks.install") | 302 | local install = require("luarocks.install") |
| 300 | return install.install_binary_rock(name, no_deps) | 303 | return install.install_binary_rock(name, deps_mode) |
| 301 | elseif name:match("%.rock$") then | 304 | elseif name:match("%.rock$") then |
| 302 | return build_rock(name, true, no_deps) | 305 | return build_rock(name, true, deps_mode) |
| 303 | elseif not name:match(dir.separator) then | 306 | elseif not name:match(dir.separator) then |
| 304 | local search = require("luarocks.search") | 307 | local search = require("luarocks.search") |
| 305 | return search.act_on_src_or_rockspec(run, name:lower(), version, no_deps and "--nodeps") | 308 | return search.act_on_src_or_rockspec(run, name:lower(), version, deps.deps_mode_to_flag(deps_mode)) |
| 306 | end | 309 | end |
| 307 | return nil, "Don't know what to do with "..name | 310 | return nil, "Don't know what to do with "..name |
| 308 | end | 311 | end |
| @@ -323,10 +326,10 @@ function run(...) | |||
| 323 | assert(type(version) == "string" or not version) | 326 | assert(type(version) == "string" or not version) |
| 324 | 327 | ||
| 325 | if flags["pack-binary-rock"] then | 328 | if flags["pack-binary-rock"] then |
| 326 | return pack.pack_binary_rock(name, version, do_build, name, version, flags["nodeps"]) | 329 | return pack.pack_binary_rock(name, version, do_build, name, version, deps.flags_to_deps_mode(flags)) |
| 327 | else | 330 | else |
| 328 | local ok, err = fs.check_command_permissions(flags) | 331 | local ok, err = fs.check_command_permissions(flags) |
| 329 | if not ok then return nil, err end | 332 | if not ok then return nil, err end |
| 330 | return do_build(name, version, flags["nodeps"]) | 333 | return do_build(name, version, deps.flags_to_deps_mode(flags)) |
| 331 | end | 334 | end |
| 332 | end | 335 | end |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 41adb4e5..b2ed2a96 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -164,6 +164,7 @@ local defaults = { | |||
| 164 | use_extensions = false, | 164 | use_extensions = false, |
| 165 | accept_unknown_fields = false, | 165 | accept_unknown_fields = false, |
| 166 | fs_use_modules = true, | 166 | fs_use_modules = true, |
| 167 | use_trees = "one", | ||
| 167 | 168 | ||
| 168 | lua_modules_path = "/share/lua/"..lua_version, | 169 | lua_modules_path = "/share/lua/"..lua_version, |
| 169 | lib_modules_path = "/lib/lua/"..lua_version, | 170 | lib_modules_path = "/lib/lua/"..lua_version, |
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 00e796b0..a409920a 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) | 315 | local function match_dep(dep, blacklist, use_trees) |
| 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) | 322 | versions = manif_core.get_versions(dep.name, use_trees) |
| 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) | 364 | function match_deps(rockspec, blacklist, use_trees) |
| 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) | 370 | local found = match_dep(dep, blacklist and blacklist[dep.name] or nil, use_trees) |
| 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) | 404 | function fulfill_dependencies(rockspec, use_trees) |
| 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) | |||
| 433 | end | 433 | end |
| 434 | end | 434 | end |
| 435 | 435 | ||
| 436 | local matched, missing, no_upgrade = match_deps(rockspec) | 436 | local matched, missing, no_upgrade = match_deps(rockspec, nil, use_trees) |
| 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) | |||
| 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) then | 470 | if not match_dep(dep, nil, use_trees) 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) | 643 | function scan_deps(results, missing, manifest, name, version, use_trees) |
| 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) | |||
| 669 | else | 669 | else |
| 670 | rockspec = { dependencies = deplist } | 670 | rockspec = { dependencies = deplist } |
| 671 | end | 671 | end |
| 672 | local matched, failures = match_deps(rockspec) | 672 | local matched, failures = match_deps(rockspec, nil, use_trees) |
| 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) | 674 | results, missing = scan_deps(results, missing, manifest, match.name, match.version, use_trees) |
| 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 |
| @@ -681,3 +681,31 @@ function scan_deps(results, missing, manifest, name, version) | |||
| 681 | results[name] = version | 681 | results[name] = version |
| 682 | return results, missing | 682 | return results, missing |
| 683 | end | 683 | end |
| 684 | |||
| 685 | local valid_trees = { | ||
| 686 | one = true, | ||
| 687 | order = true, | ||
| 688 | all = true, | ||
| 689 | } | ||
| 690 | |||
| 691 | function check_trees_flag(flag) | ||
| 692 | return valid_trees[flag] | ||
| 693 | end | ||
| 694 | |||
| 695 | function flags_to_deps_mode(flags) | ||
| 696 | if flags["nodeps"] then | ||
| 697 | return "none" | ||
| 698 | elseif flags["trees"] then | ||
| 699 | return flags["trees"] | ||
| 700 | else | ||
| 701 | return cfg.use_trees | ||
| 702 | end | ||
| 703 | end | ||
| 704 | |||
| 705 | function deps_mode_to_flag(deps_mode) | ||
| 706 | if deps_mode == "none" then | ||
| 707 | return "--nodeps" | ||
| 708 | else | ||
| 709 | return "--trees="..deps_mode | ||
| 710 | end | ||
| 711 | end | ||
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index 6b5ea85f..a940d356 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua | |||
| @@ -23,10 +23,11 @@ or a filename of a locally available rock. | |||
| 23 | 23 | ||
| 24 | --- Install a binary rock. | 24 | --- Install a binary rock. |
| 25 | -- @param rock_file string: local or remote filename of a rock. | 25 | -- @param rock_file string: local or remote filename of a rock. |
| 26 | -- @param no_deps boolean: true if dependency check needs to be skipped | 26 | -- @param deps_mode: string: Which trees to check dependencies for: |
| 27 | -- "none", "one", "order" or "all". | ||
| 27 | -- @return boolean or (nil, string, [string]): True if succeeded or | 28 | -- @return boolean or (nil, string, [string]): True if succeeded or |
| 28 | -- nil and an error message and an optional error code. | 29 | -- nil and an error message and an optional error code. |
| 29 | function install_binary_rock(rock_file, no_deps) | 30 | function install_binary_rock(rock_file, deps_mode) |
| 30 | assert(type(rock_file) == "string") | 31 | assert(type(rock_file) == "string") |
| 31 | 32 | ||
| 32 | local name, version, arch = path.parse_name(rock_file) | 33 | local name, version, arch = path.parse_name(rock_file) |
| @@ -54,7 +55,7 @@ function install_binary_rock(rock_file, no_deps) | |||
| 54 | return nil, "Failed loading rockspec for installed package: "..err, errcode | 55 | return nil, "Failed loading rockspec for installed package: "..err, errcode |
| 55 | end | 56 | end |
| 56 | 57 | ||
| 57 | if no_deps then | 58 | if deps_mode == "none" then |
| 58 | util.printerr("Warning: skipping dependency checks.") | 59 | util.printerr("Warning: skipping dependency checks.") |
| 59 | else | 60 | else |
| 60 | ok, err, errcode = deps.check_external_deps(rockspec, "install") | 61 | ok, err, errcode = deps.check_external_deps(rockspec, "install") |
| @@ -67,8 +68,8 @@ function install_binary_rock(rock_file, no_deps) | |||
| 67 | if err then return nil, err end | 68 | if err then return nil, err end |
| 68 | end | 69 | end |
| 69 | 70 | ||
| 70 | if not no_deps then | 71 | if deps_mode ~= "none" then |
| 71 | ok, err, errcode = deps.fulfill_dependencies(rockspec) | 72 | ok, err, errcode = deps.fulfill_dependencies(rockspec, deps_mode) |
| 72 | if err then return nil, err, errcode end | 73 | if err then return nil, err, errcode end |
| 73 | end | 74 | end |
| 74 | 75 | ||
| @@ -88,7 +89,7 @@ function install_binary_rock(rock_file, no_deps) | |||
| 88 | ok, err = repos.run_hook(rockspec, "post_install") | 89 | ok, err = repos.run_hook(rockspec, "post_install") |
| 89 | if err then return nil, err end | 90 | if err then return nil, err end |
| 90 | 91 | ||
| 91 | ok, err = manif.update_manifest(name, version) | 92 | ok, err = manif.update_manifest(name, version, nil, deps_mode) |
| 92 | if err then return nil, err end | 93 | if err then return nil, err end |
| 93 | 94 | ||
| 94 | local license = "" | 95 | local license = "" |
| @@ -126,9 +127,13 @@ function run(...) | |||
| 126 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then | 127 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then |
| 127 | util.printout("Using "..name.."... switching to 'build' mode") | 128 | util.printout("Using "..name.."... switching to 'build' mode") |
| 128 | local build = require("luarocks.build") | 129 | local build = require("luarocks.build") |
| 129 | return build.run(name, flags["local"] and "--local") | 130 | local build_flags = {} |
| 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)) | ||
| 130 | elseif name:match("%.rock$") then | 135 | elseif name:match("%.rock$") then |
| 131 | return install_binary_rock(name, flags["nodeps"]) | 136 | return install_binary_rock(name, deps.flags_to_deps_mode(flags)) |
| 132 | else | 137 | else |
| 133 | local search = require("luarocks.search") | 138 | local search = require("luarocks.search") |
| 134 | local results, err = search.find_suitable_rock(search.make_query(name:lower(), version)) | 139 | 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 769db2f7..498445d8 100644 --- a/src/luarocks/make.lua +++ b/src/luarocks/make.lua | |||
| @@ -11,6 +11,7 @@ local util = require("luarocks.util") | |||
| 11 | local cfg = require("luarocks.cfg") | 11 | local cfg = require("luarocks.cfg") |
| 12 | local fetch = require("luarocks.fetch") | 12 | local fetch = require("luarocks.fetch") |
| 13 | local pack = require("luarocks.pack") | 13 | local pack = require("luarocks.pack") |
| 14 | local deps = require("luarocks.deps") | ||
| 14 | 15 | ||
| 15 | help_summary = "Compile package in current directory using a rockspec." | 16 | help_summary = "Compile package in current directory using a rockspec." |
| 16 | help_arguments = "[--pack-binary-rock] [<rockspec>]" | 17 | help_arguments = "[--pack-binary-rock] [<rockspec>]" |
| @@ -62,10 +63,10 @@ function run(...) | |||
| 62 | if not rspec then | 63 | if not rspec then |
| 63 | return nil, err | 64 | return nil, err |
| 64 | end | 65 | end |
| 65 | return pack.pack_binary_rock(rspec.name, rspec.version, build.build_rockspec, rockspec, false, true, flags["nodeps"]) | 66 | return pack.pack_binary_rock(rspec.name, rspec.version, build.build_rockspec, rockspec, false, true, deps.flags_to_deps_mode(flags)) |
| 66 | else | 67 | else |
| 67 | local ok, err = fs.check_command_permissions(flags) | 68 | local ok, err = fs.check_command_permissions(flags) |
| 68 | if not ok then return nil, err end | 69 | if not ok then return nil, err end |
| 69 | return build.build_rockspec(rockspec, false, true) | 70 | return build.build_rockspec(rockspec, false, true, deps.flags_to_deps_mode(flags)) |
| 70 | end | 71 | end |
| 71 | end | 72 | end |
diff --git a/src/luarocks/make_manifest.lua b/src/luarocks/make_manifest.lua index 07d2fd05..e629b9de 100644 --- a/src/luarocks/make_manifest.lua +++ b/src/luarocks/make_manifest.lua | |||
| @@ -7,6 +7,7 @@ local manif = require("luarocks.manif") | |||
| 7 | local index = require("luarocks.index") | 7 | local index = require("luarocks.index") |
| 8 | local cfg = require("luarocks.cfg") | 8 | local cfg = require("luarocks.cfg") |
| 9 | local util = require("luarocks.util") | 9 | local util = require("luarocks.util") |
| 10 | local deps = require("luarocks.deps") | ||
| 10 | 11 | ||
| 11 | help_summary = "Compile a manifest file for a repository." | 12 | help_summary = "Compile a manifest file for a repository." |
| 12 | 13 | ||
| @@ -19,13 +20,15 @@ help = [[ | |||
| 19 | -- the default local repository configured as cfg.rocks_dir is used. | 20 | -- the default local repository configured as cfg.rocks_dir is used. |
| 20 | -- @return boolean or (nil, string): True if manifest was generated, | 21 | -- @return boolean or (nil, string): True if manifest was generated, |
| 21 | -- or nil and an error message. | 22 | -- or nil and an error message. |
| 22 | function run(repo) | 23 | function run(...) |
| 24 | local flags, repo = util.parse_flags(...) | ||
| 25 | |||
| 23 | assert(type(repo) == "string" or not repo) | 26 | assert(type(repo) == "string" or not repo) |
| 24 | repo = repo or cfg.rocks_dir | 27 | repo = repo or cfg.rocks_dir |
| 25 | 28 | ||
| 26 | util.printout("Making manifest for "..repo) | 29 | util.printout("Making manifest for "..repo) |
| 27 | 30 | ||
| 28 | local ok, err = manif.make_manifest(repo) | 31 | local ok, err = manif.make_manifest(repo, deps.flags_to_deps_mode(flags)) |
| 29 | if ok then | 32 | if ok then |
| 30 | util.printout("Generating index.html for "..repo) | 33 | util.printout("Generating index.html for "..repo) |
| 31 | index.make_index(repo) | 34 | index.make_index(repo) |
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua index 2c745f0b..9e5ee823 100644 --- a/src/luarocks/manif.lua +++ b/src/luarocks/manif.lua | |||
| @@ -185,14 +185,14 @@ 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) | 188 | local function update_dependencies(manifest, use_trees) |
| 189 | for pkg, versions in pairs(manifest.repository) do | 189 | for pkg, versions in pairs(manifest.repository) do |
| 190 | for version, repositories in pairs(versions) do | 190 | for version, repositories in pairs(versions) do |
| 191 | local current = pkg.." "..version | 191 | local current = pkg.." "..version |
| 192 | for _, repo in ipairs(repositories) do | 192 | for _, repo in ipairs(repositories) do |
| 193 | if repo.arch == "installed" then | 193 | if repo.arch == "installed" then |
| 194 | local missing | 194 | local missing |
| 195 | repo.dependencies, missing = deps.scan_deps({}, {}, manifest, pkg, version) | 195 | repo.dependencies, missing = deps.scan_deps({}, {}, manifest, pkg, version, use_trees) |
| 196 | repo.dependencies[pkg] = nil | 196 | repo.dependencies[pkg] = nil |
| 197 | if missing then | 197 | if missing then |
| 198 | for miss, err in pairs(missing) do | 198 | for miss, err in pairs(missing) do |
| @@ -214,7 +214,7 @@ end | |||
| 214 | -- @param manifest table: A manifest table (must contain repository, modules, commands tables). | 214 | -- @param manifest table: A manifest table (must contain repository, modules, commands tables). |
| 215 | -- It will be altered to include the search results. | 215 | -- 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. | 216 | -- @return boolean or (nil, string): true in case of success, or nil followed by an error message. |
| 217 | local function store_results(results, manifest) | 217 | local function store_results(results, manifest, use_trees) |
| 218 | assert(type(results) == "table") | 218 | assert(type(results) == "table") |
| 219 | assert(type(manifest) == "table") | 219 | assert(type(manifest) == "table") |
| 220 | 220 | ||
| @@ -239,7 +239,7 @@ local function store_results(results, manifest) | |||
| 239 | end | 239 | end |
| 240 | manifest.repository[name] = pkgtable | 240 | manifest.repository[name] = pkgtable |
| 241 | end | 241 | end |
| 242 | update_dependencies(manifest) | 242 | update_dependencies(manifest, use_trees) |
| 243 | sort_package_matching_table(manifest.modules) | 243 | sort_package_matching_table(manifest.modules) |
| 244 | sort_package_matching_table(manifest.commands) | 244 | sort_package_matching_table(manifest.commands) |
| 245 | return true | 245 | return true |
| @@ -251,9 +251,11 @@ end | |||
| 251 | -- @param repo A local repository directory. | 251 | -- @param repo A local repository directory. |
| 252 | -- @return boolean or (nil, string): True if manifest was generated, | 252 | -- @return boolean or (nil, string): True if manifest was generated, |
| 253 | -- or nil and an error message. | 253 | -- or nil and an error message. |
| 254 | function make_manifest(repo) | 254 | function make_manifest(repo, use_trees) |
| 255 | assert(type(repo) == "string") | 255 | assert(type(repo) == "string") |
| 256 | 256 | ||
| 257 | if use_trees == "none" then use_trees = cfg.use_trees end | ||
| 258 | |||
| 257 | if not fs.is_dir(repo) then | 259 | if not fs.is_dir(repo) then |
| 258 | return nil, "Cannot access repository at "..repo | 260 | return nil, "Cannot access repository at "..repo |
| 259 | end | 261 | end |
| @@ -265,7 +267,7 @@ function make_manifest(repo) | |||
| 265 | local manifest = { repository = {}, modules = {}, commands = {} } | 267 | local manifest = { repository = {}, modules = {}, commands = {} } |
| 266 | manif_core.manifest_cache[repo] = manifest | 268 | manif_core.manifest_cache[repo] = manifest |
| 267 | 269 | ||
| 268 | local ok, err = store_results(results, manifest) | 270 | local ok, err = store_results(results, manifest, use_trees) |
| 269 | if not ok then return nil, err end | 271 | if not ok then return nil, err end |
| 270 | 272 | ||
| 271 | return save_table(repo, "manifest", manifest) | 273 | return save_table(repo, "manifest", manifest) |
| @@ -281,17 +283,19 @@ end | |||
| 281 | -- the default local repository configured as cfg.rocks_dir is used. | 283 | -- the default local repository configured as cfg.rocks_dir is used. |
| 282 | -- @return boolean or (nil, string): True if manifest was generated, | 284 | -- @return boolean or (nil, string): True if manifest was generated, |
| 283 | -- or nil and an error message. | 285 | -- or nil and an error message. |
| 284 | function update_manifest(name, version, repo) | 286 | function update_manifest(name, version, repo, use_trees) |
| 285 | assert(type(name) == "string") | 287 | assert(type(name) == "string") |
| 286 | assert(type(version) == "string") | 288 | assert(type(version) == "string") |
| 287 | repo = path.rocks_dir(repo or cfg.root_dir) | 289 | repo = path.rocks_dir(repo or cfg.root_dir) |
| 290 | |||
| 291 | if use_trees == "none" then use_trees = cfg.use_trees end | ||
| 288 | 292 | ||
| 289 | util.printout("Updating manifest for "..repo) | 293 | util.printout("Updating manifest for "..repo) |
| 290 | 294 | ||
| 291 | local manifest, err = load_manifest(repo) | 295 | local manifest, err = load_manifest(repo) |
| 292 | if not manifest then | 296 | if not manifest then |
| 293 | util.printerr("No existing manifest. Attempting to rebuild...") | 297 | util.printerr("No existing manifest. Attempting to rebuild...") |
| 294 | local ok, err = make_manifest(repo) | 298 | local ok, err = make_manifest(repo, use_trees) |
| 295 | if not ok then | 299 | if not ok then |
| 296 | return nil, err | 300 | return nil, err |
| 297 | end | 301 | end |
| @@ -303,7 +307,7 @@ function update_manifest(name, version, repo) | |||
| 303 | 307 | ||
| 304 | local results = {[name] = {[version] = {{arch = "installed", repo = repo}}}} | 308 | local results = {[name] = {[version] = {{arch = "installed", repo = repo}}}} |
| 305 | 309 | ||
| 306 | local ok, err = store_results(results, manifest) | 310 | local ok, err = store_results(results, manifest, use_trees) |
| 307 | if not ok then return nil, err end | 311 | if not ok then return nil, err end |
| 308 | 312 | ||
| 309 | return save_table(repo, "manifest", manifest) | 313 | return save_table(repo, "manifest", manifest) |
diff --git a/src/luarocks/manif_core.lua b/src/luarocks/manif_core.lua index 40f16898..ed6cac07 100644 --- a/src/luarocks/manif_core.lua +++ b/src/luarocks/manif_core.lua | |||
| @@ -8,6 +8,7 @@ local type_check = require("luarocks.type_check") | |||
| 8 | local dir = require("luarocks.dir") | 8 | local dir = require("luarocks.dir") |
| 9 | local util = require("luarocks.util") | 9 | local util = require("luarocks.util") |
| 10 | local cfg = require("luarocks.cfg") | 10 | local cfg = require("luarocks.cfg") |
| 11 | local path = require("luarocks.path") | ||
| 11 | 12 | ||
| 12 | manifest_cache = {} | 13 | manifest_cache = {} |
| 13 | 14 | ||
| @@ -52,22 +53,40 @@ end | |||
| 52 | 53 | ||
| 53 | --- Get all versions of a package listed in a manifest file. | 54 | --- Get all versions of a package listed in a manifest file. |
| 54 | -- @param name string: a package name. | 55 | -- @param name string: a package name. |
| 55 | -- @param manifest table or nil: a manifest table; if not given, the | 56 | -- @param use_trees string: "one", to use only the currently |
| 56 | -- default local manifest table is used. | 57 | -- configured tree; "order" to select trees based on order |
| 58 | -- (use the current tree and all trees below it on the list) | ||
| 59 | -- or "all", to use all trees. | ||
| 57 | -- @return table: An array of strings listing installed | 60 | -- @return table: An array of strings listing installed |
| 58 | -- versions of a package. | 61 | -- versions of a package. |
| 59 | function get_versions(name, manifest) | 62 | function get_versions(name, use_trees) |
| 60 | assert(type(name) == "string") | 63 | assert(type(name) == "string") |
| 61 | assert(type(manifest) == "table" or not manifest) | 64 | assert(type(use_trees) == "string") |
| 62 | 65 | ||
| 63 | if not manifest then | 66 | local manifest |
| 67 | |||
| 68 | if use_trees == "one" then | ||
| 64 | manifest = load_local_manifest(cfg.rocks_dir) | 69 | manifest = load_local_manifest(cfg.rocks_dir) |
| 65 | if not manifest then | 70 | elseif use_trees == "all" or use_trees == "order" then |
| 66 | return {} | 71 | manifest = {} |
| 72 | local use = false | ||
| 73 | if use_trees == "all" then | ||
| 74 | use = true | ||
| 75 | end | ||
| 76 | for _, tree in ipairs(cfg.rocks_trees) do | ||
| 77 | if tree == cfg.rocks_dir then | ||
| 78 | use = true | ||
| 79 | end | ||
| 80 | if use then | ||
| 81 | local loaded = load_local_manifest(path.rocks_dir(tree)) | ||
| 82 | if loaded then | ||
| 83 | util.deep_merge(manifest, loaded) | ||
| 84 | end | ||
| 85 | end | ||
| 67 | end | 86 | end |
| 68 | end | 87 | end |
| 69 | 88 | ||
| 70 | local item = manifest.repository[name] | 89 | local item = manifest and manifest.repository[name] |
| 71 | if item then | 90 | if item then |
| 72 | return util.keys(item) | 91 | return util.keys(item) |
| 73 | end | 92 | end |
diff --git a/src/luarocks/purge.lua b/src/luarocks/purge.lua index dc6b822d..ca682f7d 100644 --- a/src/luarocks/purge.lua +++ b/src/luarocks/purge.lua | |||
| @@ -44,5 +44,5 @@ function run(...) | |||
| 44 | end | 44 | end |
| 45 | end | 45 | end |
| 46 | end | 46 | end |
| 47 | return manif.make_manifest(cfg.rocks_dir) | 47 | return manif.make_manifest(cfg.rocks_dir, "one") |
| 48 | end | 48 | end |
diff --git a/src/luarocks/remove.lua b/src/luarocks/remove.lua index a9d97540..261dc1c4 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) | 31 | local function check_dependents(name, versions, use_trees) |
| 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) | |||
| 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) | 47 | local _, missing = deps.match_deps(rockspec, blacklist, use_trees) |
| 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,11 +78,17 @@ 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 | ||
| 81 | 85 | ||
| 82 | if type(name) ~= "string" then | 86 | if type(name) ~= "string" then |
| 83 | return nil, "Argument missing, see help." | 87 | return nil, "Argument missing, see help." |
| 84 | end | 88 | end |
| 85 | 89 | ||
| 90 | local use_trees = flags["trees"] or cfg.use_trees | ||
| 91 | |||
| 86 | local ok, err = fs.check_command_permissions(flags) | 92 | local ok, err = fs.check_command_permissions(flags) |
| 87 | if not ok then return nil, err end | 93 | if not ok then return nil, err end |
| 88 | 94 | ||
| @@ -100,7 +106,7 @@ function run(...) | |||
| 100 | util.printout(name.." "..table.concat(util.keys(versions), ", ").."...") | 106 | util.printout(name.." "..table.concat(util.keys(versions), ", ").."...") |
| 101 | util.printout() | 107 | util.printout() |
| 102 | 108 | ||
| 103 | local dependents = check_dependents(name, versions) | 109 | local dependents = check_dependents(name, versions, use_trees) |
| 104 | 110 | ||
| 105 | if #dependents == 0 or flags["force"] then | 111 | if #dependents == 0 or flags["force"] then |
| 106 | if #dependents > 0 then | 112 | if #dependents > 0 then |
| @@ -112,7 +118,7 @@ function run(...) | |||
| 112 | end | 118 | end |
| 113 | local ok, err = delete_versions(name, versions) | 119 | local ok, err = delete_versions(name, versions) |
| 114 | if not ok then return nil, err end | 120 | if not ok then return nil, err end |
| 115 | ok, err = manif.make_manifest(cfg.rocks_dir) | 121 | ok, err = manif.make_manifest(cfg.rocks_dir, use_trees) |
| 116 | if not ok then return nil, err end | 122 | if not ok then return nil, err end |
| 117 | else | 123 | else |
| 118 | if not second then | 124 | if not second then |
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index 30c61f55..3a337e7c 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua | |||
| @@ -14,7 +14,7 @@ local deps = require("luarocks.deps") | |||
| 14 | -- @param name string: a package name. | 14 | -- @param name string: a package name. |
| 15 | -- @return table or nil: An array of strings listing installed | 15 | -- @return table or nil: An array of strings listing installed |
| 16 | -- versions of a package, or nil if none is available. | 16 | -- versions of a package, or nil if none is available. |
| 17 | function get_versions(name) | 17 | local function get_installed_versions(name) |
| 18 | assert(type(name) == "string") | 18 | assert(type(name) == "string") |
| 19 | 19 | ||
| 20 | local dirs = fs.list_dir(path.versions_dir(name)) | 20 | local dirs = fs.list_dir(path.versions_dir(name)) |
| @@ -229,7 +229,7 @@ function deploy_files(name, version, wrap_bin_scripts) | |||
| 229 | else | 229 | else |
| 230 | target = new_target | 230 | target = new_target |
| 231 | end | 231 | end |
| 232 | end | 232 | end |
| 233 | fs.make_dir(dir.dir_name(target)) | 233 | fs.make_dir(dir.dir_name(target)) |
| 234 | ok, err = move_fn(source, target) | 234 | ok, err = move_fn(source, target) |
| 235 | fs.remove_dir_tree_if_empty(dir.dir_name(source)) | 235 | fs.remove_dir_tree_if_empty(dir.dir_name(source)) |
| @@ -312,7 +312,7 @@ function delete_version(name, version, quick) | |||
| 312 | if err then return nil, err end | 312 | if err then return nil, err end |
| 313 | 313 | ||
| 314 | fs.delete(path.install_dir(name, version)) | 314 | fs.delete(path.install_dir(name, version)) |
| 315 | if not get_versions(name) then | 315 | if not get_installed_versions(name) then |
| 316 | fs.delete(dir.path(cfg.rocks_dir, name)) | 316 | fs.delete(dir.path(cfg.rocks_dir, name)) |
| 317 | end | 317 | end |
| 318 | return true | 318 | return true |
diff --git a/src/luarocks/validate.lua b/src/luarocks/validate.lua index 03e90ecf..fb6a78ad 100644 --- a/src/luarocks/validate.lua +++ b/src/luarocks/validate.lua | |||
| @@ -50,7 +50,7 @@ local function prepare_sandbox(file) | |||
| 50 | end | 50 | end |
| 51 | 51 | ||
| 52 | local function validate_rockspec(file) | 52 | local function validate_rockspec(file) |
| 53 | local ok, err, errcode = build.build_rockspec(file, true) | 53 | local ok, err, errcode = build.build_rockspec(file, true, "one") |
| 54 | if not ok then | 54 | if not ok then |
| 55 | util.printerr(err) | 55 | util.printerr(err) |
| 56 | end | 56 | end |
| @@ -58,7 +58,7 @@ local function validate_rockspec(file) | |||
| 58 | end | 58 | end |
| 59 | 59 | ||
| 60 | local function validate_src_rock(file) | 60 | local function validate_src_rock(file) |
| 61 | local ok, err, errcode = build.build_rock(file, false) | 61 | local ok, err, errcode = build.build_rock(file, false, "one") |
| 62 | if not ok then | 62 | if not ok then |
| 63 | util.printerr(err) | 63 | util.printerr(err) |
| 64 | end | 64 | end |
| @@ -66,7 +66,7 @@ local function validate_src_rock(file) | |||
| 66 | end | 66 | end |
| 67 | 67 | ||
| 68 | local function validate_rock(file) | 68 | local function validate_rock(file) |
| 69 | local ok, err, errcode = install.install_binary_rock(file) | 69 | local ok, err, errcode = install.install_binary_rock(file, "one") |
| 70 | if not ok then | 70 | if not ok then |
| 71 | util.printerr(err) | 71 | util.printerr(err) |
| 72 | end | 72 | end |
| @@ -97,7 +97,7 @@ local function validate(repo, flags) | |||
| 97 | util.printout() | 97 | util.printout() |
| 98 | util.printout("Verifying "..pathname) | 98 | util.printout("Verifying "..pathname) |
| 99 | if file:match("%.rockspec$") then | 99 | if file:match("%.rockspec$") then |
| 100 | ok, err, errcode = validate_rockspec(pathname) | 100 | ok, err, errcode = validate_rockspec(pathname, "one") |
| 101 | elseif file:match("%.src%.rock$") then | 101 | elseif file:match("%.src%.rock$") then |
| 102 | ok, err, errcode = validate_src_rock(pathname) | 102 | ok, err, errcode = validate_src_rock(pathname) |
| 103 | elseif file:match("%.rock$") then | 103 | elseif file:match("%.rock$") then |
