aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Melnichenko <mpeterval@gmail.com>2016-11-12 00:35:46 +0300
committerPeter Melnichenko <mpeterval@gmail.com>2017-09-12 18:17:21 +0300
commit6ef95c8f0a1dfffdefa322b0249fe7f74acec1fa (patch)
tree0bf05978bb4ff0db9a14ea14bfb482cd800e5c32
parent7e661d3a394aaf7a015ab927e7459d59abc2041b (diff)
downloadluarocks-6ef95c8f0a1dfffdefa322b0249fe7f74acec1fa.tar.gz
luarocks-6ef95c8f0a1dfffdefa322b0249fe7f74acec1fa.tar.bz2
luarocks-6ef95c8f0a1dfffdefa322b0249fe7f74acec1fa.zip
Fix module paths `luarocks show` displays for "asset" files
Instead of using 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. Ref #424.
-rw-r--r--src/luarocks/repos.lua27
-rw-r--r--src/luarocks/show.lua5
2 files changed, 28 insertions, 4 deletions
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua
index 5d5eac70..abc62b0d 100644
--- a/src/luarocks/repos.lua
+++ b/src/luarocks/repos.lua
@@ -226,8 +226,9 @@ end
226-- item from the newest version of lexicographically smallest package 226-- item from the newest version of lexicographically smallest package
227-- is deployed using non-versioned name and others use versioned names. 227-- is deployed using non-versioned name and others use versioned names.
228 228
229local function get_deploy_paths(name, version, deploy_type, file_path) 229local function get_deploy_paths(name, version, deploy_type, file_path, repo)
230 local deploy_dir = cfg["deploy_" .. deploy_type .. "_dir"] 230 repo = repo or cfg.root_dir
231 local deploy_dir = path["deploy_" .. deploy_type .. "_dir"](repo)
231 local non_versioned = dir.path(deploy_dir, file_path) 232 local non_versioned = dir.path(deploy_dir, file_path)
232 local versioned = path.versioned_name(non_versioned, deploy_dir, name, version) 233 local versioned = path.versioned_name(non_versioned, deploy_dir, name, version)
233 return non_versioned, versioned 234 return non_versioned, versioned
@@ -419,4 +420,26 @@ function repos.delete_version(name, version, deps_mode, quick)
419 return manif.remove_from_manifest(name, version, nil, deps_mode) 420 return manif.remove_from_manifest(name, version, nil, deps_mode)
420end 421end
421 422
423--- Find full path to a file providing a module or a command
424-- in a package.
425-- @param name string: name of package.
426-- @param version string: exact package version in string format.
427-- @param item_type string: "module" or "command".
428-- @param item_name string: module or command name.
429-- @param root string or nil: A local root dir for a rocks tree. If not given, the default is used.
430-- @return string: absolute path to the file providing given module
431-- or command.
432function repos.which(name, version, item_type, item_name, repo)
433 local deploy_type, file_path = manif.get_providing_file(name, version, item_type, item_name, repo)
434 local non_versioned, versioned = get_deploy_paths(name, version, deploy_type, file_path, repo)
435 local cur_name, cur_version = manif.get_current_provider(item_type, item_name)
436 local deploy_path = (name == cur_name and version == cur_version) and non_versioned or versioned
437
438 if deploy_type == "bin" and cfg.wrapper_suffix and cfg.wrapper_suffix ~= "" then
439 deploy_path = find_suffixed(deploy_path, cfg.wrapper_suffix) or deploy_path
440 end
441
442 return deploy_path
443end
444
422return repos 445return repos
diff --git a/src/luarocks/show.lua b/src/luarocks/show.lua
index 85c7edcb..8ec6394b 100644
--- a/src/luarocks/show.lua
+++ b/src/luarocks/show.lua
@@ -10,6 +10,7 @@ local path = require("luarocks.path")
10local deps = require("luarocks.deps") 10local deps = require("luarocks.deps")
11local fetch = require("luarocks.fetch") 11local fetch = require("luarocks.fetch")
12local manif = require("luarocks.manif") 12local manif = require("luarocks.manif")
13local repos = require("luarocks.repos")
13 14
14util.add_run_function(show) 15util.add_run_function(show)
15show.help_summary = "Show information about an installed rock." 16show.help_summary = "Show information about an installed rock."
@@ -118,8 +119,8 @@ function show.command(flags, name, version)
118 if next(minfo.modules) then 119 if next(minfo.modules) then
119 util.printout() 120 util.printout()
120 util.printout("Modules:") 121 util.printout("Modules:")
121 for mod, filename in util.sortedpairs(minfo.modules) do 122 for mod in util.sortedpairs(minfo.modules) do
122 util.printout("\t"..mod.." ("..path.which(mod, filename, name, version, repo, manifest)..")") 123 util.printout("\t"..mod.." ("..repos.which(name, version, "module", mod, repo)..")")
123 end 124 end
124 end 125 end
125 local direct_deps = {} 126 local direct_deps = {}