diff options
Diffstat (limited to 'src/luarocks/path.lua')
-rw-r--r-- | src/luarocks/path.lua | 29 |
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" |
25 | end | 25 | end |
26 | 26 | ||
27 | function path.root_dir(rocks_dir) | 27 | function 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) .. ".*$") |
30 | end | 30 | end |
31 | 31 | ||
32 | function path.deploy_bin_dir(tree) | 32 | function 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 |
39 | end | 39 | end |
40 | 40 | ||
41 | function path.deploy_bin_dir(tree) | ||
42 | return dir.path(path.root_dir(tree), "bin") | ||
43 | end | ||
44 | |||
41 | function path.manifest_file(tree) | 45 | function 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 | ||
48 | end | 47 | end |
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. |
55 | function path.versions_dir(name, tree) | 54 | function 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) |
59 | end | 57 | end |
60 | 58 | ||
@@ -67,7 +65,6 @@ end | |||
67 | function path.install_dir(name, version, tree) | 65 | function 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) |
72 | end | 69 | end |
73 | 70 | ||
@@ -80,7 +77,6 @@ end | |||
80 | function path.rockspec_file(name, version, tree) | 77 | function 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") |
85 | end | 81 | end |
86 | 82 | ||
@@ -93,7 +89,6 @@ end | |||
93 | function path.rock_manifest_file(name, version, tree) | 89 | function 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") |
98 | end | 93 | end |
99 | 94 | ||
@@ -106,7 +101,6 @@ end | |||
106 | function path.rock_namespace_file(name, version, tree) | 101 | function 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") |
111 | end | 105 | end |
112 | 106 | ||
@@ -119,7 +113,6 @@ end | |||
119 | function path.lib_dir(name, version, tree) | 113 | function 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") |
124 | end | 117 | end |
125 | 118 | ||
@@ -132,7 +125,6 @@ end | |||
132 | function path.lua_dir(name, version, tree) | 125 | function 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") |
137 | end | 129 | end |
138 | 130 | ||
@@ -145,7 +137,6 @@ end | |||
145 | function path.doc_dir(name, version, tree) | 137 | function 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") |
150 | end | 141 | end |
151 | 142 | ||
@@ -158,7 +149,6 @@ end | |||
158 | function path.conf_dir(name, version, tree) | 149 | function 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") |
163 | end | 153 | end |
164 | 154 | ||
@@ -172,7 +162,6 @@ end | |||
172 | function path.bin_dir(name, version, tree) | 162 | function 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") |
177 | end | 166 | end |
178 | 167 | ||