diff options
Diffstat (limited to 'src/luarocks/path.lua')
-rw-r--r-- | src/luarocks/path.lua | 84 |
1 files changed, 52 insertions, 32 deletions
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index c9085431..fccabc99 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -16,115 +16,135 @@ function rockspec_name_from_rock(rock_name) | |||
16 | return base_name:match("(.*)%.[^.]*.rock") .. ".rockspec" | 16 | return base_name:match("(.*)%.[^.]*.rock") .. ".rockspec" |
17 | end | 17 | end |
18 | 18 | ||
19 | function rocks_dir(repo) | ||
20 | return dir.path(repo, "lib", "luarocks", "rocks") | ||
21 | end | ||
22 | |||
23 | function scripts_dir(repo) | ||
24 | return dir.path(repo, "bin") | ||
25 | end | ||
26 | |||
27 | function lua_modules_dir(repo) | ||
28 | return dir.path(repo, "share", "lua", "5.1") | ||
29 | end | ||
30 | |||
31 | function bin_modules_dir(repo) | ||
32 | return dir.path(repo, "lib", "lua", "5.1") | ||
33 | end | ||
34 | |||
35 | function manifest_file(repo) | ||
36 | return dir.path(repo, "lib", "luarocks", "rocks", "manifest") | ||
37 | end | ||
38 | |||
19 | --- Get the repository directory for all versions of a package. | 39 | --- Get the repository directory for all versions of a package. |
20 | -- @param name string: The package name. | 40 | -- @param name string: The package name. |
21 | -- @return string: The resulting path -- does not guarantee that | 41 | -- @return string: The resulting path -- does not guarantee that |
22 | -- @param repo string or nil: If given, specifies the local repository to use. | 42 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
23 | -- the package (and by extension, the path) exists. | 43 | -- the package (and by extension, the path) exists. |
24 | function versions_dir(name, repo) | 44 | function versions_dir(name, rocks_dir) |
25 | assert(type(name) == "string") | 45 | assert(type(name) == "string") |
26 | assert(not repo or type(repo) == "string") | 46 | assert(not rocks_dir or type(rocks_dir) == "string") |
27 | 47 | ||
28 | return dir.path(repo or cfg.rocks_dir, name) | 48 | return dir.path(rocks_dir or cfg.rocks_dir, name) |
29 | end | 49 | end |
30 | 50 | ||
31 | --- Get the local installation directory (prefix) for a package. | 51 | --- Get the local installation directory (prefix) for a package. |
32 | -- @param name string: The package name. | 52 | -- @param name string: The package name. |
33 | -- @param version string: The package version. | 53 | -- @param version string: The package version. |
34 | -- @param repo string or nil: If given, specifies the local repository to use. | 54 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
35 | -- @return string: The resulting path -- does not guarantee that | 55 | -- @return string: The resulting path -- does not guarantee that |
36 | -- the package (and by extension, the path) exists. | 56 | -- the package (and by extension, the path) exists. |
37 | function install_dir(name, version, repo) | 57 | function install_dir(name, version, rocks_dir) |
38 | assert(type(name) == "string") | 58 | assert(type(name) == "string") |
39 | assert(type(version) == "string") | 59 | assert(type(version) == "string") |
40 | assert(not repo or type(repo) == "string") | 60 | assert(not rocks_dir or type(rocks_dir) == "string") |
41 | 61 | ||
42 | return dir.path(repo or cfg.rocks_dir, name, version) | 62 | return dir.path(rocks_dir or cfg.rocks_dir, name, version) |
43 | end | 63 | end |
44 | 64 | ||
45 | --- Get the local filename of the rockspec of an installed rock. | 65 | --- Get the local filename of the rockspec of an installed rock. |
46 | -- @param name string: The package name. | 66 | -- @param name string: The package name. |
47 | -- @param version string: The package version. | 67 | -- @param version string: The package version. |
48 | -- @param repo string or nil: If given, specifies the local repository to use. | 68 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
49 | -- @return string: The resulting path -- does not guarantee that | 69 | -- @return string: The resulting path -- does not guarantee that |
50 | -- the package (and by extension, the file) exists. | 70 | -- the package (and by extension, the file) exists. |
51 | function rockspec_file(name, version, repo) | 71 | function rockspec_file(name, version, rocks_dir) |
52 | assert(type(name) == "string") | 72 | assert(type(name) == "string") |
53 | assert(type(version) == "string") | 73 | assert(type(version) == "string") |
54 | assert(not repo or type(repo) == "string") | 74 | assert(not rocks_dir or type(rocks_dir) == "string") |
55 | 75 | ||
56 | return dir.path(repo or cfg.rocks_dir, name, version, name.."-"..version..".rockspec") | 76 | return dir.path(rocks_dir or cfg.rocks_dir, name, version, name.."-"..version..".rockspec") |
57 | end | 77 | end |
58 | 78 | ||
59 | --- Get the local installation directory for C libraries of a package. | 79 | --- Get the local installation directory for C libraries of a package. |
60 | -- @param name string: The package name. | 80 | -- @param name string: The package name. |
61 | -- @param version string: The package version. | 81 | -- @param version string: The package version. |
62 | -- @param repo string or nil: If given, specifies the local repository to use. | 82 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
63 | -- @return string: The resulting path -- does not guarantee that | 83 | -- @return string: The resulting path -- does not guarantee that |
64 | -- the package (and by extension, the path) exists. | 84 | -- the package (and by extension, the path) exists. |
65 | function lib_dir(name, version, repo) | 85 | function lib_dir(name, version, rocks_dir) |
66 | assert(type(name) == "string") | 86 | assert(type(name) == "string") |
67 | assert(type(version) == "string") | 87 | assert(type(version) == "string") |
68 | assert(not repo or type(repo) == "string") | 88 | assert(not rocks_dir or type(rocks_dir) == "string") |
69 | 89 | ||
70 | return dir.path(repo or cfg.rocks_dir, name, version, "lib") | 90 | return dir.path(rocks_dir or cfg.rocks_dir, name, version, "lib") |
71 | end | 91 | end |
72 | 92 | ||
73 | --- Get the local installation directory for Lua modules of a package. | 93 | --- Get the local installation directory for Lua modules of a package. |
74 | -- @param name string: The package name. | 94 | -- @param name string: The package name. |
75 | -- @param version string: The package version. | 95 | -- @param version string: The package version. |
76 | -- @param repo string or nil: If given, specifies the local repository to use. | 96 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
77 | -- @return string: The resulting path -- does not guarantee that | 97 | -- @return string: The resulting path -- does not guarantee that |
78 | -- the package (and by extension, the path) exists. | 98 | -- the package (and by extension, the path) exists. |
79 | function lua_dir(name, version, repo) | 99 | function lua_dir(name, version, rocks_dir) |
80 | assert(type(name) == "string") | 100 | assert(type(name) == "string") |
81 | assert(type(version) == "string") | 101 | assert(type(version) == "string") |
82 | assert(not repo or type(repo) == "string") | 102 | assert(not rocks_dir or type(rocks_dir) == "string") |
83 | 103 | ||
84 | return dir.path(repo or cfg.rocks_dir, name, version, "lua") | 104 | return dir.path(rocks_dir or cfg.rocks_dir, name, version, "lua") |
85 | end | 105 | end |
86 | 106 | ||
87 | --- Get the local installation directory for documentation of a package. | 107 | --- Get the local installation directory for documentation of a package. |
88 | -- @param name string: The package name. | 108 | -- @param name string: The package name. |
89 | -- @param version string: The package version. | 109 | -- @param version string: The package version. |
90 | -- @param repo string or nil: If given, specifies the local repository to use. | 110 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
91 | -- @return string: The resulting path -- does not guarantee that | 111 | -- @return string: The resulting path -- does not guarantee that |
92 | -- the package (and by extension, the path) exists. | 112 | -- the package (and by extension, the path) exists. |
93 | function doc_dir(name, version, repo) | 113 | function doc_dir(name, version, rocks_dir) |
94 | assert(type(name) == "string") | 114 | assert(type(name) == "string") |
95 | assert(type(version) == "string") | 115 | assert(type(version) == "string") |
96 | assert(not repo or type(repo) == "string") | 116 | assert(not rocks_dir or type(rocks_dir) == "string") |
97 | 117 | ||
98 | return dir.path(repo or cfg.rocks_dir, name, version, "doc") | 118 | return dir.path(rocks_dir or cfg.rocks_dir, name, version, "doc") |
99 | end | 119 | end |
100 | 120 | ||
101 | --- Get the local installation directory for configuration files of a package. | 121 | --- Get the local installation directory for configuration files of a package. |
102 | -- @param name string: The package name. | 122 | -- @param name string: The package name. |
103 | -- @param version string: The package version. | 123 | -- @param version string: The package version. |
104 | -- @param repo string or nil: If given, specifies the local repository to use. | 124 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
105 | -- @return string: The resulting path -- does not guarantee that | 125 | -- @return string: The resulting path -- does not guarantee that |
106 | -- the package (and by extension, the path) exists. | 126 | -- the package (and by extension, the path) exists. |
107 | function conf_dir(name, version, repo) | 127 | function conf_dir(name, version, rocks_dir) |
108 | assert(type(name) == "string") | 128 | assert(type(name) == "string") |
109 | assert(type(version) == "string") | 129 | assert(type(version) == "string") |
110 | assert(not repo or type(repo) == "string") | 130 | assert(not rocks_dir or type(rocks_dir) == "string") |
111 | 131 | ||
112 | return dir.path(repo or cfg.rocks_dir, name, version, "conf") | 132 | return dir.path(rocks_dir or cfg.rocks_dir, name, version, "conf") |
113 | end | 133 | end |
114 | 134 | ||
115 | --- Get the local installation directory for command-line scripts | 135 | --- Get the local installation directory for command-line scripts |
116 | -- of a package. | 136 | -- of a package. |
117 | -- @param name string: The package name. | 137 | -- @param name string: The package name. |
118 | -- @param version string: The package version. | 138 | -- @param version string: The package version. |
119 | -- @param repo string or nil: If given, specifies the local repository to use. | 139 | -- @param rocks_dir string or nil: If given, specifies the local repository to use. |
120 | -- @return string: The resulting path -- does not guarantee that | 140 | -- @return string: The resulting path -- does not guarantee that |
121 | -- the package (and by extension, the path) exists. | 141 | -- the package (and by extension, the path) exists. |
122 | function bin_dir(name, version, repo) | 142 | function bin_dir(name, version, rocks_dir) |
123 | assert(type(name) == "string") | 143 | assert(type(name) == "string") |
124 | assert(type(version) == "string") | 144 | assert(type(version) == "string") |
125 | assert(not repo or type(repo) == "string") | 145 | assert(not rocks_dir or type(rocks_dir) == "string") |
126 | 146 | ||
127 | return dir.path(repo or cfg.rocks_dir, name, version, "bin") | 147 | return dir.path(rocks_dir or cfg.rocks_dir, name, version, "bin") |
128 | end | 148 | end |
129 | 149 | ||
130 | --- Extract name, version and arch of a rock filename. | 150 | --- Extract name, version and arch of a rock filename. |