aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHisham <hisham@gobolinux.org>2016-10-19 12:43:41 -0400
committerHisham <hisham@gobolinux.org>2016-10-19 12:43:41 -0400
commit66a4d40893199fbee5eed5abd3c91aad0a3cce2b (patch)
tree804456ac2600b57c4bf79ddecc99858820c6053b /src
parent4958f45fc46ce9bf22a1487413c8290ae27b9082 (diff)
downloadluarocks-66a4d40893199fbee5eed5abd3c91aad0a3cce2b.tar.gz
luarocks-66a4d40893199fbee5eed5abd3c91aad0a3cce2b.tar.bz2
luarocks-66a4d40893199fbee5eed5abd3c91aad0a3cce2b.zip
Refactor error message and add extra checks.
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/manif.lua4
-rw-r--r--src/luarocks/manif/writer.lua6
-rw-r--r--src/luarocks/pack.lua6
-rw-r--r--src/luarocks/repos.lua17
4 files changed, 16 insertions, 17 deletions
diff --git a/src/luarocks/manif.lua b/src/luarocks/manif.lua
index 680b5cfe..bd6fd6ee 100644
--- a/src/luarocks/manif.lua
+++ b/src/luarocks/manif.lua
@@ -25,7 +25,9 @@ function manif.load_rock_manifest(name, version, root)
25 end 25 end
26 local pathname = path.rock_manifest_file(name, version, root) 26 local pathname = path.rock_manifest_file(name, version, root)
27 local rock_manifest = persist.load_into_table(pathname) 27 local rock_manifest = persist.load_into_table(pathname)
28 if not rock_manifest then return nil end 28 if not rock_manifest then
29 return nil, "rock_manifest file not found for "..name.." "..version.." - not a LuaRocks tree?"
30 end
29 manif.rock_manifest_cache[name_version] = rock_manifest 31 manif.rock_manifest_cache[name_version] = rock_manifest
30 return rock_manifest.rock_manifest 32 return rock_manifest.rock_manifest
31end 33end
diff --git a/src/luarocks/manif/writer.lua b/src/luarocks/manif/writer.lua
index 75ea3b81..1eb5ee7c 100644
--- a/src/luarocks/manif/writer.lua
+++ b/src/luarocks/manif/writer.lua
@@ -189,10 +189,8 @@ local function store_results(results, manifest, dep_handler)
189 local entrytable = {} 189 local entrytable = {}
190 entrytable.arch = entry.arch 190 entrytable.arch = entry.arch
191 if entry.arch == "installed" then 191 if entry.arch == "installed" then
192 local rock_manifest = manif.load_rock_manifest(name, version) 192 local rock_manifest, err = manif.load_rock_manifest(name, version)
193 if not rock_manifest then 193 if not rock_manifest then return nil, err end
194 return nil, "rock_manifest file not found for "..name.." "..version.." - not a LuaRocks 2 tree?"
195 end
196 entrytable.modules = store_package_items(repos.package_modules, name, version, manifest.modules) 194 entrytable.modules = store_package_items(repos.package_modules, name, version, manifest.modules)
197 entrytable.commands = store_package_items(repos.package_commands, name, version, manifest.commands) 195 entrytable.commands = store_package_items(repos.package_commands, name, version, manifest.commands)
198 end 196 end
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua
index 989d49ee..49c68e85 100644
--- a/src/luarocks/pack.lua
+++ b/src/luarocks/pack.lua
@@ -102,10 +102,8 @@ local function do_pack_binary_rock(name, version, tree)
102 return nil, "'"..name.." "..version.."' does not seem to be an installed rock." 102 return nil, "'"..name.." "..version.."' does not seem to be an installed rock."
103 end 103 end
104 104
105 local rock_manifest = manif.load_rock_manifest(name, version, root) 105 local rock_manifest, err = manif.load_rock_manifest(name, version, root)
106 if not rock_manifest then 106 if not rock_manifest then return nil, err end
107 return nil, "rock_manifest file not found for "..name.." "..version.." - not a LuaRocks 2 tree?"
108 end
109 107
110 local name_version = name .. "-" .. version 108 local name_version = name .. "-" .. version
111 local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock") 109 local rock_file = fs.absolute_name(name_version .. "."..cfg.arch..".rock")
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua
index f1d58da0..0ed9068c 100644
--- a/src/luarocks/repos.lua
+++ b/src/luarocks/repos.lua
@@ -78,6 +78,7 @@ function repos.package_modules(package, version)
78 78
79 local result = {} 79 local result = {}
80 local rock_manifest = manif.load_rock_manifest(package, version) 80 local rock_manifest = manif.load_rock_manifest(package, version)
81 if not rock_manifest then return result end
81 store_package_data(result, package, rock_manifest.lib) 82 store_package_data(result, package, rock_manifest.lib)
82 store_package_data(result, package, rock_manifest.lua) 83 store_package_data(result, package, rock_manifest.lua)
83 return result 84 return result
@@ -97,6 +98,7 @@ function repos.package_commands(package, version)
97 98
98 local result = {} 99 local result = {}
99 local rock_manifest = manif.load_rock_manifest(package, version) 100 local rock_manifest = manif.load_rock_manifest(package, version)
101 if not rock_manifest then return result end
100 store_package_data(result, package, rock_manifest.bin) 102 store_package_data(result, package, rock_manifest.bin)
101 return result 103 return result
102end 104end
@@ -112,7 +114,7 @@ function repos.has_binaries(name, version)
112 assert(type(version) == "string") 114 assert(type(version) == "string")
113 115
114 local rock_manifest = manif.load_rock_manifest(name, version) 116 local rock_manifest = manif.load_rock_manifest(name, version)
115 if rock_manifest.bin then 117 if rock_manifest and rock_manifest.bin then
116 for name, md5 in pairs(rock_manifest.bin) do 118 for name, md5 in pairs(rock_manifest.bin) do
117 -- TODO verify that it is the same file. If it isn't, find the actual command. 119 -- TODO verify that it is the same file. If it isn't, find the actual command.
118 if fs.is_actual_binary(dir.path(cfg.deploy_bin_dir, name)) then 120 if fs.is_actual_binary(dir.path(cfg.deploy_bin_dir, name)) then
@@ -196,7 +198,7 @@ function repos.deploy_files(name, version, wrap_bin_scripts)
196 198
197 local function deploy_file_tree(file_tree, path_fn, deploy_dir, move_fn) 199 local function deploy_file_tree(file_tree, path_fn, deploy_dir, move_fn)
198 local source_dir = path_fn(name, version) 200 local source_dir = path_fn(name, version)
199 return recurse_rock_manifest_tree(file_tree, 201 return recurse_rock_manifest_tree(file_tree,
200 function(parent_path, parent_module, file) 202 function(parent_path, parent_module, file)
201 local source = dir.path(source_dir, parent_path, file) 203 local source = dir.path(source_dir, parent_path, file)
202 local target = dir.path(deploy_dir, parent_path, file) 204 local target = dir.path(deploy_dir, parent_path, file)
@@ -226,7 +228,8 @@ function repos.deploy_files(name, version, wrap_bin_scripts)
226 ) 228 )
227 end 229 end
228 230
229 local rock_manifest = manif.load_rock_manifest(name, version) 231 local rock_manifest, err = manif.load_rock_manifest(name, version)
232 if not rock_manifest then return nil, err end
230 233
231 local ok, err = true 234 local ok, err = true
232 if rock_manifest.bin then 235 if rock_manifest.bin then
@@ -305,12 +308,10 @@ function repos.delete_version(name, version, deps_mode, quick)
305 ) 308 )
306 end 309 end
307 310
308 local rock_manifest = manif.load_rock_manifest(name, version) 311 local rock_manifest, err = manif.load_rock_manifest(name, version)
309 if not rock_manifest then 312 if not rock_manifest then return nil, err end
310 return nil, "rock_manifest file not found for "..name.." "..version.." - not a LuaRocks 2 tree?"
311 end
312 313
313 local ok, err = true 314 local ok = true
314 if rock_manifest.bin then 315 if rock_manifest.bin then
315 ok, err = delete_deployed_file_tree(rock_manifest.bin, cfg.deploy_bin_dir, cfg.wrapper_suffix) 316 ok, err = delete_deployed_file_tree(rock_manifest.bin, cfg.deploy_bin_dir, cfg.wrapper_suffix)
316 end 317 end