diff options
Diffstat (limited to 'src/luarocks/install.lua')
-rw-r--r-- | src/luarocks/install.lua | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index 68b7c125..7678c0cc 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua | |||
@@ -1,6 +1,8 @@ | |||
1 | --- Module implementing the LuaRocks "install" command. | 1 | --- Module implementing the LuaRocks "install" command. |
2 | -- Installs binary rocks. | 2 | -- Installs binary rocks. |
3 | module("luarocks.install", package.seeall) | 3 | --module("luarocks.install", package.seeall) |
4 | local install = {} | ||
5 | package.loaded["luarocks.install"] = install | ||
4 | 6 | ||
5 | local path = require("luarocks.path") | 7 | local path = require("luarocks.path") |
6 | local repos = require("luarocks.repos") | 8 | local repos = require("luarocks.repos") |
@@ -12,11 +14,11 @@ local manif = require("luarocks.manif") | |||
12 | local remove = require("luarocks.remove") | 14 | local remove = require("luarocks.remove") |
13 | local cfg = require("luarocks.cfg") | 15 | local cfg = require("luarocks.cfg") |
14 | 16 | ||
15 | help_summary = "Install a rock." | 17 | install.help_summary = "Install a rock." |
16 | 18 | ||
17 | help_arguments = "{<rock>|<name> [<version>]}" | 19 | install.help_arguments = "{<rock>|<name> [<version>]}" |
18 | 20 | ||
19 | help = [[ | 21 | install.help = [[ |
20 | Argument may be the name of a rock to be fetched from a repository | 22 | Argument may be the name of a rock to be fetched from a repository |
21 | or a filename of a locally available rock. | 23 | or a filename of a locally available rock. |
22 | 24 | ||
@@ -34,7 +36,7 @@ or a filename of a locally available rock. | |||
34 | -- "order" for all trees with priority >= the current default, "none" for no trees. | 36 | -- "order" for all trees with priority >= the current default, "none" for no trees. |
35 | -- @return (string, string) or (nil, string, [string]): Name and version of | 37 | -- @return (string, string) or (nil, string, [string]): Name and version of |
36 | -- installed rock if succeeded or nil and an error message followed by an error code. | 38 | -- installed rock if succeeded or nil and an error message followed by an error code. |
37 | function install_binary_rock(rock_file, deps_mode) | 39 | function install.install_binary_rock(rock_file, deps_mode) |
38 | assert(type(rock_file) == "string") | 40 | assert(type(rock_file) == "string") |
39 | 41 | ||
40 | local name, version, arch = path.parse_name(rock_file) | 42 | local name, version, arch = path.parse_name(rock_file) |
@@ -117,7 +119,7 @@ end | |||
117 | -- may also be given. | 119 | -- may also be given. |
118 | -- @return boolean or (nil, string, exitcode): True if installation was | 120 | -- @return boolean or (nil, string, exitcode): True if installation was |
119 | -- successful, nil and an error message otherwise. exitcode is optionally returned. | 121 | -- successful, nil and an error message otherwise. exitcode is optionally returned. |
120 | function run(...) | 122 | function install.run(...) |
121 | local flags, name, version = util.parse_flags(...) | 123 | local flags, name, version = util.parse_flags(...) |
122 | if type(name) ~= "string" then | 124 | if type(name) ~= "string" then |
123 | return nil, "Argument missing. "..util.see_help("install") | 125 | return nil, "Argument missing. "..util.see_help("install") |
@@ -131,7 +133,7 @@ function run(...) | |||
131 | local build = require("luarocks.build") | 133 | local build = require("luarocks.build") |
132 | return build.run(name, util.forward_flags(flags, "local", "keep", "deps-mode")) | 134 | return build.run(name, util.forward_flags(flags, "local", "keep", "deps-mode")) |
133 | elseif name:match("%.rock$") then | 135 | elseif name:match("%.rock$") then |
134 | ok, err = install_binary_rock(name, deps.get_deps_mode(flags)) | 136 | ok, err = install.install_binary_rock(name, deps.get_deps_mode(flags)) |
135 | if not ok then return nil, err end | 137 | if not ok then return nil, err end |
136 | local name, version = ok, err | 138 | local name, version = ok, err |
137 | if (not flags["keep"]) and not cfg.keep_other_versions then | 139 | if (not flags["keep"]) and not cfg.keep_other_versions then |
@@ -147,7 +149,7 @@ function run(...) | |||
147 | elseif type(results) == "string" then | 149 | elseif type(results) == "string" then |
148 | local url = results | 150 | local url = results |
149 | util.printout("Installing "..url.."...") | 151 | util.printout("Installing "..url.."...") |
150 | return run(url, util.forward_flags(flags)) | 152 | return install.run(url, util.forward_flags(flags)) |
151 | else | 153 | else |
152 | util.printout() | 154 | util.printout() |
153 | util.printerr("Could not determine which rock to install.") | 155 | util.printerr("Could not determine which rock to install.") |
@@ -157,3 +159,5 @@ function run(...) | |||
157 | end | 159 | end |
158 | end | 160 | end |
159 | end | 161 | end |
162 | |||
163 | return install | ||