aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/path.lua67
1 files changed, 37 insertions, 30 deletions
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua
index 05e04b43..d07c244e 100644
--- a/src/luarocks/path.lua
+++ b/src/luarocks/path.lua
@@ -17,48 +17,55 @@ function rockspec_name_from_rock(rock_name)
17end 17end
18 18
19function rocks_dir(repo) 19function rocks_dir(repo)
20 if type(repo) == "string" then 20 if type(repo) == "string" then
21 return dir.path(repo, "lib", "luarocks", "rocks") 21 return dir.path(repo, "lib", "luarocks", "rocks")
22 else 22 else
23 assert(type(repo) == "table") 23 assert(type(repo) == "table")
24 return repo.rocks_dir or dir.path(repo.root, "lib", "luarocks", "rocks") 24 return repo.rocks_dir or dir.path(repo.root, "lib", "luarocks", "rocks")
25 end 25 end
26end
27
28function root_dir(rocks_dir)
29 assert(type(rocks_dir) == "string")
30
31 local suffix = dir.path("lib", "luarocks", "rocks")
32 return rocks_dir:match("(.*)" .. suffix .. "$")
26end 33end
27 34
28function deploy_bin_dir(repo) 35function deploy_bin_dir(repo)
29 if type(repo) == "string" then 36 if type(repo) == "string" then
30 return dir.path(repo, "bin") 37 return dir.path(repo, "bin")
31 else 38 else
32 assert(type(repo) == "table") 39 assert(type(repo) == "table")
33 return repo.bin_dir or dir.path(repo.root, "bin") 40 return repo.bin_dir or dir.path(repo.root, "bin")
34 end 41 end
35end 42end
36 43
37function deploy_lua_dir(repo) 44function deploy_lua_dir(repo)
38 if type(repo) == "string" then 45 if type(repo) == "string" then
39 return dir.path(repo, "share", "lua", "5.1") 46 return dir.path(repo, "share", "lua", "5.1")
40 else 47 else
41 assert(type(repo) == "table") 48 assert(type(repo) == "table")
42 return repo.lua_dir or dir.path(repo.root, "share", "lua", "5.1") 49 return repo.lua_dir or dir.path(repo.root, "share", "lua", "5.1")
43 end 50 end
44end 51end
45 52
46function deploy_lib_dir(repo) 53function deploy_lib_dir(repo)
47 if type(repo) == "string" then 54 if type(repo) == "string" then
48 return dir.path(repo, "lib", "lua", "5.1") 55 return dir.path(repo, "lib", "lua", "5.1")
49 else 56 else
50 assert(type(repo) == "table") 57 assert(type(repo) == "table")
51 return repo.lib_dir or dir.path(repo.root, "lib", "lua", "5.1") 58 return repo.lib_dir or dir.path(repo.root, "lib", "lua", "5.1")
52 end 59 end
53end 60end
54 61
55function manifest_file(repo) 62function manifest_file(repo)
56 if type(repo) == "string" then 63 if type(repo) == "string" then
57 return dir.path(repo, "lib", "luarocks", "rocks", "manifest") 64 return dir.path(repo, "lib", "luarocks", "rocks", "manifest")
58 else 65 else
59 assert(type(repo) == "table") 66 assert(type(repo) == "table")
60 return (repo.rocks_dir and dir.path(repo.rocks_dir, "manifest")) or dir.path(repo.root, "lib", "luarocks", "rocks", "manifest") 67 return (repo.rocks_dir and dir.path(repo.rocks_dir, "manifest")) or dir.path(repo.root, "lib", "luarocks", "rocks", "manifest")
61 end 68 end
62end 69end
63 70
64--- Get the repository directory for all versions of a package. 71--- Get the repository directory for all versions of a package.