aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/core/path.lua2
-rw-r--r--src/luarocks/deps.lua2
-rw-r--r--src/luarocks/fs/lua.lua18
-rw-r--r--src/luarocks/fs/unix/tools.lua10
-rw-r--r--src/luarocks/fs/win32.lua10
-rw-r--r--src/luarocks/manif.lua2
-rw-r--r--src/luarocks/manif/writer.lua12
-rw-r--r--src/luarocks/path.lua22
-rw-r--r--src/luarocks/queries.lua9
-rw-r--r--src/luarocks/repos.lua14
-rw-r--r--src/luarocks/results.lua2
-rw-r--r--src/luarocks/search.lua18
-rw-r--r--src/luarocks/util.lua21
13 files changed, 71 insertions, 71 deletions
diff --git a/src/luarocks/core/path.lua b/src/luarocks/core/path.lua
index fd84c7df..125500b7 100644
--- a/src/luarocks/core/path.lua
+++ b/src/luarocks/core/path.lua
@@ -24,7 +24,7 @@ end
24-- @return string: a pathname with the same directory parts and a versioned basename. 24-- @return string: a pathname with the same directory parts and a versioned basename.
25function path.versioned_name(file, prefix, name, version) 25function path.versioned_name(file, prefix, name, version)
26 assert(type(file) == "string") 26 assert(type(file) == "string")
27 assert(type(name) == "string") 27 assert(type(name) == "string" and not name:match("/"))
28 assert(type(version) == "string") 28 assert(type(version) == "string")
29 29
30 local rest = file:sub(#prefix+1):gsub("^/*", "") 30 local rest = file:sub(#prefix+1):gsub("^/*", "")
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua
index 182bbfb2..ccbced0c 100644
--- a/src/luarocks/deps.lua
+++ b/src/luarocks/deps.lua
@@ -394,7 +394,7 @@ end
394function deps.scan_deps(results, manifest, name, version, deps_mode) 394function deps.scan_deps(results, manifest, name, version, deps_mode)
395 assert(type(results) == "table") 395 assert(type(results) == "table")
396 assert(type(manifest) == "table") 396 assert(type(manifest) == "table")
397 assert(type(name) == "string") 397 assert(type(name) == "string" and not name:match("/"))
398 assert(type(version) == "string") 398 assert(type(version) == "string")
399 399
400 local fetch = require("luarocks.fetch") 400 local fetch = require("luarocks.fetch")
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua
index 89426b09..38a37f0a 100644
--- a/src/luarocks/fs/lua.lua
+++ b/src/luarocks/fs/lua.lua
@@ -791,14 +791,14 @@ end
791if posix.mkdtemp then 791if posix.mkdtemp then
792 792
793--- Create a temporary directory. 793--- Create a temporary directory.
794-- @param name string: name pattern to use for avoiding conflicts 794-- @param name_pattern string: name pattern to use for avoiding conflicts
795-- when creating temporary directory. 795-- when creating temporary directory.
796-- @return string or (nil, string): name of temporary directory or (nil, error message) on failure. 796-- @return string or (nil, string): name of temporary directory or (nil, error message) on failure.
797function fs_lua.make_temp_dir(name) 797function fs_lua.make_temp_dir(name_pattern)
798 assert(type(name) == "string") 798 assert(type(name_pattern) == "string")
799 name = dir.normalize(name) 799 name_pattern = dir.normalize(name_pattern)
800 800
801 return posix.mkdtemp((os.getenv("TMPDIR") or "/tmp") .. "/luarocks_" .. name:gsub("/", "_") .. "-XXXXXX") 801 return posix.mkdtemp((os.getenv("TMPDIR") or "/tmp") .. "/luarocks_" .. name_pattern:gsub("/", "_") .. "-XXXXXX")
802end 802end
803 803
804end -- if posix.mkdtemp 804end -- if posix.mkdtemp
@@ -892,13 +892,13 @@ end
892--- Check whether a file is a Lua script 892--- Check whether a file is a Lua script
893-- When the file can be succesfully compiled by the configured 893-- When the file can be succesfully compiled by the configured
894-- Lua interpreter, it's considered to be a valid Lua file. 894-- Lua interpreter, it's considered to be a valid Lua file.
895-- @param name filename of file to check 895-- @param filename filename of file to check
896-- @return boolean true, if it is a Lua script, false otherwise 896-- @return boolean true, if it is a Lua script, false otherwise
897function fs_lua.is_lua(name) 897function fs_lua.is_lua(filename)
898 name = name:gsub([[%\]],"/") -- normalize on fw slash to prevent escaping issues 898 filename = filename:gsub([[%\]],"/") -- normalize on fw slash to prevent escaping issues
899 local lua = fs.Q(dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)) -- get lua interpreter configured 899 local lua = fs.Q(dir.path(cfg.variables["LUA_BINDIR"], cfg.lua_interpreter)) -- get lua interpreter configured
900 -- execute on configured interpreter, might not be the same as the interpreter LR is run on 900 -- execute on configured interpreter, might not be the same as the interpreter LR is run on
901 local result = fs.execute_string(lua..[[ -e "if loadfile(']]..name..[[') then os.exit() else os.exit(1) end"]]) 901 local result = fs.execute_string(lua..[[ -e "if loadfile(']]..filename..[[') then os.exit() else os.exit(1) end"]])
902 return (result == true) 902 return (result == true)
903end 903end
904 904
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua
index 33ba911d..be5ba7a7 100644
--- a/src/luarocks/fs/unix/tools.lua
+++ b/src/luarocks/fs/unix/tools.lua
@@ -223,14 +223,14 @@ function tools.set_time(file, time)
223end 223end
224 224
225--- Create a temporary directory. 225--- Create a temporary directory.
226-- @param name string: name pattern to use for avoiding conflicts 226-- @param name_pattern string: name pattern to use for avoiding conflicts
227-- when creating temporary directory. 227-- when creating temporary directory.
228-- @return string or (nil, string): name of temporary directory or (nil, error message) on failure. 228-- @return string or (nil, string): name of temporary directory or (nil, error message) on failure.
229function tools.make_temp_dir(name) 229function tools.make_temp_dir(name_pattern)
230 assert(type(name) == "string") 230 assert(type(name_pattern) == "string")
231 name = dir.normalize(name) 231 name_pattern = dir.normalize(name_pattern)
232 232
233 local template = (os.getenv("TMPDIR") or "/tmp") .. "/luarocks_" .. name:gsub("/", "_") .. "-XXXXXX" 233 local template = (os.getenv("TMPDIR") or "/tmp") .. "/luarocks_" .. name_pattern:gsub("/", "_") .. "-XXXXXX"
234 local pipe = io.popen(vars.MKTEMP.." -d "..fs.Q(template)) 234 local pipe = io.popen(vars.MKTEMP.." -d "..fs.Q(template))
235 local dirname = pipe:read("*l") 235 local dirname = pipe:read("*l")
236 pipe:close() 236 pipe:close()
diff --git a/src/luarocks/fs/win32.lua b/src/luarocks/fs/win32.lua
index 6fd24fa5..a915deb6 100644
--- a/src/luarocks/fs/win32.lua
+++ b/src/luarocks/fs/win32.lua
@@ -248,14 +248,14 @@ function win32.is_writable(file)
248end 248end
249 249
250--- Create a temporary directory. 250--- Create a temporary directory.
251-- @param name string: name pattern to use for avoiding conflicts 251-- @param name_pattern string: name pattern to use for avoiding conflicts
252-- when creating temporary directory. 252-- when creating temporary directory.
253-- @return string or (nil, string): name of temporary directory or (nil, error message) on failure. 253-- @return string or (nil, string): name of temporary directory or (nil, error message) on failure.
254function win32.make_temp_dir(name) 254function win32.make_temp_dir(name_pattern)
255 assert(type(name) == "string") 255 assert(type(name_pattern) == "string")
256 name = dir.normalize(name) 256 name_pattern = dir.normalize(name_pattern)
257 257
258 local temp_dir = os.getenv("TMP") .. "/luarocks_" .. name:gsub("/", "_") .. "-" .. tostring(math.floor(math.random() * 10000)) 258 local temp_dir = os.getenv("TMP") .. "/luarocks_" .. name_pattern:gsub("/", "_") .. "-" .. tostring(math.floor(math.random() * 10000))
259 local ok, err = fs.make_dir(temp_dir) 259 local ok, err = fs.make_dir(temp_dir)
260 if ok then 260 if ok then
261 return temp_dir 261 return temp_dir
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua
index 5ac9920d..146d5d73 100644
--- a/src/luarocks/manif.lua
+++ b/src/luarocks/manif.lua
@@ -39,7 +39,7 @@ function manif.load_local_manifest(repo_url)
39end 39end
40 40
41function manif.load_rock_manifest(name, version, root) 41function manif.load_rock_manifest(name, version, root)
42 assert(type(name) == "string") 42 assert(type(name) == "string" and not name:match("/"))
43 assert(type(version) == "string") 43 assert(type(version) == "string")
44 44
45 local name_version = name.."/"..version 45 local name_version = name.."/"..version
diff --git a/src/luarocks/manif/writer.lua b/src/luarocks/manif/writer.lua
index a6c70f4d..07628ea2 100644
--- a/src/luarocks/manif/writer.lua
+++ b/src/luarocks/manif/writer.lua
@@ -25,7 +25,7 @@ local queries = require("luarocks.queries")
25local function store_package_items(storage, name, version, items) 25local function store_package_items(storage, name, version, items)
26 assert(type(storage) == "table") 26 assert(type(storage) == "table")
27 assert(type(items) == "table") 27 assert(type(items) == "table")
28 assert(type(name) == "string") 28 assert(type(name) == "string" and not name:match("/"))
29 assert(type(version) == "string") 29 assert(type(version) == "string")
30 30
31 local package_identifier = name.."/"..version 31 local package_identifier = name.."/"..version
@@ -49,7 +49,7 @@ end
49local function remove_package_items(storage, name, version, items) 49local function remove_package_items(storage, name, version, items)
50 assert(type(storage) == "table") 50 assert(type(storage) == "table")
51 assert(type(items) == "table") 51 assert(type(items) == "table")
52 assert(type(name) == "string") 52 assert(type(name) == "string" and not name:match("/"))
53 assert(type(version) == "string") 53 assert(type(version) == "string")
54 54
55 local package_identifier = name.."/"..version 55 local package_identifier = name.."/"..version
@@ -235,7 +235,7 @@ end
235-- message in case of errors. 235-- message in case of errors.
236local function save_table(where, name, tbl) 236local function save_table(where, name, tbl)
237 assert(type(where) == "string") 237 assert(type(where) == "string")
238 assert(type(name) == "string") 238 assert(type(name) == "string" and not name:match("/"))
239 assert(type(tbl) == "table") 239 assert(type(tbl) == "table")
240 240
241 local filename = dir.path(where, name) 241 local filename = dir.path(where, name)
@@ -284,7 +284,7 @@ end
284-- @return true if successful (or unnecessary, if there is no namespace), 284-- @return true if successful (or unnecessary, if there is no namespace),
285-- or nil and an error message. 285-- or nil and an error message.
286function writer.make_namespace_file(name, version, namespace) 286function writer.make_namespace_file(name, version, namespace)
287 assert(type(name) == "string") 287 assert(type(name) == "string" and not name:match("/"))
288 assert(type(version) == "string") 288 assert(type(version) == "string")
289 assert(type(namespace) == "string" or not namespace) 289 assert(type(namespace) == "string" or not namespace)
290 name = util.adjust_name_and_namespace(name, { namespace = namespace }) 290 name = util.adjust_name_and_namespace(name, { namespace = namespace })
@@ -360,7 +360,7 @@ end
360-- @return boolean or (nil, string): True if manifest was updated successfully, 360-- @return boolean or (nil, string): True if manifest was updated successfully,
361-- or nil and an error message. 361-- or nil and an error message.
362function writer.add_to_manifest(name, version, repo, deps_mode) 362function writer.add_to_manifest(name, version, repo, deps_mode)
363 assert(type(name) == "string") 363 assert(type(name) == "string" and not name:match("/"))
364 assert(type(version) == "string") 364 assert(type(version) == "string")
365 local rocks_dir = path.rocks_dir(repo or cfg.root_dir) 365 local rocks_dir = path.rocks_dir(repo or cfg.root_dir)
366 assert(type(deps_mode) == "string") 366 assert(type(deps_mode) == "string")
@@ -397,7 +397,7 @@ end
397-- @return boolean or (nil, string): True if manifest was updated successfully, 397-- @return boolean or (nil, string): True if manifest was updated successfully,
398-- or nil and an error message. 398-- or nil and an error message.
399function writer.remove_from_manifest(name, version, repo, deps_mode) 399function writer.remove_from_manifest(name, version, repo, deps_mode)
400 assert(type(name) == "string") 400 assert(type(name) == "string" and not name:match("/"))
401 assert(type(version) == "string") 401 assert(type(version) == "string")
402 local rocks_dir = path.rocks_dir(repo or cfg.root_dir) 402 local rocks_dir = path.rocks_dir(repo or cfg.root_dir)
403 assert(type(deps_mode) == "string") 403 assert(type(deps_mode) == "string")
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua
index 7a569169..f6b12727 100644
--- a/src/luarocks/path.lua
+++ b/src/luarocks/path.lua
@@ -53,7 +53,7 @@ end
53-- @param tree string or nil: If given, specifies the local tree to use. 53-- @param tree string or nil: If given, specifies the local tree to use.
54-- the package (and by extension, the path) exists. 54-- the package (and by extension, the path) exists.
55function path.versions_dir(name, tree) 55function path.versions_dir(name, tree)
56 assert(type(name) == "string") 56 assert(type(name) == "string" and not name:match("/"))
57 tree = tree or cfg.root_dir 57 tree = tree or cfg.root_dir
58 return dir.path(path.rocks_dir(tree), name) 58 return dir.path(path.rocks_dir(tree), name)
59end 59end
@@ -65,7 +65,7 @@ end
65-- @return string: The resulting path -- does not guarantee that 65-- @return string: The resulting path -- does not guarantee that
66-- the package (and by extension, the path) exists. 66-- the package (and by extension, the path) exists.
67function path.install_dir(name, version, tree) 67function path.install_dir(name, version, tree)
68 assert(type(name) == "string") 68 assert(type(name) == "string" and not name:match("/"))
69 assert(type(version) == "string") 69 assert(type(version) == "string")
70 tree = tree or cfg.root_dir 70 tree = tree or cfg.root_dir
71 return dir.path(path.rocks_dir(tree), name, version) 71 return dir.path(path.rocks_dir(tree), name, version)
@@ -78,7 +78,7 @@ end
78-- @return string: The resulting path -- does not guarantee that 78-- @return string: The resulting path -- does not guarantee that
79-- the package (and by extension, the file) exists. 79-- the package (and by extension, the file) exists.
80function path.rockspec_file(name, version, tree) 80function path.rockspec_file(name, version, tree)
81 assert(type(name) == "string") 81 assert(type(name) == "string" and not name:match("/"))
82 assert(type(version) == "string") 82 assert(type(version) == "string")
83 tree = tree or cfg.root_dir 83 tree = tree or cfg.root_dir
84 return dir.path(path.rocks_dir(tree), name, version, name.."-"..version..".rockspec") 84 return dir.path(path.rocks_dir(tree), name, version, name.."-"..version..".rockspec")
@@ -91,7 +91,7 @@ end
91-- @return string: The resulting path -- does not guarantee that 91-- @return string: The resulting path -- does not guarantee that
92-- the package (and by extension, the file) exists. 92-- the package (and by extension, the file) exists.
93function path.rock_manifest_file(name, version, tree) 93function path.rock_manifest_file(name, version, tree)
94 assert(type(name) == "string") 94 assert(type(name) == "string" and not name:match("/"))
95 assert(type(version) == "string") 95 assert(type(version) == "string")
96 tree = tree or cfg.root_dir 96 tree = tree or cfg.root_dir
97 return dir.path(path.rocks_dir(tree), name, version, "rock_manifest") 97 return dir.path(path.rocks_dir(tree), name, version, "rock_manifest")
@@ -104,7 +104,7 @@ end
104-- @return string: The resulting path -- does not guarantee that 104-- @return string: The resulting path -- does not guarantee that
105-- the package (and by extension, the file) exists. 105-- the package (and by extension, the file) exists.
106function path.rock_namespace_file(name, version, tree) 106function path.rock_namespace_file(name, version, tree)
107 assert(type(name) == "string") 107 assert(type(name) == "string" and not name:match("/"))
108 assert(type(version) == "string") 108 assert(type(version) == "string")
109 tree = tree or cfg.root_dir 109 tree = tree or cfg.root_dir
110 return dir.path(path.rocks_dir(tree), name, version, "rock_namespace") 110 return dir.path(path.rocks_dir(tree), name, version, "rock_namespace")
@@ -117,7 +117,7 @@ end
117-- @return string: The resulting path -- does not guarantee that 117-- @return string: The resulting path -- does not guarantee that
118-- the package (and by extension, the path) exists. 118-- the package (and by extension, the path) exists.
119function path.lib_dir(name, version, tree) 119function path.lib_dir(name, version, tree)
120 assert(type(name) == "string") 120 assert(type(name) == "string" and not name:match("/"))
121 assert(type(version) == "string") 121 assert(type(version) == "string")
122 tree = tree or cfg.root_dir 122 tree = tree or cfg.root_dir
123 return dir.path(path.rocks_dir(tree), name, version, "lib") 123 return dir.path(path.rocks_dir(tree), name, version, "lib")
@@ -130,7 +130,7 @@ end
130-- @return string: The resulting path -- does not guarantee that 130-- @return string: The resulting path -- does not guarantee that
131-- the package (and by extension, the path) exists. 131-- the package (and by extension, the path) exists.
132function path.lua_dir(name, version, tree) 132function path.lua_dir(name, version, tree)
133 assert(type(name) == "string") 133 assert(type(name) == "string" and not name:match("/"))
134 assert(type(version) == "string") 134 assert(type(version) == "string")
135 tree = tree or cfg.root_dir 135 tree = tree or cfg.root_dir
136 return dir.path(path.rocks_dir(tree), name, version, "lua") 136 return dir.path(path.rocks_dir(tree), name, version, "lua")
@@ -143,7 +143,7 @@ end
143-- @return string: The resulting path -- does not guarantee that 143-- @return string: The resulting path -- does not guarantee that
144-- the package (and by extension, the path) exists. 144-- the package (and by extension, the path) exists.
145function path.doc_dir(name, version, tree) 145function path.doc_dir(name, version, tree)
146 assert(type(name) == "string") 146 assert(type(name) == "string" and not name:match("/"))
147 assert(type(version) == "string") 147 assert(type(version) == "string")
148 tree = tree or cfg.root_dir 148 tree = tree or cfg.root_dir
149 return dir.path(path.rocks_dir(tree), name, version, "doc") 149 return dir.path(path.rocks_dir(tree), name, version, "doc")
@@ -156,7 +156,7 @@ end
156-- @return string: The resulting path -- does not guarantee that 156-- @return string: The resulting path -- does not guarantee that
157-- the package (and by extension, the path) exists. 157-- the package (and by extension, the path) exists.
158function path.conf_dir(name, version, tree) 158function path.conf_dir(name, version, tree)
159 assert(type(name) == "string") 159 assert(type(name) == "string" and not name:match("/"))
160 assert(type(version) == "string") 160 assert(type(version) == "string")
161 tree = tree or cfg.root_dir 161 tree = tree or cfg.root_dir
162 return dir.path(path.rocks_dir(tree), name, version, "conf") 162 return dir.path(path.rocks_dir(tree), name, version, "conf")
@@ -170,7 +170,7 @@ end
170-- @return string: The resulting path -- does not guarantee that 170-- @return string: The resulting path -- does not guarantee that
171-- the package (and by extension, the path) exists. 171-- the package (and by extension, the path) exists.
172function path.bin_dir(name, version, tree) 172function path.bin_dir(name, version, tree)
173 assert(type(name) == "string") 173 assert(type(name) == "string" and not name:match("/"))
174 assert(type(version) == "string") 174 assert(type(version) == "string")
175 tree = tree or cfg.root_dir 175 tree = tree or cfg.root_dir
176 return dir.path(path.rocks_dir(tree), name, version, "bin") 176 return dir.path(path.rocks_dir(tree), name, version, "bin")
@@ -198,7 +198,7 @@ end
198-- @return string: A URL or pathname following LuaRocks naming conventions. 198-- @return string: A URL or pathname following LuaRocks naming conventions.
199function path.make_url(pathname, name, version, arch) 199function path.make_url(pathname, name, version, arch)
200 assert(type(pathname) == "string") 200 assert(type(pathname) == "string")
201 assert(type(name) == "string") 201 assert(type(name) == "string" and not name:match("/"))
202 assert(type(version) == "string") 202 assert(type(version) == "string")
203 assert(type(arch) == "string") 203 assert(type(arch) == "string")
204 204
diff --git a/src/luarocks/queries.lua b/src/luarocks/queries.lua
index 888d9cf7..e47a5722 100644
--- a/src/luarocks/queries.lua
+++ b/src/luarocks/queries.lua
@@ -36,15 +36,15 @@ local function arch_to_table(input)
36end 36end
37 37
38--- Prepare a query in dependency table format. 38--- Prepare a query in dependency table format.
39-- @param name string: the package name, may contain a namespace. 39-- @param ns_name string: the package name, may contain a namespace.
40-- @param version string?: the package version. 40-- @param version string?: the package version.
41-- @param substring boolean?: match substrings of the name 41-- @param substring boolean?: match substrings of the name
42-- (default is false, match full name) 42-- (default is false, match full name)
43-- @param arch string?: a string with pipe-separated accepted arch values 43-- @param arch string?: a string with pipe-separated accepted arch values
44-- @param operator string?: operator for version matching (default is "==") 44-- @param operator string?: operator for version matching (default is "==")
45-- @return table: A query in table format 45-- @return table: A query in table format
46function queries.new(name, version, substring, arch, operator) 46function queries.new(ns_name, version, substring, arch, operator)
47 assert(type(name) == "string") 47 assert(type(ns_name) == "string")
48 assert(type(version) == "string" or not version) 48 assert(type(version) == "string" or not version)
49 assert(type(substring) == "boolean" or not substring) 49 assert(type(substring) == "boolean" or not substring)
50 assert(type(arch) == "string" or not arch) 50 assert(type(arch) == "string" or not arch)
@@ -52,8 +52,7 @@ function queries.new(name, version, substring, arch, operator)
52 52
53 operator = operator or "==" 53 operator = operator or "=="
54 54
55 local namespace 55 local name, namespace = util.split_namespace(ns_name)
56 name, namespace = util.split_namespace(name)
57 56
58 local self = { 57 local self = {
59 name = name, 58 name = name,
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua
index 35f5e3bc..00e7d3b8 100644
--- a/src/luarocks/repos.lua
+++ b/src/luarocks/repos.lua
@@ -32,7 +32,7 @@ local vers = require("luarocks.core.vers")
32-- @return table or nil: An array of strings listing installed 32-- @return table or nil: An array of strings listing installed
33-- versions of a package, or nil if none is available. 33-- versions of a package, or nil if none is available.
34local function get_installed_versions(name) 34local function get_installed_versions(name)
35 assert(type(name) == "string") 35 assert(type(name) == "string" and not name:match("/"))
36 36
37 local dirs = fs.list_dir(path.versions_dir(name)) 37 local dirs = fs.list_dir(path.versions_dir(name))
38 return (dirs and #dirs > 0) and dirs or nil 38 return (dirs and #dirs > 0) and dirs or nil
@@ -45,7 +45,7 @@ end
45-- @return boolean: true if a package is installed, 45-- @return boolean: true if a package is installed,
46-- false otherwise. 46-- false otherwise.
47function repos.is_installed(name, version) 47function repos.is_installed(name, version)
48 assert(type(name) == "string") 48 assert(type(name) == "string" and not name:match("/"))
49 assert(type(version) == "string") 49 assert(type(version) == "string")
50 50
51 return fs.is_dir(path.install_dir(name, version)) 51 return fs.is_dir(path.install_dir(name, version))
@@ -93,7 +93,7 @@ end
93-- If no modules are found or if package name or version 93-- If no modules are found or if package name or version
94-- are invalid, an empty table is returned. 94-- are invalid, an empty table is returned.
95function repos.package_modules(name, version) 95function repos.package_modules(name, version)
96 assert(type(name) == "string") 96 assert(type(name) == "string" and not name:match("/"))
97 assert(type(version) == "string") 97 assert(type(version) == "string")
98 98
99 local result = {} 99 local result = {}
@@ -114,7 +114,7 @@ end
114-- If no commands are found or if package name or version 114-- If no commands are found or if package name or version
115-- are invalid, an empty table is returned. 115-- are invalid, an empty table is returned.
116function repos.package_commands(name, version) 116function repos.package_commands(name, version)
117 assert(type(name) == "string") 117 assert(type(name) == "string" and not name:match("/"))
118 assert(type(version) == "string") 118 assert(type(version) == "string")
119 119
120 local result = {} 120 local result = {}
@@ -131,7 +131,7 @@ end
131-- @return boolean: returns true if rock contains platform-specific 131-- @return boolean: returns true if rock contains platform-specific
132-- binary executables, or false if it is a pure-Lua rock. 132-- binary executables, or false if it is a pure-Lua rock.
133function repos.has_binaries(name, version) 133function repos.has_binaries(name, version)
134 assert(type(name) == "string") 134 assert(type(name) == "string" and not name:match("/"))
135 assert(type(version) == "string") 135 assert(type(version) == "string")
136 136
137 local rock_manifest = manif.load_rock_manifest(name, version) 137 local rock_manifest = manif.load_rock_manifest(name, version)
@@ -272,7 +272,7 @@ end
272-- "one" for the current default tree, "all" for all trees, 272-- "one" for the current default tree, "all" for all trees,
273-- "order" for all trees with priority >= the current default, "none" for no trees. 273-- "order" for all trees with priority >= the current default, "none" for no trees.
274function repos.deploy_files(name, version, wrap_bin_scripts, deps_mode) 274function repos.deploy_files(name, version, wrap_bin_scripts, deps_mode)
275 assert(type(name) == "string") 275 assert(type(name) == "string" and not name:match("/"))
276 assert(type(version) == "string") 276 assert(type(version) == "string")
277 assert(type(wrap_bin_scripts) == "boolean") 277 assert(type(wrap_bin_scripts) == "boolean")
278 278
@@ -351,7 +351,7 @@ end
351-- was deleted. This is used during 'purge', as every module 351-- was deleted. This is used during 'purge', as every module
352-- will be eventually deleted. 352-- will be eventually deleted.
353function repos.delete_version(name, version, deps_mode, quick) 353function repos.delete_version(name, version, deps_mode, quick)
354 assert(type(name) == "string") 354 assert(type(name) == "string" and not name:match("/"))
355 assert(type(version) == "string") 355 assert(type(version) == "string")
356 assert(type(deps_mode) == "string") 356 assert(type(deps_mode) == "string")
357 357
diff --git a/src/luarocks/results.lua b/src/luarocks/results.lua
index 3e743883..a6ebfbf3 100644
--- a/src/luarocks/results.lua
+++ b/src/luarocks/results.lua
@@ -12,7 +12,7 @@ function result_mt.type()
12end 12end
13 13
14function results.new(name, version, repo, arch, namespace) 14function results.new(name, version, repo, arch, namespace)
15 assert(type(name) == "string") 15 assert(type(name) == "string" and not name:match("/"))
16 assert(type(version) == "string") 16 assert(type(version) == "string")
17 assert(type(repo) == "string") 17 assert(type(repo) == "string")
18 assert(type(arch) == "string" or not arch) 18 assert(type(arch) == "string" or not arch)
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua
index a86db890..49098642 100644
--- a/src/luarocks/search.lua
+++ b/src/luarocks/search.lua
@@ -53,7 +53,7 @@ end
53-- @param tree string: The local tree to use. 53-- @param tree string: The local tree to use.
54-- @return string?: The namespace if it exists, or nil. 54-- @return string?: The namespace if it exists, or nil.
55local function read_namespace(name, version, tree) 55local function read_namespace(name, version, tree)
56 assert(type(name) == "string") 56 assert(type(name) == "string" and not name:match("/"))
57 assert(type(version) == "string") 57 assert(type(version) == "string")
58 assert(type(tree) == "string") 58 assert(type(tree) == "string")
59 59
@@ -198,7 +198,7 @@ end
198-- @return string or nil: the URL for the latest version if one could 198-- @return string or nil: the URL for the latest version if one could
199-- be picked, or nil. 199-- be picked, or nil.
200local function pick_latest_version(name, versions) 200local function pick_latest_version(name, versions)
201 assert(type(name) == "string") 201 assert(type(name) == "string" and not name:match("/"))
202 assert(type(versions) == "table") 202 assert(type(versions) == "table")
203 203
204 local vtables = {} 204 local vtables = {}
@@ -318,24 +318,26 @@ end
318-- user possibilities if it couldn't narrow down a single match. 318-- user possibilities if it couldn't narrow down a single match.
319-- @param action function: A function that takes a .src.rock or 319-- @param action function: A function that takes a .src.rock or
320-- .rockspec URL as a parameter. 320-- .rockspec URL as a parameter.
321-- @param name string: A rock name 321-- @param ns_name string: A rock name, may be namespaced
322-- @param version string or nil: A version number may also be given. 322-- @param version string or nil: A version number may also be given.
323-- @return The result of the action function, or nil and an error message. 323-- @return The result of the action function, or nil and an error message.
324function search.act_on_src_or_rockspec(action, name, version, ...) 324function search.act_on_src_or_rockspec(action, ns_name, version, ...)
325 assert(type(action) == "function") 325 assert(type(action) == "function")
326 assert(type(name) == "string") 326 assert(type(ns_name) == "string")
327 assert(type(version) == "string" or not version) 327 assert(type(version) == "string" or not version)
328 328
329 local _, namespace = util.split_namespace(name) 329 local query = queries.new(ns_name, version, false, "src|rockspec")
330 local query = queries.new(name, version, false, "src|rockspec")
331 local url, err = search.find_suitable_rock(query) 330 local url, err = search.find_suitable_rock(query)
332 if not url then 331 if not url then
333 return nil, "Could not find a result named "..name..(version and " "..version or "")..": "..err 332 return nil, "Could not find a result named "..tostring(query)..": "..err
334 end 333 end
334 local _, namespace = util.split_namespace(ns_name)
335 return action(url, namespace, ...) 335 return action(url, namespace, ...)
336end 336end
337 337
338function search.pick_installed_rock(query, given_tree) 338function search.pick_installed_rock(query, given_tree)
339 assert(query:type() == "query")
340
339 local result_tree = {} 341 local result_tree = {}
340 local tree_map = {} 342 local tree_map = {}
341 local trees = cfg.rocks_trees 343 local trees = cfg.rocks_trees
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua
index 76b46d55..426868e4 100644
--- a/src/luarocks/util.lua
+++ b/src/luarocks/util.lua
@@ -459,18 +459,17 @@ end
459-- If a namespace is given in user/rock syntax, update the --namespace flag; 459-- If a namespace is given in user/rock syntax, update the --namespace flag;
460-- If a namespace is given in --namespace flag, update the user/rock syntax. 460-- If a namespace is given in --namespace flag, update the user/rock syntax.
461-- In case of conflicts, the user/rock syntax takes precedence. 461-- In case of conflicts, the user/rock syntax takes precedence.
462function util.adjust_name_and_namespace(name, flags) 462function util.adjust_name_and_namespace(ns_name, flags)
463 assert(type(name) == "string" or not name) 463 assert(type(ns_name) == "string" or not ns_name)
464 assert(type(flags) == "table") 464 assert(type(flags) == "table")
465 465
466 if not name then 466 if not ns_name then
467 return 467 return
468 elseif name:match("%.rockspec$") or name:match("%.rock$") then 468 elseif ns_name:match("%.rockspec$") or ns_name:match("%.rock$") then
469 return name 469 return ns_name
470 end 470 end
471 471
472 local namespace 472 local name, namespace = util.split_namespace(ns_name)
473 name, namespace = util.split_namespace(name)
474 if namespace then 473 if namespace then
475 flags["namespace"] = namespace 474 flags["namespace"] = namespace
476 end 475 end
@@ -481,14 +480,14 @@ function util.adjust_name_and_namespace(name, flags)
481end 480end
482 481
483-- Split name and namespace of a package name. 482-- Split name and namespace of a package name.
484-- @param name a name that may be in "namespace/name" format 483-- @param ns_name a name that may be in "namespace/name" format
485-- @return string, string? - name and optionally a namespace 484-- @return string, string? - name and optionally a namespace
486function util.split_namespace(name) 485function util.split_namespace(ns_name)
487 local p1, p2 = name:match("^([^/]+)/([^/]+)$") 486 local p1, p2 = ns_name:match("^([^/]+)/([^/]+)$")
488 if p1 then 487 if p1 then
489 return p2, p1 488 return p2, p1
490 end 489 end
491 return name 490 return ns_name
492end 491end
493 492
494return util 493return util