diff options
Diffstat (limited to 'src/luarocks/install.lua')
-rw-r--r-- | src/luarocks/install.lua | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua index c938aa9f..acbf584a 100644 --- a/src/luarocks/install.lua +++ b/src/luarocks/install.lua | |||
@@ -1,6 +1,5 @@ | |||
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) | ||
4 | local install = {} | 3 | local install = {} |
5 | package.loaded["luarocks.install"] = install | 4 | package.loaded["luarocks.install"] = install |
6 | 5 | ||
@@ -14,6 +13,7 @@ local manif = require("luarocks.manif") | |||
14 | local remove = require("luarocks.remove") | 13 | local remove = require("luarocks.remove") |
15 | local cfg = require("luarocks.cfg") | 14 | local cfg = require("luarocks.cfg") |
16 | 15 | ||
16 | util.add_run_function(install) | ||
17 | install.help_summary = "Install a rock." | 17 | install.help_summary = "Install a rock." |
18 | 18 | ||
19 | install.help_arguments = "{<rock>|<name> [<version>]}" | 19 | install.help_arguments = "{<rock>|<name> [<version>]}" |
@@ -98,15 +98,7 @@ function install.install_binary_rock(rock_file, deps_mode) | |||
98 | ok, err = manif.update_manifest(name, version, nil, deps_mode) | 98 | ok, err = manif.update_manifest(name, version, nil, deps_mode) |
99 | if err then return nil, err end | 99 | if err then return nil, err end |
100 | 100 | ||
101 | local license = "" | 101 | util.announce_install(rockspec) |
102 | if rockspec.description.license then | ||
103 | license = ("(license: "..rockspec.description.license..")") | ||
104 | end | ||
105 | |||
106 | local root_dir = path.root_dir(cfg.rocks_dir) | ||
107 | util.printout() | ||
108 | util.printout(name.." "..version.." is now installed in "..root_dir.." "..license) | ||
109 | |||
110 | util.remove_scheduled_function(rollback) | 102 | util.remove_scheduled_function(rollback) |
111 | return name, version | 103 | return name, version |
112 | end | 104 | end |
@@ -143,7 +135,7 @@ function install.install_binary_rock_deps(rock_file, deps_mode) | |||
143 | if err then return nil, err, errcode end | 135 | if err then return nil, err, errcode end |
144 | 136 | ||
145 | util.printout() | 137 | util.printout() |
146 | util.printout("Succesfully installed dependencies for " ..name.." "..version) | 138 | util.printout("Successfully installed dependencies for " ..name.." "..version) |
147 | 139 | ||
148 | return name, version | 140 | return name, version |
149 | end | 141 | end |
@@ -158,8 +150,7 @@ end | |||
158 | -- may also be given. | 150 | -- may also be given. |
159 | -- @return boolean or (nil, string, exitcode): True if installation was | 151 | -- @return boolean or (nil, string, exitcode): True if installation was |
160 | -- successful, nil and an error message otherwise. exitcode is optionally returned. | 152 | -- successful, nil and an error message otherwise. exitcode is optionally returned. |
161 | function install.run(...) | 153 | function install.command(flags, name, version) |
162 | local flags, name, version = util.parse_flags(...) | ||
163 | if type(name) ~= "string" then | 154 | if type(name) ~= "string" then |
164 | return nil, "Argument missing. "..util.see_help("install") | 155 | return nil, "Argument missing. "..util.see_help("install") |
165 | end | 156 | end |
@@ -168,9 +159,8 @@ function install.run(...) | |||
168 | if not ok then return nil, err, cfg.errorcodes.PERMISSIONDENIED end | 159 | if not ok then return nil, err, cfg.errorcodes.PERMISSIONDENIED end |
169 | 160 | ||
170 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then | 161 | if name:match("%.rockspec$") or name:match("%.src%.rock$") then |
171 | util.printout("Using "..name.."... switching to 'build' mode") | ||
172 | local build = require("luarocks.build") | 162 | local build = require("luarocks.build") |
173 | return build.run(name, util.forward_flags(flags, "local", "keep", "deps-mode", "only-deps")) | 163 | return build.command(flags, name) |
174 | elseif name:match("%.rock$") then | 164 | elseif name:match("%.rock$") then |
175 | if flags["only-deps"] then | 165 | if flags["only-deps"] then |
176 | ok, err = install.install_binary_rock_deps(name, deps.get_deps_mode(flags)) | 166 | ok, err = install.install_binary_rock_deps(name, deps.get_deps_mode(flags)) |
@@ -180,7 +170,7 @@ function install.run(...) | |||
180 | if not ok then return nil, err end | 170 | if not ok then return nil, err end |
181 | local name, version = ok, err | 171 | local name, version = ok, err |
182 | if (not flags["only-deps"]) and (not flags["keep"]) and not cfg.keep_other_versions then | 172 | if (not flags["only-deps"]) and (not flags["keep"]) and not cfg.keep_other_versions then |
183 | local ok, err = remove.remove_other_versions(name, version, flags["force"]) | 173 | local ok, err = remove.remove_other_versions(name, version, flags["force"], flags["force-fast"]) |
184 | if not ok then util.printerr(err) end | 174 | if not ok then util.printerr(err) end |
185 | end | 175 | end |
186 | return name, version | 176 | return name, version |
@@ -190,8 +180,8 @@ function install.run(...) | |||
190 | if not url then | 180 | if not url then |
191 | return nil, err | 181 | return nil, err |
192 | end | 182 | end |
193 | util.printout("Installing "..url.."...") | 183 | util.printout("Installing "..url) |
194 | return install.run(url, util.forward_flags(flags)) | 184 | return install.command(flags, url) |
195 | end | 185 | end |
196 | end | 186 | end |
197 | 187 | ||