summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/add.lua2
-rw-r--r--src/luarocks/admin_remove.lua2
-rw-r--r--src/luarocks/build.lua35
-rw-r--r--src/luarocks/cfg.lua5
-rw-r--r--src/luarocks/deps.lua48
-rw-r--r--src/luarocks/dir.lua4
-rw-r--r--src/luarocks/fs/lua.lua41
-rw-r--r--src/luarocks/install.lua21
-rw-r--r--src/luarocks/make.lua5
-rw-r--r--src/luarocks/make_manifest.lua7
-rw-r--r--src/luarocks/manif.lua22
-rw-r--r--src/luarocks/manif_core.lua24
-rw-r--r--src/luarocks/path.lua28
-rw-r--r--src/luarocks/purge.lua2
-rw-r--r--src/luarocks/remove.lua14
-rw-r--r--src/luarocks/repos.lua6
-rw-r--r--src/luarocks/util.lua2
-rw-r--r--src/luarocks/validate.lua8
18 files changed, 179 insertions, 97 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.
117function build_rockspec(rockspec_file, need_to_fetch, minimal_mode, no_deps) 118function 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.
278function build_rock(rock_file, need_to_fetch, no_deps) 281function 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
291end 294end
292 295
293local function do_build(name, version, no_deps) 296local 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
308end 311end
@@ -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
332end 335end
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index d4222998..136ea6be 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -165,6 +165,7 @@ local defaults = {
165 use_extensions = false, 165 use_extensions = false,
166 accept_unknown_fields = false, 166 accept_unknown_fields = false,
167 fs_use_modules = true, 167 fs_use_modules = true,
168 use_trees = "one",
168 169
169 lua_modules_path = "/share/lua/"..lua_version, 170 lua_modules_path = "/share/lua/"..lua_version,
170 lib_modules_path = "/lib/lua/"..lua_version, 171 lib_modules_path = "/lib/lua/"..lua_version,
@@ -278,7 +279,7 @@ if detected.windows then
278 lib = { "?.dll", "lib?.dll" }, 279 lib = { "?.dll", "lib?.dll" },
279 include = { "?.h" } 280 include = { "?.h" }
280 } 281 }
281 defaults.export_path = "SET PATH=%s;%s" 282 defaults.export_path = "SET PATH=%s"
282 defaults.export_path_separator = ";" 283 defaults.export_path_separator = ";"
283 defaults.export_lua_path = "SET LUA_PATH=%s" 284 defaults.export_lua_path = "SET LUA_PATH=%s"
284 defaults.export_lua_cpath = "SET LUA_CPATH=%s" 285 defaults.export_lua_cpath = "SET LUA_CPATH=%s"
@@ -323,7 +324,7 @@ if detected.unix then
323 lib = { "lib?.so", "lib?.so.*" }, 324 lib = { "lib?.so", "lib?.so.*" },
324 include = { "?.h" } 325 include = { "?.h" }
325 } 326 }
326 defaults.export_path = "export PATH='%s:%s'" 327 defaults.export_path = "export PATH='%s'"
327 defaults.export_path_separator = ":" 328 defaults.export_path_separator = ":"
328 defaults.export_lua_path = "export LUA_PATH='%s'" 329 defaults.export_lua_path = "export LUA_PATH='%s'"
329 defaults.export_lua_cpath = "export LUA_CPATH='%s'" 330 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.
315local function match_dep(dep, blacklist) 315local 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.
364function match_deps(rockspec, blacklist) 364function 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.
404function fulfill_dependencies(rockspec) 404function 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.
643function scan_deps(results, missing, manifest, name, version) 643function 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
683end 683end
684
685local valid_trees = {
686 one = true,
687 order = true,
688 all = true,
689}
690
691function check_trees_flag(flag)
692 return valid_trees[flag]
693end
694
695function 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
703end
704
705function deps_mode_to_flag(deps_mode)
706 if deps_mode == "none" then
707 return "--nodeps"
708 else
709 return "--trees="..deps_mode
710 end
711end
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
70end 70end
71
72function normalize(name)
73 return name:gsub("\\", "/"):gsub("(.)/*$", "%1")
74end
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua
index 00c576dc..d6795773 100644
--- a/src/luarocks/fs/lua.lua
+++ b/src/luarocks/fs/lua.lua
@@ -23,7 +23,6 @@ if cfg.fs_use_modules then
23 posix_ok, posix = pcall(require, "posix") 23 posix_ok, posix = pcall(require, "posix")
24end 24end
25 25
26local tar = require("luarocks.tools.tar")
27local patch = require("luarocks.tools.patch") 26local patch = require("luarocks.tools.patch")
28 27
29local dir_stack = {} 28local dir_stack = {}
@@ -43,10 +42,6 @@ function Q(arg)
43 return "'" .. arg:gsub("\\", "\\\\"):gsub("'", "'\\''") .. "'" 42 return "'" .. arg:gsub("\\", "\\\\"):gsub("'", "'\\''") .. "'"
44end 43end
45 44
46local function normalize(name)
47 return name:gsub("\\", "/"):gsub("(.)/*$", "%1")
48end
49
50--- Test is file/dir is writable. 45--- Test is file/dir is writable.
51-- Warning: testing if a file/dir is writable does not guarantee 46-- Warning: testing if a file/dir is writable does not guarantee
52-- that it will remain writable and therefore it is no replacement 47-- that it will remain writable and therefore it is no replacement
@@ -55,7 +50,7 @@ end
55-- @return boolean: true if file exists, false otherwise. 50-- @return boolean: true if file exists, false otherwise.
56function is_writable(file) 51function is_writable(file)
57 assert(file) 52 assert(file)
58 file = normalize(file) 53 file = dir.normalize(file)
59 local result 54 local result
60 if fs.is_dir(file) then 55 if fs.is_dir(file) then
61 local file2 = dir.path(file, '.tmpluarockstestwritable') 56 local file2 = dir.path(file, '.tmpluarockstestwritable')
@@ -77,7 +72,7 @@ end
77-- @return string or nil: name of temporary directory or nil on failure. 72-- @return string or nil: name of temporary directory or nil on failure.
78function make_temp_dir(name) 73function make_temp_dir(name)
79 assert(type(name) == "string") 74 assert(type(name) == "string")
80 name = normalize(name) 75 name = dir.normalize(name)
81 76
82 local temp_dir = (os.getenv("TMP") or "/tmp") .. "/luarocks_" .. name:gsub(dir.separator, "_") .. "-" .. tostring(math.floor(math.random() * 10000)) 77 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 78 if fs.make_dir(temp_dir) then
@@ -110,7 +105,7 @@ end
110-- @return boolean: true if the MD5 checksum for 'file' equals 'md5sum', false if not 105-- @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. 106-- or if it could not perform the check for any reason.
112function check_md5(file, md5sum) 107function check_md5(file, md5sum)
113 file = normalize(file) 108 file = dir.normalize(file)
114 local computed = fs.get_md5(file) 109 local computed = fs.get_md5(file)
115 if not computed then 110 if not computed then
116 return false 111 return false
@@ -156,7 +151,7 @@ end
156-- @param d string: The directory to switch to. 151-- @param d string: The directory to switch to.
157function change_dir(d) 152function change_dir(d)
158 table.insert(dir_stack, lfs.currentdir()) 153 table.insert(dir_stack, lfs.currentdir())
159 d = normalize(d) 154 d = dir.normalize(d)
160 lfs.chdir(d) 155 lfs.chdir(d)
161end 156end
162 157
@@ -187,7 +182,7 @@ end
187-- @return boolean: true on success, false on failure. 182-- @return boolean: true on success, false on failure.
188function make_dir(directory) 183function make_dir(directory)
189 assert(type(directory) == "string") 184 assert(type(directory) == "string")
190 directory = normalize(directory) 185 directory = dir.normalize(directory)
191 local path = nil 186 local path = nil
192 if directory:sub(2, 2) == ":" then 187 if directory:sub(2, 2) == ":" then
193 path = directory:sub(1, 2) 188 path = directory:sub(1, 2)
@@ -217,7 +212,7 @@ end
217-- @param d string: pathname of directory to remove. 212-- @param d string: pathname of directory to remove.
218function remove_dir_if_empty(d) 213function remove_dir_if_empty(d)
219 assert(d) 214 assert(d)
220 d = normalize(d) 215 d = dir.normalize(d)
221 lfs.rmdir(d) 216 lfs.rmdir(d)
222end 217end
223 218
@@ -227,7 +222,7 @@ end
227-- @param d string: pathname of directory to remove. 222-- @param d string: pathname of directory to remove.
228function remove_dir_tree_if_empty(d) 223function remove_dir_tree_if_empty(d)
229 assert(d) 224 assert(d)
230 d = normalize(d) 225 d = dir.normalize(d)
231 for i=1,10 do 226 for i=1,10 do
232 lfs.rmdir(d) 227 lfs.rmdir(d)
233 d = dir.dir_name(d) 228 d = dir.dir_name(d)
@@ -243,8 +238,8 @@ end
243-- plus an error message. 238-- plus an error message.
244function copy(src, dest, perms) 239function copy(src, dest, perms)
245 assert(src and dest) 240 assert(src and dest)
246 src = normalize(src) 241 src = dir.normalize(src)
247 dest = normalize(dest) 242 dest = dir.normalize(dest)
248 local destmode = lfs.attributes(dest, "mode") 243 local destmode = lfs.attributes(dest, "mode")
249 if destmode == "directory" then 244 if destmode == "directory" then
250 dest = dir.path(dest, dir.base_name(src)) 245 dest = dir.path(dest, dir.base_name(src))
@@ -296,8 +291,8 @@ end
296-- plus an error message. 291-- plus an error message.
297function copy_contents(src, dest) 292function copy_contents(src, dest)
298 assert(src and dest) 293 assert(src and dest)
299 src = normalize(src) 294 src = dir.normalize(src)
300 dest = normalize(dest) 295 dest = dir.normalize(dest)
301 assert(lfs.attributes(src, "mode") == "directory") 296 assert(lfs.attributes(src, "mode") == "directory")
302 297
303 for file in lfs.dir(src) do 298 for file in lfs.dir(src) do
@@ -338,7 +333,7 @@ end
338-- @param name string: Pathname of source 333-- @param name string: Pathname of source
339-- @return boolean: true on success, false on failure. 334-- @return boolean: true on success, false on failure.
340function delete(name) 335function delete(name)
341 name = normalize(name) 336 name = dir.normalize(name)
342 return recursive_delete(name) or false 337 return recursive_delete(name) or false
343end 338end
344 339
@@ -352,7 +347,7 @@ function list_dir(at)
352 if not at then 347 if not at then
353 at = fs.current_dir() 348 at = fs.current_dir()
354 end 349 end
355 at = normalize(at) 350 at = dir.normalize(at)
356 if not fs.is_dir(at) then 351 if not fs.is_dir(at) then
357 return {} 352 return {}
358 end 353 end
@@ -393,7 +388,7 @@ function find(at)
393 if not at then 388 if not at then
394 at = fs.current_dir() 389 at = fs.current_dir()
395 end 390 end
396 at = normalize(at) 391 at = dir.normalize(at)
397 if not fs.is_dir(at) then 392 if not fs.is_dir(at) then
398 return {} 393 return {}
399 end 394 end
@@ -407,7 +402,7 @@ end
407-- @return boolean: true if file exists, false otherwise. 402-- @return boolean: true if file exists, false otherwise.
408function exists(file) 403function exists(file)
409 assert(file) 404 assert(file)
410 file = normalize(file) 405 file = dir.normalize(file)
411 return type(lfs.attributes(file)) == "table" 406 return type(lfs.attributes(file)) == "table"
412end 407end
413 408
@@ -416,7 +411,7 @@ end
416-- @return boolean: true if it is a directory, false otherwise. 411-- @return boolean: true if it is a directory, false otherwise.
417function is_dir(file) 412function is_dir(file)
418 assert(file) 413 assert(file)
419 file = normalize(file) 414 file = dir.normalize(file)
420 return lfs.attributes(file, "mode") == "directory" 415 return lfs.attributes(file, "mode") == "directory"
421end 416end
422 417
@@ -425,12 +420,12 @@ end
425-- @return boolean: true if it is a file, false otherwise. 420-- @return boolean: true if it is a file, false otherwise.
426function is_file(file) 421function is_file(file)
427 assert(file) 422 assert(file)
428 file = normalize(file) 423 file = dir.normalize(file)
429 return lfs.attributes(file, "mode") == "file" 424 return lfs.attributes(file, "mode") == "file"
430end 425end
431 426
432function set_time(file, time) 427function set_time(file, time)
433 file = normalize(file) 428 file = dir.normalize(file)
434 return lfs.touch(file, time) 429 return lfs.touch(file, time)
435end 430end
436 431
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua
index 708d6abe..0ffb95ef 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.
29function install_binary_rock(rock_file, no_deps) 30function 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")
11local cfg = require("luarocks.cfg") 11local cfg = require("luarocks.cfg")
12local fetch = require("luarocks.fetch") 12local fetch = require("luarocks.fetch")
13local pack = require("luarocks.pack") 13local pack = require("luarocks.pack")
14local deps = require("luarocks.deps")
14 15
15help_summary = "Compile package in current directory using a rockspec." 16help_summary = "Compile package in current directory using a rockspec."
16help_arguments = "[--pack-binary-rock] [<rockspec>]" 17help_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
71end 72end
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")
7local index = require("luarocks.index") 7local index = require("luarocks.index")
8local cfg = require("luarocks.cfg") 8local cfg = require("luarocks.cfg")
9local util = require("luarocks.util") 9local util = require("luarocks.util")
10local deps = require("luarocks.deps")
10 11
11help_summary = "Compile a manifest file for a repository." 12help_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.
22function run(repo) 23function 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 65a6beba..b7554a33 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.
188local function update_dependencies(manifest) 188local 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.
217local function store_results(results, manifest) 217local 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.
254function make_manifest(repo) 254function 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.
284function update_manifest(name, version, repo) 286function 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")
8local dir = require("luarocks.dir") 8local dir = require("luarocks.dir")
9local util = require("luarocks.util") 9local util = require("luarocks.util")
10local cfg = require("luarocks.cfg") 10local cfg = require("luarocks.cfg")
11local path = require("luarocks.path")
11 12
12manifest_cache = {} 13manifest_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.
59function get_versions(name, manifest) 62function 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 798f15a9..42d3b8f1 100644
--- a/src/luarocks/path.lua
+++ b/src/luarocks/path.lua
@@ -7,6 +7,7 @@ module("luarocks.path", package.seeall)
7local dir = require("luarocks.dir") 7local dir = require("luarocks.dir")
8local cfg = require("luarocks.cfg") 8local cfg = require("luarocks.cfg")
9local util = require("luarocks.util") 9local util = require("luarocks.util")
10local deps = require("luarocks.deps")
10 11
11help_summary = "Return the currently configured package path." 12help_summary = "Return the currently configured package path."
12help_arguments = "" 13help_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)
306end 307end
307 308
309function map_trees(use_trees, fn, ...)
310 local result = {}
311 if use_trees == "one" then
312 table.insert(result, (fn(cfg.root_dir, ...)) or 0)
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, ...)) or 0)
324 end
325 end
326 end
327 return result
328end
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.
353function run(...) 375function 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
361end 387end
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")
48end 48end
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.
31local function check_dependents(name, versions) 31local 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.
79function run(...) 79function 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 27cdc67d..dc1b63c8 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.
17function get_versions(name) 17local 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))
@@ -213,7 +213,7 @@ function deploy_files(name, version, wrap_bin_scripts)
213 else 213 else
214 target = new_target 214 target = new_target
215 end 215 end
216 end 216 end
217 fs.make_dir(dir.dir_name(target)) 217 fs.make_dir(dir.dir_name(target))
218 ok, err = move_fn(source, target) 218 ok, err = move_fn(source, target)
219 fs.remove_dir_tree_if_empty(dir.dir_name(source)) 219 fs.remove_dir_tree_if_empty(dir.dir_name(source))
@@ -296,7 +296,7 @@ function delete_version(name, version, quick)
296 if err then return nil, err end 296 if err then return nil, err end
297 297
298 fs.delete(path.install_dir(name, version)) 298 fs.delete(path.install_dir(name, version))
299 if not get_versions(name) then 299 if not get_installed_versions(name) then
300 fs.delete(dir.path(cfg.rocks_dir, name)) 300 fs.delete(dir.path(cfg.rocks_dir, name))
301 end 301 end
302 return true 302 return true
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua
index de7a43a2..c6e0c592 100644
--- a/src/luarocks/util.lua
+++ b/src/luarocks/util.lua
@@ -339,6 +339,8 @@ end
339-- @param list string: A path string (from $PATH or package.path) 339-- @param list string: A path string (from $PATH or package.path)
340-- @param sep string: The separator 340-- @param sep string: The separator
341function remove_path_dupes(list, sep) 341function remove_path_dupes(list, sep)
342 assert(type(list) == "string")
343 assert(type(sep) == "string")
342 local parts = split_string(list, sep) 344 local parts = split_string(list, sep)
343 local final, entries = {}, {} 345 local final, entries = {}, {}
344 for _, part in ipairs(parts) do 346 for _, part in ipairs(parts) do
diff --git a/src/luarocks/validate.lua b/src/luarocks/validate.lua
index ed12f8f0..1e1e69e1 100644
--- a/src/luarocks/validate.lua
+++ b/src/luarocks/validate.lua
@@ -50,7 +50,7 @@ local function prepare_sandbox(file)
50end 50end
51 51
52local function validate_rockspec(file) 52local 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)
58end 58end
59 59
60local function validate_src_rock(file) 60local 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)
66end 66end
67 67
68local function validate_rock(file) 68local 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