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.lua29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua
index 4babcb30..a8426090 100644
--- a/src/luarocks/path.lua
+++ b/src/luarocks/path.lua
@@ -24,27 +24,26 @@ function path.rockspec_name_from_rock(rock_name)
24 return base_name:match("(.*)%.[^.]*.rock") .. ".rockspec" 24 return base_name:match("(.*)%.[^.]*.rock") .. ".rockspec"
25end 25end
26 26
27function path.root_dir(rocks_dir) 27function path.root_from_rocks_dir(rocks_dir)
28 assert(type(rocks_dir) == "string") 28 assert(type(rocks_dir) == "string")
29 return rocks_dir:match("(.*)" .. util.matchquote(cfg.rocks_subdir) .. ".*$") 29 return rocks_dir:match("(.*)" .. util.matchquote(cfg.rocks_subdir) .. ".*$")
30end 30end
31 31
32function path.deploy_bin_dir(tree) 32function path.root_dir(tree)
33 if type(tree) == "string" then 33 if type(tree) == "string" then
34 return dir.path(tree, "bin") 34 return tree
35 else 35 else
36 assert(type(tree) == "table") 36 assert(type(tree) == "table")
37 return tree.bin_dir or dir.path(tree.root, "bin") 37 return tree.root
38 end 38 end
39end 39end
40 40
41function path.deploy_bin_dir(tree)
42 return dir.path(path.root_dir(tree), "bin")
43end
44
41function path.manifest_file(tree) 45function path.manifest_file(tree)
42 if type(tree) == "string" then 46 return dir.path(path.rocks_dir(tree), "manifest")
43 return dir.path(tree, cfg.rocks_subdir, "manifest")
44 else
45 assert(type(tree) == "table")
46 return (tree.rocks_dir and dir.path(tree.rocks_dir, "manifest")) or dir.path(tree.root, cfg.rocks_subdir, "manifest")
47 end
48end 47end
49 48
50--- Get the directory for all versions of a package in a tree. 49--- Get the directory for all versions of a package in a tree.
@@ -54,7 +53,6 @@ end
54-- the package (and by extension, the path) exists. 53-- the package (and by extension, the path) exists.
55function path.versions_dir(name, tree) 54function path.versions_dir(name, tree)
56 assert(type(name) == "string" and not name:match("/")) 55 assert(type(name) == "string" and not name:match("/"))
57 tree = tree or cfg.root_dir
58 return dir.path(path.rocks_dir(tree), name) 56 return dir.path(path.rocks_dir(tree), name)
59end 57end
60 58
@@ -67,7 +65,6 @@ end
67function path.install_dir(name, version, tree) 65function path.install_dir(name, version, tree)
68 assert(type(name) == "string" and not name:match("/")) 66 assert(type(name) == "string" and not name:match("/"))
69 assert(type(version) == "string") 67 assert(type(version) == "string")
70 tree = tree or cfg.root_dir
71 return dir.path(path.rocks_dir(tree), name, version) 68 return dir.path(path.rocks_dir(tree), name, version)
72end 69end
73 70
@@ -80,7 +77,6 @@ end
80function path.rockspec_file(name, version, tree) 77function path.rockspec_file(name, version, tree)
81 assert(type(name) == "string" and not name:match("/")) 78 assert(type(name) == "string" and not name:match("/"))
82 assert(type(version) == "string") 79 assert(type(version) == "string")
83 tree = tree or cfg.root_dir
84 return dir.path(path.rocks_dir(tree), name, version, name.."-"..version..".rockspec") 80 return dir.path(path.rocks_dir(tree), name, version, name.."-"..version..".rockspec")
85end 81end
86 82
@@ -93,7 +89,6 @@ end
93function path.rock_manifest_file(name, version, tree) 89function path.rock_manifest_file(name, version, tree)
94 assert(type(name) == "string" and not name:match("/")) 90 assert(type(name) == "string" and not name:match("/"))
95 assert(type(version) == "string") 91 assert(type(version) == "string")
96 tree = tree or cfg.root_dir
97 return dir.path(path.rocks_dir(tree), name, version, "rock_manifest") 92 return dir.path(path.rocks_dir(tree), name, version, "rock_manifest")
98end 93end
99 94
@@ -106,7 +101,6 @@ end
106function path.rock_namespace_file(name, version, tree) 101function path.rock_namespace_file(name, version, tree)
107 assert(type(name) == "string" and not name:match("/")) 102 assert(type(name) == "string" and not name:match("/"))
108 assert(type(version) == "string") 103 assert(type(version) == "string")
109 tree = tree or cfg.root_dir
110 return dir.path(path.rocks_dir(tree), name, version, "rock_namespace") 104 return dir.path(path.rocks_dir(tree), name, version, "rock_namespace")
111end 105end
112 106
@@ -119,7 +113,6 @@ end
119function path.lib_dir(name, version, tree) 113function path.lib_dir(name, version, tree)
120 assert(type(name) == "string" and not name:match("/")) 114 assert(type(name) == "string" and not name:match("/"))
121 assert(type(version) == "string") 115 assert(type(version) == "string")
122 tree = tree or cfg.root_dir
123 return dir.path(path.rocks_dir(tree), name, version, "lib") 116 return dir.path(path.rocks_dir(tree), name, version, "lib")
124end 117end
125 118
@@ -132,7 +125,6 @@ end
132function path.lua_dir(name, version, tree) 125function path.lua_dir(name, version, tree)
133 assert(type(name) == "string" and not name:match("/")) 126 assert(type(name) == "string" and not name:match("/"))
134 assert(type(version) == "string") 127 assert(type(version) == "string")
135 tree = tree or cfg.root_dir
136 return dir.path(path.rocks_dir(tree), name, version, "lua") 128 return dir.path(path.rocks_dir(tree), name, version, "lua")
137end 129end
138 130
@@ -145,7 +137,6 @@ end
145function path.doc_dir(name, version, tree) 137function path.doc_dir(name, version, tree)
146 assert(type(name) == "string" and not name:match("/")) 138 assert(type(name) == "string" and not name:match("/"))
147 assert(type(version) == "string") 139 assert(type(version) == "string")
148 tree = tree or cfg.root_dir
149 return dir.path(path.rocks_dir(tree), name, version, "doc") 140 return dir.path(path.rocks_dir(tree), name, version, "doc")
150end 141end
151 142
@@ -158,7 +149,6 @@ end
158function path.conf_dir(name, version, tree) 149function path.conf_dir(name, version, tree)
159 assert(type(name) == "string" and not name:match("/")) 150 assert(type(name) == "string" and not name:match("/"))
160 assert(type(version) == "string") 151 assert(type(version) == "string")
161 tree = tree or cfg.root_dir
162 return dir.path(path.rocks_dir(tree), name, version, "conf") 152 return dir.path(path.rocks_dir(tree), name, version, "conf")
163end 153end
164 154
@@ -172,7 +162,6 @@ end
172function path.bin_dir(name, version, tree) 162function path.bin_dir(name, version, tree)
173 assert(type(name) == "string" and not name:match("/")) 163 assert(type(name) == "string" and not name:match("/"))
174 assert(type(version) == "string") 164 assert(type(version) == "string")
175 tree = tree or cfg.root_dir
176 return dir.path(path.rocks_dir(tree), name, version, "bin") 165 return dir.path(path.rocks_dir(tree), name, version, "bin")
177end 166end
178 167