diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2018-04-20 13:13:18 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-05-07 19:27:37 -0300 |
commit | 4566c9bb20b8986d511c61c1f96bb2333e07bb1d (patch) | |
tree | 117c7307815dd52a1e986d81affc2c211824960e /src | |
parent | fdc51baae37c3232f6051db0e58ebefca8fdfdc7 (diff) | |
download | luarocks-4566c9bb20b8986d511c61c1f96bb2333e07bb1d.tar.gz luarocks-4566c9bb20b8986d511c61c1f96bb2333e07bb1d.tar.bz2 luarocks-4566c9bb20b8986d511c61c1f96bb2333e07bb1d.zip |
path: change signature of root_dir(), make things more consistent
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/core/path.lua | 8 | ||||
-rw-r--r-- | src/luarocks/pack.lua | 2 | ||||
-rw-r--r-- | src/luarocks/path.lua | 29 | ||||
-rw-r--r-- | src/luarocks/util.lua | 3 |
4 files changed, 16 insertions, 26 deletions
diff --git a/src/luarocks/core/path.lua b/src/luarocks/core/path.lua index 125500b7..adebaa23 100644 --- a/src/luarocks/core/path.lua +++ b/src/luarocks/core/path.lua | |||
@@ -8,12 +8,14 @@ local require = nil | |||
8 | -------------------------------------------------------------------------------- | 8 | -------------------------------------------------------------------------------- |
9 | 9 | ||
10 | function path.rocks_dir(tree) | 10 | function path.rocks_dir(tree) |
11 | if tree == nil then | ||
12 | tree = cfg.root_dir | ||
13 | end | ||
11 | if type(tree) == "string" then | 14 | if type(tree) == "string" then |
12 | return dir.path(tree, cfg.rocks_subdir) | 15 | return dir.path(tree, cfg.rocks_subdir) |
13 | else | ||
14 | assert(type(tree) == "table") | ||
15 | return tree.rocks_dir or dir.path(tree.root, cfg.rocks_subdir) | ||
16 | end | 16 | end |
17 | assert(type(tree) == "table") | ||
18 | return tree.rocks_dir or dir.path(tree.root, cfg.rocks_subdir) | ||
17 | end | 19 | end |
18 | 20 | ||
19 | --- Produce a versioned version of a filename. | 21 | --- Produce a versioned version of a filename. |
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index 60ba4caf..e0e94283 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua | |||
@@ -84,7 +84,7 @@ function pack.pack_installed_rock(query, tree) | |||
84 | return nil, version | 84 | return nil, version |
85 | end | 85 | end |
86 | 86 | ||
87 | local root = path.root_dir(repo_url) | 87 | local root = path.root_from_rocks_dir(repo_url) |
88 | local prefix = path.install_dir(name, version, root) | 88 | local prefix = path.install_dir(name, version, root) |
89 | if not fs.exists(prefix) then | 89 | if not fs.exists(prefix) then |
90 | return nil, "'"..name.." "..version.."' does not seem to be an installed rock." | 90 | return nil, "'"..name.." "..version.."' does not seem to be an installed rock." |
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 | ||
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 9731f034..f96f5c32 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -379,8 +379,7 @@ function util.announce_install(rockspec) | |||
379 | suffix = " (license: "..rockspec.description.license..")" | 379 | suffix = " (license: "..rockspec.description.license..")" |
380 | end | 380 | end |
381 | 381 | ||
382 | local root_dir = path.root_dir(cfg.rocks_dir) | 382 | util.printout(rockspec.name.." "..rockspec.version.." is now installed in "..path.root_dir(cfg.root_dir)..suffix) |
383 | util.printout(rockspec.name.." "..rockspec.version.." is now installed in "..root_dir..suffix) | ||
384 | util.printout() | 383 | util.printout() |
385 | end | 384 | end |
386 | 385 | ||