diff options
Diffstat (limited to 'src/luarocks/path.lua')
-rw-r--r-- | src/luarocks/path.lua | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index fb5eec7e..bc7ab63b 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -342,44 +342,45 @@ end | |||
342 | local is_src_extension = { [".lua"] = true, [".tl"] = true, [".tld"] = true, [".moon"] = true } | 342 | local is_src_extension = { [".lua"] = true, [".tl"] = true, [".tld"] = true, [".moon"] = true } |
343 | 343 | ||
344 | --- Return the pathname of the file that would be loaded for a module, indexed. | 344 | --- Return the pathname of the file that would be loaded for a module, indexed. |
345 | -- @param module_name string: module name (eg. "socket.core") | 345 | -- @param file_name string: module file name as in manifest (eg. "socket/core.so") |
346 | -- @param name string: name of the package (eg. "luasocket") | 346 | -- @param name string: name of the package (eg. "luasocket") |
347 | -- @param version string: version number (eg. "2.0.2-1") | 347 | -- @param version string: version number (eg. "2.0.2-1") |
348 | -- @param tree string: repository path (eg. "/usr/local") | 348 | -- @param tree string: repository path (eg. "/usr/local") |
349 | -- @param i number: the index, 1 if version is the current default, > 1 otherwise. | 349 | -- @param i number: the index, 1 if version is the current default, > 1 otherwise. |
350 | -- This is done this way for use by select_module in luarocks.loader. | 350 | -- This is done this way for use by select_module in luarocks.loader. |
351 | -- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so") | 351 | -- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so") |
352 | function path.which_i(module_name, name, version, tree, i) | 352 | function path.which_i(file_name, name, version, tree, i) |
353 | local deploy_dir | 353 | local deploy_dir |
354 | local extension = module_name:match("%.[a-z]+$") | 354 | local extension = file_name:match("%.[a-z]+$") |
355 | if is_src_extension[extension] then | 355 | if is_src_extension[extension] then |
356 | deploy_dir = path.deploy_lua_dir(tree) | 356 | deploy_dir = path.deploy_lua_dir(tree) |
357 | module_name = dir.path(deploy_dir, module_name) | 357 | file_name = dir.path(deploy_dir, file_name) |
358 | else | 358 | else |
359 | deploy_dir = path.deploy_lib_dir(tree) | 359 | deploy_dir = path.deploy_lib_dir(tree) |
360 | module_name = dir.path(deploy_dir, module_name) | 360 | file_name = dir.path(deploy_dir, file_name) |
361 | end | 361 | end |
362 | if i > 1 then | 362 | if i > 1 then |
363 | module_name = path.versioned_name(module_name, deploy_dir, name, version) | 363 | file_name = path.versioned_name(file_name, deploy_dir, name, version) |
364 | end | 364 | end |
365 | return module_name | 365 | return file_name |
366 | end | 366 | end |
367 | 367 | ||
368 | --- Return the pathname of the file that would be loaded for a module, | 368 | --- Return the pathname of the file that would be loaded for a module, |
369 | -- returning the versioned pathname if given version is not the default version | 369 | -- returning the versioned pathname if given version is not the default version |
370 | -- in the given manifest. | 370 | -- in the given manifest. |
371 | -- @param module_name string: module name (eg. "socket.core") | 371 | -- @param module_name string: module name (eg. "socket.core") |
372 | -- @param file_name string: module file name as in manifest (eg. "socket/core.so") | ||
372 | -- @param name string: name of the package (eg. "luasocket") | 373 | -- @param name string: name of the package (eg. "luasocket") |
373 | -- @param version string: version number (eg. "2.0.2-1") | 374 | -- @param version string: version number (eg. "2.0.2-1") |
374 | -- @param tree string: repository path (eg. "/usr/local") | 375 | -- @param tree string: repository path (eg. "/usr/local") |
375 | -- @param manifest table: the manifest table for the tree. | 376 | -- @param manifest table: the manifest table for the tree. |
376 | -- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so") | 377 | -- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so") |
377 | function path.which(module_name, filename, name, version, tree, manifest) | 378 | function path.which(module_name, file_name, name, version, tree, manifest) |
378 | local versions = manifest.modules[module_name] | 379 | local versions = manifest.modules[module_name] |
379 | assert(versions) | 380 | assert(versions) |
380 | for i, name_version in ipairs(versions) do | 381 | for i, name_version in ipairs(versions) do |
381 | if name_version == name.."/"..version then | 382 | if name_version == name.."/"..version then |
382 | return path.which_i(filename, name, version, tree, i):gsub("//", "/") | 383 | return path.which_i(file_name, name, version, tree, i):gsub("//", "/") |
383 | end | 384 | end |
384 | end | 385 | end |
385 | assert(false) | 386 | assert(false) |