diff options
Diffstat (limited to 'src/luarocks/path.lua')
-rw-r--r-- | src/luarocks/path.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index 1c94b639..bbd928a0 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -305,6 +305,49 @@ function use_tree(tree) | |||
305 | cfg.deploy_lib_dir = deploy_lib_dir(tree) | 305 | cfg.deploy_lib_dir = deploy_lib_dir(tree) |
306 | end | 306 | end |
307 | 307 | ||
308 | --- Return the pathname of the file that would be loaded for a module, indexed. | ||
309 | -- @param module_name string: module name (eg. "socket.core") | ||
310 | -- @param name string: name of the package (eg. "luasocket") | ||
311 | -- @param version string: version number (eg. "2.0.2-1") | ||
312 | -- @param tree string: repository path (eg. "/usr/local") | ||
313 | -- @param i number: the index, 1 if version is the current default, > 1 otherwise. | ||
314 | -- This is done this way for use by select_module in luarocks.loader. | ||
315 | -- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so") | ||
316 | function which_i(module_name, name, version, tree, i) | ||
317 | local deploy_dir | ||
318 | if module_name:match("%.lua$") then | ||
319 | deploy_dir = deploy_lua_dir(tree) | ||
320 | module_name = dir.path(deploy_dir, module_name) | ||
321 | else | ||
322 | deploy_dir = deploy_lib_dir(tree) | ||
323 | module_name = dir.path(deploy_dir, module_name) | ||
324 | end | ||
325 | if i > 1 then | ||
326 | module_name = versioned_name(module_name, deploy_dir, name, version) | ||
327 | end | ||
328 | return module_name | ||
329 | end | ||
330 | |||
331 | --- Return the pathname of the file that would be loaded for a module, | ||
332 | -- returning the versioned pathname if given version is not the default version | ||
333 | -- in the given manifest. | ||
334 | -- @param module_name string: module name (eg. "socket.core") | ||
335 | -- @param name string: name of the package (eg. "luasocket") | ||
336 | -- @param version string: version number (eg. "2.0.2-1") | ||
337 | -- @param tree string: repository path (eg. "/usr/local") | ||
338 | -- @param manifest table: the manifest table for the tree. | ||
339 | -- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so") | ||
340 | function which(module_name, filename, name, version, tree, manifest) | ||
341 | local versions = manifest.modules[module_name] | ||
342 | assert(versions) | ||
343 | for i, name_version in ipairs(versions) do | ||
344 | if name_version == name.."/"..version then | ||
345 | return which_i(filename, name, version, tree, i):gsub("//", "/") | ||
346 | end | ||
347 | end | ||
348 | assert(false) | ||
349 | end | ||
350 | |||
308 | --- Driver function for "path" command. | 351 | --- Driver function for "path" command. |
309 | -- @return boolean This function always succeeds. | 352 | -- @return boolean This function always succeeds. |
310 | function run(...) | 353 | function run(...) |