aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2018-04-20 13:13:18 -0300
committerHisham Muhammad <hisham@gobolinux.org>2018-05-07 19:27:37 -0300
commit4566c9bb20b8986d511c61c1f96bb2333e07bb1d (patch)
tree117c7307815dd52a1e986d81affc2c211824960e
parentfdc51baae37c3232f6051db0e58ebefca8fdfdc7 (diff)
downloadluarocks-4566c9bb20b8986d511c61c1f96bb2333e07bb1d.tar.gz
luarocks-4566c9bb20b8986d511c61c1f96bb2333e07bb1d.tar.bz2
luarocks-4566c9bb20b8986d511c61c1f96bb2333e07bb1d.zip
path: change signature of root_dir(), make things more consistent
-rw-r--r--src/luarocks/core/path.lua8
-rw-r--r--src/luarocks/pack.lua2
-rw-r--r--src/luarocks/path.lua29
-rw-r--r--src/luarocks/util.lua3
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
10function path.rocks_dir(tree) 10function 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)
17end 19end
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"
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
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()
385end 384end
386 385