aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/repos.lua54
1 files changed, 29 insertions, 25 deletions
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua
index 4ef43867..7c3251b9 100644
--- a/src/luarocks/repos.lua
+++ b/src/luarocks/repos.lua
@@ -73,50 +73,54 @@ local function recurse_rock_manifest_tree(file_tree, action)
73 return do_recurse_rock_manifest_tree(file_tree) 73 return do_recurse_rock_manifest_tree(file_tree)
74end 74end
75 75
76local function store_package_data(result, name, file_tree) 76local function store_package_data(result, rock_manifest, deploy_type)
77 if not file_tree then return end 77 if rock_manifest[deploy_type] then
78 return recurse_rock_manifest_tree(file_tree, function(file_path) 78 recurse_rock_manifest_tree(rock_manifest[deploy_type], function(file_path)
79 result[path.path_to_module(file_path)] = file_path 79 local _, item_name = manif.get_provided_item(deploy_type, file_path)
80 return true 80 result[item_name] = file_path
81 end) 81 return true
82 end)
83 end
82end 84end
83 85
84--- Obtain a list of modules within an installed package. 86--- Obtain a table of modules within an installed package.
85-- @param package string: The package name; for example "luasocket" 87-- @param name string: The package name; for example "luasocket"
86-- @param version string: The exact version number including revision; 88-- @param version string: The exact version number including revision;
87-- for example "2.0.1-1". 89-- for example "2.0.1-1".
88-- @return table: A table of modules where keys are module identifiers 90-- @return table: A table of modules where keys are module names
89-- in "foo.bar" format and values are pathnames in architecture-dependent 91-- and values are file paths of files providing modules
90-- "foo/bar.so" format. If no modules are found or if package or version 92-- relative to "lib" or "lua" rock manifest subtree.
93-- If no modules are found or if package name or version
91-- are invalid, an empty table is returned. 94-- are invalid, an empty table is returned.
92function repos.package_modules(package, version) 95function repos.package_modules(name, version)
93 assert(type(package) == "string") 96 assert(type(name) == "string")
94 assert(type(version) == "string") 97 assert(type(version) == "string")
95 98
96 local result = {} 99 local result = {}
97 local rock_manifest = manif.load_rock_manifest(package, version) 100 local rock_manifest = manif.load_rock_manifest(name, version)
98 if not rock_manifest then return result end 101 if not rock_manifest then return result end
99 store_package_data(result, package, rock_manifest.lib) 102 store_package_data(result, rock_manifest, "lib")
100 store_package_data(result, package, rock_manifest.lua) 103 store_package_data(result, rock_manifest, "lua")
101 return result 104 return result
102end 105end
103 106
104--- Obtain a list of command-line scripts within an installed package. 107--- Obtain a table of command-line scripts within an installed package.
105-- @param package string: The package name; for example "luasocket" 108-- @param name string: The package name; for example "luasocket"
106-- @param version string: The exact version number including revision; 109-- @param version string: The exact version number including revision;
107-- for example "2.0.1-1". 110-- for example "2.0.1-1".
108-- @return table: A table of items where keys are command names 111-- @return table: A table of commands where keys and values are command names
109-- as strings and values are pathnames in architecture-dependent 112-- as strings - file paths of files providing commands
110-- ".../bin/foo" format. If no modules are found or if package or version 113-- relative to "bin" rock manifest subtree.
114-- If no commands are found or if package name or version
111-- are invalid, an empty table is returned. 115-- are invalid, an empty table is returned.
112function repos.package_commands(package, version) 116function repos.package_commands(name, version)
113 assert(type(package) == "string") 117 assert(type(name) == "string")
114 assert(type(version) == "string") 118 assert(type(version) == "string")
115 119
116 local result = {} 120 local result = {}
117 local rock_manifest = manif.load_rock_manifest(package, version) 121 local rock_manifest = manif.load_rock_manifest(name, version)
118 if not rock_manifest then return result end 122 if not rock_manifest then return result end
119 store_package_data(result, package, rock_manifest.bin) 123 store_package_data(result, rock_manifest, "bin")
120 return result 124 return result
121end 125end
122 126