aboutsummaryrefslogtreecommitdiff
path: root/src/luarocks/install.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/luarocks/install.lua')
-rw-r--r--src/luarocks/install.lua24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/luarocks/install.lua b/src/luarocks/install.lua
index b115a8a8..3ef32c99 100644
--- a/src/luarocks/install.lua
+++ b/src/luarocks/install.lua
@@ -23,15 +23,17 @@ or a filename of a locally available rock.
23 23
24--- Install a binary rock. 24--- Install a binary rock.
25-- @param rock_file string: local or remote filename of a rock. 25-- @param rock_file string: local or remote filename of a rock.
26-- @return boolean or (nil, string): True if succeeded or 26-- @return boolean or (nil, string, [string]): True if succeeded or
27-- nil and an error message. 27-- nil and an error message and an optional error code.
28function install_binary_rock(rock_file) 28function install_binary_rock(rock_file)
29 assert(type(rock_file) == "string")
30
29 local name, version, arch = path.parse_rock_name(rock_file) 31 local name, version, arch = path.parse_rock_name(rock_file)
30 if not name then 32 if not name then
31 return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'." 33 return nil, "Filename "..rock_file.." does not match format 'name-version-revision.arch.rock'."
32 end 34 end
33 if arch ~= "all" and arch ~= cfg.arch then 35 if arch ~= "all" and arch ~= cfg.arch then
34 return nil, "Incompatible architecture "..arch 36 return nil, "Incompatible architecture "..arch, "arch"
35 end 37 end
36 if rep.is_installed(name, version) then 38 if rep.is_installed(name, version) then
37 rep.delete_version(name, version) 39 rep.delete_version(name, version)
@@ -40,23 +42,23 @@ function install_binary_rock(rock_file)
40 fs.delete(path.install_dir(name, version)) 42 fs.delete(path.install_dir(name, version))
41 fs.remove_dir_if_empty(path.versions_dir(name)) 43 fs.remove_dir_if_empty(path.versions_dir(name))
42 end) 44 end)
43 local ok, err = fetch.fetch_and_unpack_rock(rock_file, path.install_dir(name, version)) 45 local ok, err, errcode = fetch.fetch_and_unpack_rock(rock_file, path.install_dir(name, version))
44 if not ok then return nil, err end 46 if not ok then return nil, err, errcode end
45 ok, err = rep.install_bins(name, version) 47 ok, err = rep.install_bins(name, version)
46 48
47 local rockspec, err = fetch.load_rockspec(path.rockspec_file(name, version)) 49 local rockspec, err, errcode = fetch.load_rockspec(path.rockspec_file(name, version))
48 if err then 50 if err then
49 return nil, "Failed loading rockspec for installed package: "..err 51 return nil, "Failed loading rockspec for installed package: "..err, errcode
50 end 52 end
51 53
52 ok, err = deps.check_external_deps(rockspec, "install") 54 ok, err, errcode = deps.check_external_deps(rockspec, "install")
53 if err then 55 if err then
54 return nil, err 56 return nil, err, errcode
55 end 57 end
56 58
57 ok, err = deps.fulfill_dependencies(rockspec) 59 ok, err, errcode = deps.fulfill_dependencies(rockspec)
58 if err then 60 if err then
59 return nil, err 61 return nil, err, errcode
60 end 62 end
61 63
62 ok, err = rep.run_hook(rockspec, "post_install") 64 ok, err = rep.run_hook(rockspec, "post_install")