diff options
Diffstat (limited to 'src')
-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 | 5 | ||||
-rw-r--r-- | src/luarocks/deps.lua | 48 | ||||
-rw-r--r-- | src/luarocks/dir.lua | 4 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 40 | ||||
-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 | 24 | ||||
-rw-r--r-- | src/luarocks/path.lua | 28 | ||||
-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/util.lua | 2 | ||||
-rw-r--r-- | src/luarocks/validate.lua | 8 |
18 files changed, 179 insertions, 96 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..330fabca 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, |
@@ -276,7 +277,7 @@ if detected.windows then | |||
276 | lib = { "?.dll", "lib?.dll" }, | 277 | lib = { "?.dll", "lib?.dll" }, |
277 | include = { "?.h" } | 278 | include = { "?.h" } |
278 | } | 279 | } |
279 | defaults.export_path = "SET PATH=%s;%s" | 280 | defaults.export_path = "SET PATH=%s" |
280 | defaults.export_path_separator = ";" | 281 | defaults.export_path_separator = ";" |
281 | defaults.export_lua_path = "SET LUA_PATH=%s" | 282 | defaults.export_lua_path = "SET LUA_PATH=%s" |
282 | defaults.export_lua_cpath = "SET LUA_CPATH=%s" | 283 | defaults.export_lua_cpath = "SET LUA_CPATH=%s" |
@@ -321,7 +322,7 @@ if detected.unix then | |||
321 | lib = { "lib?.so", "lib?.so.*" }, | 322 | lib = { "lib?.so", "lib?.so.*" }, |
322 | include = { "?.h" } | 323 | include = { "?.h" } |
323 | } | 324 | } |
324 | defaults.export_path = "export PATH='%s:%s'" | 325 | defaults.export_path = "export PATH='%s'" |
325 | defaults.export_path_separator = ":" | 326 | defaults.export_path_separator = ":" |
326 | defaults.export_lua_path = "export LUA_PATH='%s'" | 327 | defaults.export_lua_path = "export LUA_PATH='%s'" |
327 | defaults.export_lua_cpath = "export LUA_CPATH='%s'" | 328 | defaults.export_lua_cpath = "export LUA_CPATH='%s'" |
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/dir.lua b/src/luarocks/dir.lua index 3de9e241..c2309ff1 100644 --- a/src/luarocks/dir.lua +++ b/src/luarocks/dir.lua | |||
@@ -68,3 +68,7 @@ function split_url(url) | |||
68 | end | 68 | end |
69 | return protocol, pathname | 69 | return protocol, pathname |
70 | end | 70 | end |
71 | |||
72 | function normalize(name) | ||
73 | return name:gsub("\\", "/"):gsub("(.)/*$", "%1") | ||
74 | end | ||
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index c413ccb3..eba61214 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -43,10 +43,6 @@ function Q(arg) | |||
43 | return "'" .. arg:gsub("\\", "\\\\"):gsub("'", "'\\''") .. "'" | 43 | return "'" .. arg:gsub("\\", "\\\\"):gsub("'", "'\\''") .. "'" |
44 | end | 44 | end |
45 | 45 | ||
46 | local function normalize(name) | ||
47 | return name:gsub("\\", "/"):gsub("(.)/*$", "%1") | ||
48 | end | ||
49 | |||
50 | --- Test is file/dir is writable. | 46 | --- Test is file/dir is writable. |
51 | -- Warning: testing if a file/dir is writable does not guarantee | 47 | -- Warning: testing if a file/dir is writable does not guarantee |
52 | -- that it will remain writable and therefore it is no replacement | 48 | -- that it will remain writable and therefore it is no replacement |
@@ -55,7 +51,7 @@ end | |||
55 | -- @return boolean: true if file exists, false otherwise. | 51 | -- @return boolean: true if file exists, false otherwise. |
56 | function is_writable(file) | 52 | function is_writable(file) |
57 | assert(file) | 53 | assert(file) |
58 | file = normalize(file) | 54 | file = dir.normalize(file) |
59 | local result | 55 | local result |
60 | if fs.is_dir(file) then | 56 | if fs.is_dir(file) then |
61 | local file2 = dir.path(file, '.tmpluarockstestwritable') | 57 | local file2 = dir.path(file, '.tmpluarockstestwritable') |
@@ -77,7 +73,7 @@ end | |||
77 | -- @return string or nil: name of temporary directory or nil on failure. | 73 | -- @return string or nil: name of temporary directory or nil on failure. |
78 | function make_temp_dir(name) | 74 | function make_temp_dir(name) |
79 | assert(type(name) == "string") | 75 | assert(type(name) == "string") |
80 | name = normalize(name) | 76 | name = dir.normalize(name) |
81 | 77 | ||
82 | local temp_dir = (os.getenv("TMP") or "/tmp") .. "/luarocks_" .. name:gsub(dir.separator, "_") .. "-" .. tostring(math.floor(math.random() * 10000)) | 78 | local temp_dir = (os.getenv("TMP") or "/tmp") .. "/luarocks_" .. name:gsub(dir.separator, "_") .. "-" .. tostring(math.floor(math.random() * 10000)) |
83 | if fs.make_dir(temp_dir) then | 79 | if fs.make_dir(temp_dir) then |
@@ -110,7 +106,7 @@ end | |||
110 | -- @return boolean: true if the MD5 checksum for 'file' equals 'md5sum', false if not | 106 | -- @return boolean: true if the MD5 checksum for 'file' equals 'md5sum', false if not |
111 | -- or if it could not perform the check for any reason. | 107 | -- or if it could not perform the check for any reason. |
112 | function check_md5(file, md5sum) | 108 | function check_md5(file, md5sum) |
113 | file = normalize(file) | 109 | file = dir.normalize(file) |
114 | local computed = fs.get_md5(file) | 110 | local computed = fs.get_md5(file) |
115 | if not computed then | 111 | if not computed then |
116 | return false | 112 | return false |
@@ -156,7 +152,7 @@ end | |||
156 | -- @param d string: The directory to switch to. | 152 | -- @param d string: The directory to switch to. |
157 | function change_dir(d) | 153 | function change_dir(d) |
158 | table.insert(dir_stack, lfs.currentdir()) | 154 | table.insert(dir_stack, lfs.currentdir()) |
159 | d = normalize(d) | 155 | d = dir.normalize(d) |
160 | lfs.chdir(d) | 156 | lfs.chdir(d) |
161 | end | 157 | end |
162 | 158 | ||
@@ -187,7 +183,7 @@ end | |||
187 | -- @return boolean: true on success, false on failure. | 183 | -- @return boolean: true on success, false on failure. |
188 | function make_dir(directory) | 184 | function make_dir(directory) |
189 | assert(type(directory) == "string") | 185 | assert(type(directory) == "string") |
190 | directory = normalize(directory) | 186 | directory = dir.normalize(directory) |
191 | local path = nil | 187 | local path = nil |
192 | if directory:sub(2, 2) == ":" then | 188 | if directory:sub(2, 2) == ":" then |
193 | path = directory:sub(1, 2) | 189 | path = directory:sub(1, 2) |
@@ -217,7 +213,7 @@ end | |||
217 | -- @param d string: pathname of directory to remove. | 213 | -- @param d string: pathname of directory to remove. |
218 | function remove_dir_if_empty(d) | 214 | function remove_dir_if_empty(d) |
219 | assert(d) | 215 | assert(d) |
220 | d = normalize(d) | 216 | d = dir.normalize(d) |
221 | lfs.rmdir(d) | 217 | lfs.rmdir(d) |
222 | end | 218 | end |
223 | 219 | ||
@@ -227,7 +223,7 @@ end | |||
227 | -- @param d string: pathname of directory to remove. | 223 | -- @param d string: pathname of directory to remove. |
228 | function remove_dir_tree_if_empty(d) | 224 | function remove_dir_tree_if_empty(d) |
229 | assert(d) | 225 | assert(d) |
230 | d = normalize(d) | 226 | d = dir.normalize(d) |
231 | for i=1,10 do | 227 | for i=1,10 do |
232 | lfs.rmdir(d) | 228 | lfs.rmdir(d) |
233 | d = dir.dir_name(d) | 229 | d = dir.dir_name(d) |
@@ -243,8 +239,8 @@ end | |||
243 | -- plus an error message. | 239 | -- plus an error message. |
244 | function copy(src, dest, perms) | 240 | function copy(src, dest, perms) |
245 | assert(src and dest) | 241 | assert(src and dest) |
246 | src = normalize(src) | 242 | src = dir.normalize(src) |
247 | dest = normalize(dest) | 243 | dest = dir.normalize(dest) |
248 | local destmode = lfs.attributes(dest, "mode") | 244 | local destmode = lfs.attributes(dest, "mode") |
249 | if destmode == "directory" then | 245 | if destmode == "directory" then |
250 | dest = dir.path(dest, dir.base_name(src)) | 246 | dest = dir.path(dest, dir.base_name(src)) |
@@ -296,8 +292,8 @@ end | |||
296 | -- plus an error message. | 292 | -- plus an error message. |
297 | function copy_contents(src, dest) | 293 | function copy_contents(src, dest) |
298 | assert(src and dest) | 294 | assert(src and dest) |
299 | src = normalize(src) | 295 | src = dir.normalize(src) |
300 | dest = normalize(dest) | 296 | dest = dir.normalize(dest) |
301 | assert(lfs.attributes(src, "mode") == "directory") | 297 | assert(lfs.attributes(src, "mode") == "directory") |
302 | 298 | ||
303 | for file in lfs.dir(src) do | 299 | for file in lfs.dir(src) do |
@@ -338,7 +334,7 @@ end | |||
338 | -- @param name string: Pathname of source | 334 | -- @param name string: Pathname of source |
339 | -- @return boolean: true on success, false on failure. | 335 | -- @return boolean: true on success, false on failure. |
340 | function delete(name) | 336 | function delete(name) |
341 | name = normalize(name) | 337 | name = dir.normalize(name) |
342 | return recursive_delete(name) or false | 338 | return recursive_delete(name) or false |
343 | end | 339 | end |
344 | 340 | ||
@@ -352,7 +348,7 @@ function list_dir(at) | |||
352 | if not at then | 348 | if not at then |
353 | at = fs.current_dir() | 349 | at = fs.current_dir() |
354 | end | 350 | end |
355 | at = normalize(at) | 351 | at = dir.normalize(at) |
356 | if not fs.is_dir(at) then | 352 | if not fs.is_dir(at) then |
357 | return {} | 353 | return {} |
358 | end | 354 | end |
@@ -393,7 +389,7 @@ function find(at) | |||
393 | if not at then | 389 | if not at then |
394 | at = fs.current_dir() | 390 | at = fs.current_dir() |
395 | end | 391 | end |
396 | at = normalize(at) | 392 | at = dir.normalize(at) |
397 | if not fs.is_dir(at) then | 393 | if not fs.is_dir(at) then |
398 | return {} | 394 | return {} |
399 | end | 395 | end |
@@ -407,7 +403,7 @@ end | |||
407 | -- @return boolean: true if file exists, false otherwise. | 403 | -- @return boolean: true if file exists, false otherwise. |
408 | function exists(file) | 404 | function exists(file) |
409 | assert(file) | 405 | assert(file) |
410 | file = normalize(file) | 406 | file = dir.normalize(file) |
411 | return type(lfs.attributes(file)) == "table" | 407 | return type(lfs.attributes(file)) == "table" |
412 | end | 408 | end |
413 | 409 | ||
@@ -416,7 +412,7 @@ end | |||
416 | -- @return boolean: true if it is a directory, false otherwise. | 412 | -- @return boolean: true if it is a directory, false otherwise. |
417 | function is_dir(file) | 413 | function is_dir(file) |
418 | assert(file) | 414 | assert(file) |
419 | file = normalize(file) | 415 | file = dir.normalize(file) |
420 | return lfs.attributes(file, "mode") == "directory" | 416 | return lfs.attributes(file, "mode") == "directory" |
421 | end | 417 | end |
422 | 418 | ||
@@ -425,12 +421,12 @@ end | |||
425 | -- @return boolean: true if it is a file, false otherwise. | 421 | -- @return boolean: true if it is a file, false otherwise. |
426 | function is_file(file) | 422 | function is_file(file) |
427 | assert(file) | 423 | assert(file) |
428 | file = normalize(file) | 424 | file = dir.normalize(file) |
429 | return lfs.attributes(file, "mode") == "file" | 425 | return lfs.attributes(file, "mode") == "file" |
430 | end | 426 | end |
431 | 427 | ||
432 | function set_time(file, time) | 428 | function set_time(file, time) |
433 | file = normalize(file) | 429 | file = dir.normalize(file) |
434 | return lfs.touch(file, time) | 430 | return lfs.touch(file, time) |
435 | end | 431 | end |
436 | 432 | ||
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..6af99fe7 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,25 @@ 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 = {} |
64 | manifest = load_local_manifest(cfg.rocks_dir) | 67 | path.map_trees(use_trees, function(tree) |
65 | if not manifest then | 68 | local loaded = load_local_manifest(path.rocks_dir(tree)) |
66 | return {} | 69 | if loaded then |
70 | util.deep_merge(manifest, loaded) | ||
67 | end | 71 | end |
68 | end | 72 | end) |
69 | 73 | ||
70 | local item = manifest.repository[name] | 74 | local item = next(manifest) and manifest.repository[name] |
71 | if item then | 75 | if item then |
72 | return util.keys(item) | 76 | return util.keys(item) |
73 | end | 77 | end |
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index bbd928a0..17d9d52b 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -7,6 +7,7 @@ module("luarocks.path", package.seeall) | |||
7 | local dir = require("luarocks.dir") | 7 | local dir = require("luarocks.dir") |
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 = "Return the currently configured package path." | 12 | help_summary = "Return the currently configured package path." |
12 | help_arguments = "" | 13 | help_arguments = "" |
@@ -305,6 +306,27 @@ function use_tree(tree) | |||
305 | cfg.deploy_lib_dir = deploy_lib_dir(tree) | 306 | cfg.deploy_lib_dir = deploy_lib_dir(tree) |
306 | end | 307 | end |
307 | 308 | ||
309 | function map_trees(use_trees, fn, ...) | ||
310 | local result = {} | ||
311 | if use_trees == "one" then | ||
312 | table.insert(result, fn(cfg.root_dir, ...)) | ||
313 | elseif use_trees == "all" or use_trees == "order" then | ||
314 | local use = false | ||
315 | if use_trees == "all" then | ||
316 | use = true | ||
317 | end | ||
318 | for _, tree in ipairs(cfg.rocks_trees) do | ||
319 | if dir.normalize(tree) == dir.normalize(cfg.root_dir) then | ||
320 | use = true | ||
321 | end | ||
322 | if use then | ||
323 | table.insert(result, fn(tree, ...)) | ||
324 | end | ||
325 | end | ||
326 | end | ||
327 | return result | ||
328 | end | ||
329 | |||
308 | --- Return the pathname of the file that would be loaded for a module, indexed. | 330 | --- Return the pathname of the file that would be loaded for a module, indexed. |
309 | -- @param module_name string: module name (eg. "socket.core") | 331 | -- @param module_name string: module name (eg. "socket.core") |
310 | -- @param name string: name of the package (eg. "luasocket") | 332 | -- @param name string: name of the package (eg. "luasocket") |
@@ -352,10 +374,14 @@ end | |||
352 | -- @return boolean This function always succeeds. | 374 | -- @return boolean This function always succeeds. |
353 | function run(...) | 375 | function run(...) |
354 | local flags = util.parse_flags(...) | 376 | local flags = util.parse_flags(...) |
377 | local deps_mode = deps.flags_to_deps_mode(flags) | ||
378 | |||
355 | 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, ';'))) |
356 | 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, ';'))) |
357 | if flags["bin"] then | 381 | if flags["bin"] then |
358 | util.printout(cfg.export_path:format(util.remove_path_dupes(os.getenv("PATH"), cfg.export_path_separator), cfg.deploy_bin_dir)) | 382 | local bin_dirs = map_trees(deps_mode, deploy_bin_dir) |
383 | table.insert(bin_dirs, 1, os.getenv("PATH")) | ||
384 | util.printout(cfg.export_path:format(util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator))) | ||
359 | end | 385 | end |
360 | return true | 386 | return true |
361 | end | 387 | 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/util.lua b/src/luarocks/util.lua index 1a1cccf9..46802255 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -331,6 +331,8 @@ end | |||
331 | -- @param list string: A path string (from $PATH or package.path) | 331 | -- @param list string: A path string (from $PATH or package.path) |
332 | -- @param sep string: The separator | 332 | -- @param sep string: The separator |
333 | function remove_path_dupes(list, sep) | 333 | function remove_path_dupes(list, sep) |
334 | assert(type(list) == "string") | ||
335 | assert(type(sep) == "string") | ||
334 | local parts = split_string(list, sep) | 336 | local parts = split_string(list, sep) |
335 | local final, entries = {}, {} | 337 | local final, entries = {}, {} |
336 | for _, part in ipairs(parts) do | 338 | for _, part in ipairs(parts) do |
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 |