aboutsummaryrefslogtreecommitdiff
path: root/src/luarocks/path.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/luarocks/path.lua')
-rw-r--r--src/luarocks/path.lua128
1 files changed, 64 insertions, 64 deletions
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua
index 8c795e8b..03ed1b90 100644
--- a/src/luarocks/path.lua
+++ b/src/luarocks/path.lua
@@ -1,5 +1,5 @@
1 1
2--- Path and filename handling functions. 2--- LuaRocks-specific path handling functions.
3-- All paths are configured in this module, making it a single 3-- All paths are configured in this module, making it a single
4-- point where the layout of the local installation is defined in LuaRocks. 4-- point where the layout of the local installation is defined in LuaRocks.
5module("luarocks.path", package.seeall) 5module("luarocks.path", package.seeall)
@@ -25,12 +25,12 @@ function rockspec_name_from_rock(rock_name)
25 return base_name:match("(.*)%.[^.]*.rock") .. ".rockspec" 25 return base_name:match("(.*)%.[^.]*.rock") .. ".rockspec"
26end 26end
27 27
28function rocks_dir(repo) 28function rocks_dir(tree)
29 if type(repo) == "string" then 29 if type(tree) == "string" then
30 return dir.path(repo, "lib", "luarocks", "rocks") 30 return dir.path(tree, "lib", "luarocks", "rocks")
31 else 31 else
32 assert(type(repo) == "table") 32 assert(type(tree) == "table")
33 return repo.rocks_dir or dir.path(repo.root, "lib", "luarocks", "rocks") 33 return tree.rocks_dir or dir.path(tree.root, "lib", "luarocks", "rocks")
34 end 34 end
35end 35end
36 36
@@ -41,156 +41,156 @@ function root_dir(rocks_dir)
41 return rocks_dir:match("(.*)" .. suffix .. "$") 41 return rocks_dir:match("(.*)" .. suffix .. "$")
42end 42end
43 43
44function deploy_bin_dir(repo) 44function deploy_bin_dir(tree)
45 if type(repo) == "string" then 45 if type(tree) == "string" then
46 return dir.path(repo, "bin") 46 return dir.path(tree, "bin")
47 else 47 else
48 assert(type(repo) == "table") 48 assert(type(tree) == "table")
49 return repo.bin_dir or dir.path(repo.root, "bin") 49 return tree.bin_dir or dir.path(tree.root, "bin")
50 end 50 end
51end 51end
52 52
53function deploy_lua_dir(repo) 53function deploy_lua_dir(tree)
54 if type(repo) == "string" then 54 if type(tree) == "string" then
55 return dir.path(repo, "share", "lua", "5.1") 55 return dir.path(tree, cfg.lua_modules_path)
56 else 56 else
57 assert(type(repo) == "table") 57 assert(type(tree) == "table")
58 return repo.lua_dir or dir.path(repo.root, "share", "lua", "5.1") 58 return tree.lua_dir or dir.path(tree.root, cfg.lua_modules_path)
59 end 59 end
60end 60end
61 61
62function deploy_lib_dir(repo) 62function deploy_lib_dir(tree)
63 if type(repo) == "string" then 63 if type(tree) == "string" then
64 return dir.path(repo, "lib", "lua", "5.1") 64 return dir.path(tree, cfg.lib_modules_path)
65 else 65 else
66 assert(type(repo) == "table") 66 assert(type(tree) == "table")
67 return repo.lib_dir or dir.path(repo.root, "lib", "lua", "5.1") 67 return tree.lib_dir or dir.path(tree.root, cfg.lib_modules_path)
68 end 68 end
69end 69end
70 70
71function manifest_file(repo) 71function manifest_file(tree)
72 if type(repo) == "string" then 72 if type(tree) == "string" then
73 return dir.path(repo, "lib", "luarocks", "rocks", "manifest") 73 return dir.path(tree, "lib", "luarocks", "rocks", "manifest")
74 else 74 else
75 assert(type(repo) == "table") 75 assert(type(tree) == "table")
76 return (repo.rocks_dir and dir.path(repo.rocks_dir, "manifest")) or dir.path(repo.root, "lib", "luarocks", "rocks", "manifest") 76 return (tree.rocks_dir and dir.path(tree.rocks_dir, "manifest")) or dir.path(tree.root, "lib", "luarocks", "rocks", "manifest")
77 end 77 end
78end 78end
79 79
80--- Get the repository directory for all versions of a package. 80--- Get the directory for all versions of a package in a tree.
81-- @param name string: The package name. 81-- @param name string: The package name.
82-- @return string: The resulting path -- does not guarantee that 82-- @return string: The resulting path -- does not guarantee that
83-- @param rocks_dir string or nil: If given, specifies the local repository to use. 83-- @param tree string or nil: If given, specifies the local tree to use.
84-- the package (and by extension, the path) exists. 84-- the package (and by extension, the path) exists.
85function versions_dir(name, repo) 85function versions_dir(name, tree)
86 assert(type(name) == "string") 86 assert(type(name) == "string")
87 repo = repo or cfg.root_dir 87 tree = tree or cfg.root_dir
88 return dir.path(rocks_dir(repo), name) 88 return dir.path(rocks_dir(tree), name)
89end 89end
90 90
91--- Get the local installation directory (prefix) for a package. 91--- Get the local installation directory (prefix) for a package.
92-- @param name string: The package name. 92-- @param name string: The package name.
93-- @param version string: The package version. 93-- @param version string: The package version.
94-- @param rocks_dir string or nil: If given, specifies the local repository to use. 94-- @param tree string or nil: If given, specifies the local tree to use.
95-- @return string: The resulting path -- does not guarantee that 95-- @return string: The resulting path -- does not guarantee that
96-- the package (and by extension, the path) exists. 96-- the package (and by extension, the path) exists.
97function install_dir(name, version, repo) 97function install_dir(name, version, tree)
98 assert(type(name) == "string") 98 assert(type(name) == "string")
99 assert(type(version) == "string") 99 assert(type(version) == "string")
100 repo = repo or cfg.root_dir 100 tree = tree or cfg.root_dir
101 return dir.path(rocks_dir(repo), name, version) 101 return dir.path(rocks_dir(tree), name, version)
102end 102end
103 103
104--- Get the local filename of the rockspec of an installed rock. 104--- Get the local filename of the rockspec of an installed rock.
105-- @param name string: The package name. 105-- @param name string: The package name.
106-- @param version string: The package version. 106-- @param version string: The package version.
107-- @param rocks_dir string or nil: If given, specifies the local repository to use. 107-- @param tree string or nil: If given, specifies the local tree to use.
108-- @return string: The resulting path -- does not guarantee that 108-- @return string: The resulting path -- does not guarantee that
109-- the package (and by extension, the file) exists. 109-- the package (and by extension, the file) exists.
110function rockspec_file(name, version, repo) 110function rockspec_file(name, version, tree)
111 assert(type(name) == "string") 111 assert(type(name) == "string")
112 assert(type(version) == "string") 112 assert(type(version) == "string")
113 repo = repo or cfg.root_dir 113 tree = tree or cfg.root_dir
114 return dir.path(rocks_dir(repo), name, version, name.."-"..version..".rockspec") 114 return dir.path(rocks_dir(tree), name, version, name.."-"..version..".rockspec")
115end 115end
116 116
117--- Get the local filename of the rock_manifest file of an installed rock. 117--- Get the local filename of the rock_manifest file of an installed rock.
118-- @param name string: The package name. 118-- @param name string: The package name.
119-- @param version string: The package version. 119-- @param version string: The package version.
120-- @param rocks_dir string or nil: If given, specifies the local repository to use. 120-- @param tree string or nil: If given, specifies the local tree to use.
121-- @return string: The resulting path -- does not guarantee that 121-- @return string: The resulting path -- does not guarantee that
122-- the package (and by extension, the file) exists. 122-- the package (and by extension, the file) exists.
123function rock_manifest_file(name, version, repo) 123function rock_manifest_file(name, version, tree)
124 assert(type(name) == "string") 124 assert(type(name) == "string")
125 assert(type(version) == "string") 125 assert(type(version) == "string")
126 repo = repo or cfg.root_dir 126 tree = tree or cfg.root_dir
127 return dir.path(rocks_dir(repo), name, version, "rock_manifest") 127 return dir.path(rocks_dir(tree), name, version, "rock_manifest")
128end 128end
129 129
130--- Get the local installation directory for C libraries of a package. 130--- Get the local installation directory for C libraries of a package.
131-- @param name string: The package name. 131-- @param name string: The package name.
132-- @param version string: The package version. 132-- @param version string: The package version.
133-- @param rocks_dir string or nil: If given, specifies the local repository to use. 133-- @param tree string or nil: If given, specifies the local tree to use.
134-- @return string: The resulting path -- does not guarantee that 134-- @return string: The resulting path -- does not guarantee that
135-- the package (and by extension, the path) exists. 135-- the package (and by extension, the path) exists.
136function lib_dir(name, version, repo) 136function lib_dir(name, version, tree)
137 assert(type(name) == "string") 137 assert(type(name) == "string")
138 assert(type(version) == "string") 138 assert(type(version) == "string")
139 repo = repo or cfg.root_dir 139 tree = tree or cfg.root_dir
140 return dir.path(rocks_dir(repo), name, version, "lib") 140 return dir.path(rocks_dir(tree), name, version, "lib")
141end 141end
142 142
143--- Get the local installation directory for Lua modules of a package. 143--- Get the local installation directory for Lua modules of a package.
144-- @param name string: The package name. 144-- @param name string: The package name.
145-- @param version string: The package version. 145-- @param version string: The package version.
146-- @param rocks_dir string or nil: If given, specifies the local repository to use. 146-- @param tree string or nil: If given, specifies the local tree to use.
147-- @return string: The resulting path -- does not guarantee that 147-- @return string: The resulting path -- does not guarantee that
148-- the package (and by extension, the path) exists. 148-- the package (and by extension, the path) exists.
149function lua_dir(name, version, repo) 149function lua_dir(name, version, tree)
150 assert(type(name) == "string") 150 assert(type(name) == "string")
151 assert(type(version) == "string") 151 assert(type(version) == "string")
152 repo = repo or cfg.root_dir 152 tree = tree or cfg.root_dir
153 return dir.path(rocks_dir(repo), name, version, "lua") 153 return dir.path(rocks_dir(tree), name, version, "lua")
154end 154end
155 155
156--- Get the local installation directory for documentation of a package. 156--- Get the local installation directory for documentation of a package.
157-- @param name string: The package name. 157-- @param name string: The package name.
158-- @param version string: The package version. 158-- @param version string: The package version.
159-- @param rocks_dir string or nil: If given, specifies the local repository to use. 159-- @param tree string or nil: If given, specifies the local tree to use.
160-- @return string: The resulting path -- does not guarantee that 160-- @return string: The resulting path -- does not guarantee that
161-- the package (and by extension, the path) exists. 161-- the package (and by extension, the path) exists.
162function doc_dir(name, version, repo) 162function doc_dir(name, version, tree)
163 assert(type(name) == "string") 163 assert(type(name) == "string")
164 assert(type(version) == "string") 164 assert(type(version) == "string")
165 repo = repo or cfg.root_dir 165 tree = tree or cfg.root_dir
166 return dir.path(rocks_dir(repo), name, version, "doc") 166 return dir.path(rocks_dir(tree), name, version, "doc")
167end 167end
168 168
169--- Get the local installation directory for configuration files of a package. 169--- Get the local installation directory for configuration files of a package.
170-- @param name string: The package name. 170-- @param name string: The package name.
171-- @param version string: The package version. 171-- @param version string: The package version.
172-- @param rocks_dir string or nil: If given, specifies the local repository to use. 172-- @param tree string or nil: If given, specifies the local tree to use.
173-- @return string: The resulting path -- does not guarantee that 173-- @return string: The resulting path -- does not guarantee that
174-- the package (and by extension, the path) exists. 174-- the package (and by extension, the path) exists.
175function conf_dir(name, version, repo) 175function conf_dir(name, version, tree)
176 assert(type(name) == "string") 176 assert(type(name) == "string")
177 assert(type(version) == "string") 177 assert(type(version) == "string")
178 repo = repo or cfg.root_dir 178 tree = tree or cfg.root_dir
179 return dir.path(rocks_dir(repo), name, version, "conf") 179 return dir.path(rocks_dir(tree), name, version, "conf")
180end 180end
181 181
182--- Get the local installation directory for command-line scripts 182--- Get the local installation directory for command-line scripts
183-- of a package. 183-- of a package.
184-- @param name string: The package name. 184-- @param name string: The package name.
185-- @param version string: The package version. 185-- @param version string: The package version.
186-- @param rocks_dir string or nil: If given, specifies the local repository to use. 186-- @param tree string or nil: If given, specifies the local tree to use.
187-- @return string: The resulting path -- does not guarantee that 187-- @return string: The resulting path -- does not guarantee that
188-- the package (and by extension, the path) exists. 188-- the package (and by extension, the path) exists.
189function bin_dir(name, version, repo) 189function bin_dir(name, version, tree)
190 assert(type(name) == "string") 190 assert(type(name) == "string")
191 assert(type(version) == "string") 191 assert(type(version) == "string")
192 repo = repo or cfg.root_dir 192 tree = tree or cfg.root_dir
193 return dir.path(rocks_dir(repo), name, version, "bin") 193 return dir.path(rocks_dir(tree), name, version, "bin")
194end 194end
195 195
196--- Extract name, version and arch of a rock filename, 196--- Extract name, version and arch of a rock filename,
@@ -309,7 +309,7 @@ end
309-- @return boolean This function always succeeds. 309-- @return boolean This function always succeeds.
310function run(...) 310function run(...)
311 util.printout(cfg.export_lua_path:format(package.path)) 311 util.printout(cfg.export_lua_path:format(package.path))
312 util.printout(cfg.export_lua_cpath:format(package.path)) 312 util.printout(cfg.export_lua_cpath:format(package.cpath))
313 return true 313 return true
314end 314end
315 315