diff options
-rw-r--r-- | src/luarocks/path.lua | 67 |
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) | |||
17 | end | 17 | end |
18 | 18 | ||
19 | function rocks_dir(repo) | 19 | function 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 |
26 | end | ||
27 | |||
28 | function 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 .. "$") | ||
26 | end | 33 | end |
27 | 34 | ||
28 | function deploy_bin_dir(repo) | 35 | function 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 |
35 | end | 42 | end |
36 | 43 | ||
37 | function deploy_lua_dir(repo) | 44 | function 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 |
44 | end | 51 | end |
45 | 52 | ||
46 | function deploy_lib_dir(repo) | 53 | function 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 |
53 | end | 60 | end |
54 | 61 | ||
55 | function manifest_file(repo) | 62 | function 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 |
62 | end | 69 | end |
63 | 70 | ||
64 | --- Get the repository directory for all versions of a package. | 71 | --- Get the repository directory for all versions of a package. |