diff options
| author | Peter Melnichenko <mpeterval@gmail.com> | 2016-11-12 00:35:46 +0300 |
|---|---|---|
| committer | Peter Melnichenko <mpeterval@gmail.com> | 2016-11-12 00:41:46 +0300 |
| commit | 91c1f20bbafdee236f78a93a78c233c833f413e9 (patch) | |
| tree | 5230c4175ac979c3f49456e5419f740e49ad402b /src | |
| parent | 5e5d324e19135b1de0d3014ea203b910abc22853 (diff) | |
| download | luarocks-91c1f20bbafdee236f78a93a78c233c833f413e9.tar.gz luarocks-91c1f20bbafdee236f78a93a78c233c833f413e9.tar.bz2 luarocks-91c1f20bbafdee236f78a93a78c233c833f413e9.zip | |
Fix module paths `luarocks show` displays for "asset" files
Remove path.which that produced incorrect results for files
with no .lua/.so/.dll extension, reimplement similar functionality
in luarocks.repos (with support for commands as well) and use that instead.
Ref #424.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cmd/show.lua | 5 | ||||
| -rw-r--r-- | src/luarocks/path.lua | 21 | ||||
| -rw-r--r-- | src/luarocks/repos.lua | 27 |
3 files changed, 28 insertions, 25 deletions
diff --git a/src/luarocks/cmd/show.lua b/src/luarocks/cmd/show.lua index 1ff81e08..ebb515c0 100644 --- a/src/luarocks/cmd/show.lua +++ b/src/luarocks/cmd/show.lua | |||
| @@ -9,6 +9,7 @@ local path = require("luarocks.path") | |||
| 9 | local deps = require("luarocks.deps") | 9 | local deps = require("luarocks.deps") |
| 10 | local fetch = require("luarocks.fetch") | 10 | local fetch = require("luarocks.fetch") |
| 11 | local manif = require("luarocks.manif") | 11 | local manif = require("luarocks.manif") |
| 12 | local repos = require("luarocks.repos") | ||
| 12 | 13 | ||
| 13 | show.help_summary = "Show information about an installed rock." | 14 | show.help_summary = "Show information about an installed rock." |
| 14 | 15 | ||
| @@ -124,8 +125,8 @@ function show.command(flags, name, version) | |||
| 124 | if next(minfo.modules) then | 125 | if next(minfo.modules) then |
| 125 | util.printout() | 126 | util.printout() |
| 126 | util.printout("Modules:") | 127 | util.printout("Modules:") |
| 127 | for mod, filename in util.sortedpairs(minfo.modules) do | 128 | for mod in util.sortedpairs(minfo.modules) do |
| 128 | util.printout("\t"..mod.." ("..path.which(mod, filename, name, version, repo, manifest)..")") | 129 | util.printout("\t"..mod.." ("..repos.which(name, version, "module", mod, repo)..")") |
| 129 | end | 130 | end |
| 130 | end | 131 | end |
| 131 | local direct_deps = {} | 132 | local direct_deps = {} |
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index 83e9c295..71893cf1 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
| @@ -231,25 +231,4 @@ function path.use_tree(tree) | |||
| 231 | cfg.deploy_lib_dir = path.deploy_lib_dir(tree) | 231 | cfg.deploy_lib_dir = path.deploy_lib_dir(tree) |
| 232 | end | 232 | end |
| 233 | 233 | ||
| 234 | --- Return the pathname of the file that would be loaded for a module, | ||
| 235 | -- returning the versioned pathname if given version is not the default version | ||
| 236 | -- in the given manifest. | ||
| 237 | -- @param module_name string: module name (eg. "socket.core") | ||
| 238 | -- @param file_name string: module file name as in manifest (eg. "socket/core.so") | ||
| 239 | -- @param name string: name of the package (eg. "luasocket") | ||
| 240 | -- @param version string: version number (eg. "2.0.2-1") | ||
| 241 | -- @param tree string: repository path (eg. "/usr/local") | ||
| 242 | -- @param manifest table: the manifest table for the tree. | ||
| 243 | -- @return string: filename of the module (eg. "/usr/local/lib/lua/5.1/socket/core.so") | ||
| 244 | function path.which(module_name, file_name, name, version, tree, manifest) | ||
| 245 | local versions = manifest.modules[module_name] | ||
| 246 | assert(versions) | ||
| 247 | for i, name_version in ipairs(versions) do | ||
| 248 | if name_version == name.."/"..version then | ||
| 249 | return path.which_i(file_name, name, version, tree, i):gsub("//", "/") | ||
| 250 | end | ||
| 251 | end | ||
| 252 | assert(false) | ||
| 253 | end | ||
| 254 | |||
| 255 | return path | 234 | return path |
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index 7c3251b9..5d5dedd6 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua | |||
| @@ -231,8 +231,9 @@ end | |||
| 231 | -- item from the newest version of lexicographically smallest package | 231 | -- item from the newest version of lexicographically smallest package |
| 232 | -- is deployed using non-versioned name and others use versioned names. | 232 | -- is deployed using non-versioned name and others use versioned names. |
| 233 | 233 | ||
| 234 | local function get_deploy_paths(name, version, deploy_type, file_path) | 234 | local function get_deploy_paths(name, version, deploy_type, file_path, repo) |
| 235 | local deploy_dir = cfg["deploy_" .. deploy_type .. "_dir"] | 235 | repo = repo or cfg.root_dir |
| 236 | local deploy_dir = path["deploy_" .. deploy_type .. "_dir"](repo) | ||
| 236 | local non_versioned = dir.path(deploy_dir, file_path) | 237 | local non_versioned = dir.path(deploy_dir, file_path) |
| 237 | local versioned = path.versioned_name(non_versioned, deploy_dir, name, version) | 238 | local versioned = path.versioned_name(non_versioned, deploy_dir, name, version) |
| 238 | return non_versioned, versioned | 239 | return non_versioned, versioned |
| @@ -423,4 +424,26 @@ function repos.delete_version(name, version, deps_mode, quick) | |||
| 423 | return writer.remove_from_manifest(name, version, nil, deps_mode) | 424 | return writer.remove_from_manifest(name, version, nil, deps_mode) |
| 424 | end | 425 | end |
| 425 | 426 | ||
| 427 | --- Find full path to a file providing a module or a command | ||
| 428 | -- in a package. | ||
| 429 | -- @param name string: name of package. | ||
| 430 | -- @param version string: exact package version in string format. | ||
| 431 | -- @param item_type string: "module" or "command". | ||
| 432 | -- @param item_name string: module or command name. | ||
| 433 | -- @param root string or nil: A local root dir for a rocks tree. If not given, the default is used. | ||
| 434 | -- @return string: absolute path to the file providing given module | ||
| 435 | -- or command. | ||
| 436 | function repos.which(name, version, item_type, item_name, repo) | ||
| 437 | local deploy_type, file_path = manif.get_providing_file(name, version, item_type, item_name, repo) | ||
| 438 | local non_versioned, versioned = get_deploy_paths(name, version, deploy_type, file_path, repo) | ||
| 439 | local cur_name, cur_version = manif.get_current_provider(item_type, item_name) | ||
| 440 | local deploy_path = (name == cur_name and version == cur_version) and non_versioned or versioned | ||
| 441 | |||
| 442 | if deploy_type == "bin" and cfg.wrapper_suffix and cfg.wrapper_suffix ~= "" then | ||
| 443 | deploy_path = find_suffixed(deploy_path, cfg.wrapper_suffix) or deploy_path | ||
| 444 | end | ||
| 445 | |||
| 446 | return deploy_path | ||
| 447 | end | ||
| 448 | |||
| 426 | return repos | 449 | return repos |
