diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-08-31 15:48:47 +0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-09-03 12:47:26 -0300 |
| commit | d09f92a84d0a9267a066af2d6978f9a51e555f5f (patch) | |
| tree | 6429c10e153ca77a3f5a3037edc928cea7eb9a97 /src | |
| parent | 4eb27bea022c1bcd816561d2e8e64d67aef62b18 (diff) | |
| download | luarocks-d09f92a84d0a9267a066af2d6978f9a51e555f5f.tar.gz luarocks-d09f92a84d0a9267a066af2d6978f9a51e555f5f.tar.bz2 luarocks-d09f92a84d0a9267a066af2d6978f9a51e555f5f.zip | |
show: base listing of modules on rock_manifest
List modules based on rock_manifest, for better precision. Overall management
of modules should be moved to use rock_manifest instead of the modules list
from the general local manifest, but this is a good first step.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cmd/show.lua | 34 | ||||
| -rw-r--r-- | src/luarocks/queries.lua | 5 | ||||
| -rw-r--r-- | src/luarocks/repos.lua | 34 |
3 files changed, 47 insertions, 26 deletions
diff --git a/src/luarocks/cmd/show.lua b/src/luarocks/cmd/show.lua index b6242cbc..c90a6bea 100644 --- a/src/luarocks/cmd/show.lua +++ b/src/luarocks/cmd/show.lua | |||
| @@ -4,6 +4,7 @@ local show = {} | |||
| 4 | 4 | ||
| 5 | local queries = require("luarocks.queries") | 5 | local queries = require("luarocks.queries") |
| 6 | local search = require("luarocks.search") | 6 | local search = require("luarocks.search") |
| 7 | local dir = require("luarocks.core.dir") | ||
| 7 | local cfg = require("luarocks.core.cfg") | 8 | local cfg = require("luarocks.core.cfg") |
| 8 | local util = require("luarocks.util") | 9 | local util = require("luarocks.util") |
| 9 | local path = require("luarocks.path") | 10 | local path = require("luarocks.path") |
| @@ -44,10 +45,10 @@ local friendly_template = [[ | |||
| 44 | ?location :Installed in: \t${location} | 45 | ?location :Installed in: \t${location} |
| 45 | ?commands : | 46 | ?commands : |
| 46 | ?commands :Commands: | 47 | ?commands :Commands: |
| 47 | *commands :\t${name} (${repo}) | 48 | *commands :\t${name} (${file}) |
| 48 | ?modules : | 49 | ?modules : |
| 49 | ?modules :Modules: | 50 | ?modules :Modules: |
| 50 | *modules :\t${name} (${repo}) | 51 | *modules :\t${name} (${file}) |
| 51 | ?bdeps : | 52 | ?bdeps : |
| 52 | ?bdeps :Has build dependency on: | 53 | ?bdeps :Has build dependency on: |
| 53 | *bdeps :\t${name} (${label}) | 54 | *bdeps :\t${name} (${label}) |
| @@ -74,8 +75,8 @@ local porcelain_template = [[ | |||
| 74 | ?issues :issues\t${issues} | 75 | ?issues :issues\t${issues} |
| 75 | ?labels :labels\t${labels} | 76 | ?labels :labels\t${labels} |
| 76 | ?location :location\t${location} | 77 | ?location :location\t${location} |
| 77 | *commands :command\t${name}\t${repo} | 78 | *commands :command\t${name}\t${file} |
| 78 | *modules :module\t${name}\t${repo} | 79 | *modules :module\t${name}\t${file} |
| 79 | *bdeps :build_dependency\t${name}\t${label} | 80 | *bdeps :build_dependency\t${name}\t${label} |
| 80 | *tdeps :test_dependency\t${name}\t${label} | 81 | *tdeps :test_dependency\t${name}\t${label} |
| 81 | *deps :dependency\t${name}\t${label} | 82 | *deps :dependency\t${name}\t${label} |
| @@ -147,11 +148,32 @@ end | |||
| 147 | local function files_to_list(name, version, item_set, item_type, repo) | 148 | local function files_to_list(name, version, item_set, item_type, repo) |
| 148 | local ret = {} | 149 | local ret = {} |
| 149 | for item_name in util.sortedpairs(item_set) do | 150 | for item_name in util.sortedpairs(item_set) do |
| 150 | table.insert(ret, { name = item_name, repo = repos.which(name, version, item_type, item_name, repo) }) | 151 | table.insert(ret, { name = item_name, file = repos.which(name, version, item_type, item_name, repo) }) |
| 151 | end | 152 | end |
| 152 | return ret | 153 | return ret |
| 153 | end | 154 | end |
| 154 | 155 | ||
| 156 | local function modules_to_list(name, version, repo) | ||
| 157 | local ret = {} | ||
| 158 | local rock_manifest = manif.load_rock_manifest(name, version, repo) | ||
| 159 | |||
| 160 | local lua_dir = path.lua_dir(name, version, repo) | ||
| 161 | local lib_dir = path.lib_dir(name, version, repo) | ||
| 162 | repos.recurse_rock_manifest_entry(rock_manifest.lua, function(pathname, modname) | ||
| 163 | table.insert(ret, { name = modname, file = dir.path(lua_dir, pathname) }) | ||
| 164 | end) | ||
| 165 | repos.recurse_rock_manifest_entry(rock_manifest.lib, function(pathname, modname) | ||
| 166 | table.insert(ret, { name = modname, file = dir.path(lib_dir, pathname) }) | ||
| 167 | end) | ||
| 168 | table.sort(ret, function(a, b) | ||
| 169 | if a.name == b.name then | ||
| 170 | return a.file < b.file | ||
| 171 | end | ||
| 172 | return a.name < b.name | ||
| 173 | end) | ||
| 174 | return ret | ||
| 175 | end | ||
| 176 | |||
| 155 | local function deps_to_list(dependencies, tree) | 177 | local function deps_to_list(dependencies, tree) |
| 156 | local ret = {} | 178 | local ret = {} |
| 157 | for _, dep in ipairs(dependencies or {}) do | 179 | for _, dep in ipairs(dependencies or {}) do |
| @@ -188,7 +210,7 @@ local function show_rock(template, namespace, name, version, rockspec, repo, min | |||
| 188 | labels = desc.labels and table.concat(desc.labels, ", "), | 210 | labels = desc.labels and table.concat(desc.labels, ", "), |
| 189 | location = path.rocks_tree_to_string(repo), | 211 | location = path.rocks_tree_to_string(repo), |
| 190 | commands = files_to_list(name, version, minfo.commands, "command", repo), | 212 | commands = files_to_list(name, version, minfo.commands, "command", repo), |
| 191 | modules = files_to_list(name, version, minfo.modules, "module", repo), | 213 | modules = modules_to_list(name, version, repo), |
| 192 | bdeps = deps_to_list(rockspec.build_dependencies, tree), | 214 | bdeps = deps_to_list(rockspec.build_dependencies, tree), |
| 193 | tdeps = deps_to_list(rockspec.test_dependencies, tree), | 215 | tdeps = deps_to_list(rockspec.test_dependencies, tree), |
| 194 | deps = deps_to_list(rockspec.dependencies, tree), | 216 | deps = deps_to_list(rockspec.dependencies, tree), |
diff --git a/src/luarocks/queries.lua b/src/luarocks/queries.lua index 92d76460..15dc5fac 100644 --- a/src/luarocks/queries.lua +++ b/src/luarocks/queries.lua | |||
| @@ -198,10 +198,11 @@ function query_mt:__tostring() | |||
| 198 | if #self.constraints > 0 then | 198 | if #self.constraints > 0 then |
| 199 | local pretty = {} | 199 | local pretty = {} |
| 200 | for _, c in ipairs(self.constraints) do | 200 | for _, c in ipairs(self.constraints) do |
| 201 | local v = c.version.string | ||
| 201 | if c.op == "==" then | 202 | if c.op == "==" then |
| 202 | table.insert(pretty, tostring(c.version)) | 203 | table.insert(pretty, v) |
| 203 | else | 204 | else |
| 204 | table.insert(pretty, c.op .. " " .. tostring(c.version)) | 205 | table.insert(pretty, c.op .. " " .. v) |
| 205 | end | 206 | end |
| 206 | end | 207 | end |
| 207 | table.insert(out, " ") | 208 | table.insert(out, " ") |
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index dd2a5142..37a81c20 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua | |||
| @@ -51,31 +51,37 @@ function repos.is_installed(name, version) | |||
| 51 | return fs.is_dir(path.install_dir(name, version)) | 51 | return fs.is_dir(path.install_dir(name, version)) |
| 52 | end | 52 | end |
| 53 | 53 | ||
| 54 | local function recurse_rock_manifest_tree(file_tree, action) | 54 | function repos.recurse_rock_manifest_entry(entry, action) |
| 55 | assert(type(file_tree) == "table") | 55 | assert(entry == nil or type(entry) == "table") |
| 56 | assert(type(action) == "function") | 56 | assert(type(action) == "function") |
| 57 | 57 | ||
| 58 | local function do_recurse_rock_manifest_tree(tree, parent_path) | 58 | if entry == nil then |
| 59 | return true | ||
| 60 | end | ||
| 61 | |||
| 62 | local function do_recurse_rock_manifest_tree(tree, parent_path, parent_mod) | ||
| 59 | for file, sub in pairs(tree) do | 63 | for file, sub in pairs(tree) do |
| 60 | local sub_path = (parent_path and (parent_path .. "/") or "") .. file | 64 | local sub_path = (parent_path and (parent_path .. "/") or "") .. file |
| 65 | local sub_mod = (parent_mod and (parent_mod .. ".") or "") .. file | ||
| 61 | local ok, err | 66 | local ok, err |
| 62 | 67 | ||
| 63 | if type(sub) == "table" then | 68 | if type(sub) == "table" then |
| 64 | ok, err = do_recurse_rock_manifest_tree(sub, sub_path) | 69 | ok, err = do_recurse_rock_manifest_tree(sub, sub_path, sub_mod) |
| 65 | else | 70 | else |
| 66 | ok, err = action(sub_path) | 71 | local mod_no_ext = sub_mod:gsub("%.[^.]*$", "") |
| 72 | ok, err = action(sub_path, mod_no_ext) | ||
| 67 | end | 73 | end |
| 68 | 74 | ||
| 69 | if not ok then return nil, err end | 75 | if err then return nil, err end |
| 70 | end | 76 | end |
| 71 | return true | 77 | return true |
| 72 | end | 78 | end |
| 73 | return do_recurse_rock_manifest_tree(file_tree) | 79 | return do_recurse_rock_manifest_tree(entry) |
| 74 | end | 80 | end |
| 75 | 81 | ||
| 76 | local function store_package_data(result, rock_manifest, deploy_type) | 82 | local function store_package_data(result, rock_manifest, deploy_type) |
| 77 | if rock_manifest[deploy_type] then | 83 | if rock_manifest[deploy_type] then |
| 78 | recurse_rock_manifest_tree(rock_manifest[deploy_type], function(file_path) | 84 | repos.recurse_rock_manifest_entry(rock_manifest[deploy_type], function(file_path) |
| 79 | local _, item_name = manif.get_provided_item(deploy_type, file_path) | 85 | local _, item_name = manif.get_provided_item(deploy_type, file_path) |
| 80 | result[item_name] = file_path | 86 | result[item_name] = file_path |
| 81 | return true | 87 | return true |
| @@ -280,11 +286,7 @@ function repos.deploy_files(name, version, wrap_bin_scripts, deps_mode) | |||
| 280 | if not rock_manifest then return nil, load_err end | 286 | if not rock_manifest then return nil, load_err end |
| 281 | 287 | ||
| 282 | local function deploy_file_tree(deploy_type, source_dir, move_fn, suffix) | 288 | local function deploy_file_tree(deploy_type, source_dir, move_fn, suffix) |
| 283 | if not rock_manifest[deploy_type] then | 289 | return repos.recurse_rock_manifest_entry(rock_manifest[deploy_type], function(file_path) |
| 284 | return true | ||
| 285 | end | ||
| 286 | |||
| 287 | return recurse_rock_manifest_tree(rock_manifest[deploy_type], function(file_path) | ||
| 288 | local source = dir.path(source_dir, file_path) | 290 | local source = dir.path(source_dir, file_path) |
| 289 | 291 | ||
| 290 | local target, prepare_err = prepare_target(name, version, deploy_type, file_path, suffix) | 292 | local target, prepare_err = prepare_target(name, version, deploy_type, file_path, suffix) |
| @@ -363,11 +365,7 @@ function repos.delete_version(name, version, deps_mode, quick) | |||
| 363 | if not rock_manifest then return nil, load_err end | 365 | if not rock_manifest then return nil, load_err end |
| 364 | 366 | ||
| 365 | local function delete_deployed_file_tree(deploy_type, suffix) | 367 | local function delete_deployed_file_tree(deploy_type, suffix) |
| 366 | if not rock_manifest[deploy_type] then | 368 | return repos.recurse_rock_manifest_entry(rock_manifest[deploy_type], function(file_path) |
| 367 | return true | ||
| 368 | end | ||
| 369 | |||
| 370 | return recurse_rock_manifest_tree(rock_manifest[deploy_type], function(file_path) | ||
| 371 | local non_versioned, versioned = get_deploy_paths(name, version, deploy_type, file_path) | 369 | local non_versioned, versioned = get_deploy_paths(name, version, deploy_type, file_path) |
| 372 | 370 | ||
| 373 | -- Figure out if the file is deployed using versioned or non-versioned name. | 371 | -- Figure out if the file is deployed using versioned or non-versioned name. |
