From: Tobias Ulmer Date: Wed, 12 Feb 2014 14:35:18 +0000 (+0100) Subject: Allow returning error from e2tool.dlist() X-Git-Tag: e2factory-2.3.15rc1~217 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=873729b7bd298cf355f60b3c6838fa8e4c195e7f;p=e2factory.git Allow returning error from e2tool.dlist() Signed-off-by: Tobias Ulmer --- diff --git a/local/e2-ls-project.lua b/local/e2-ls-project.lua index 5bbd107..1a1c1dc 100644 --- a/local/e2-ls-project.lua +++ b/local/e2-ls-project.lua @@ -171,7 +171,10 @@ local function e2_ls_project(arg) console.infof("digraph \"%s\" {\n", info.project.name) for _, r in pairs(results) do local res = info.results[r] - local deps = e2tool.dlist(info, r) + local deps, re = e2tool.dlist(info, r) + if not deps then + error(re) + end if #deps > 0 then for _, dep in pairs(deps) do if opts.swap then diff --git a/local/e2build.lua b/local/e2build.lua index 7871f91..aca1226 100644 --- a/local/e2build.lua +++ b/local/e2build.lua @@ -819,7 +819,10 @@ local function sources(info, r, return_flags) local rc, re local e = err.new("installing build time dependencies") local deps - deps = e2tool.dlist(info, r) + deps, re = e2tool.dlist(info, r) + if not deps then + return false, e:cat(re) + end for i, dep in pairs(deps) do local destdir = e2lib.join(res.build_config.T, "dep", dep) rc, re = e2build.unpack_result(info, r, dep, destdir) diff --git a/local/e2tool.lua b/local/e2tool.lua index eff434c..5a8105d 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -1317,12 +1317,16 @@ end -- in the project. The result itself is excluded. -- @param info Info table. -- @param resultname Result name. --- @return Sorted vector of result dependencies. +-- @return Sorted vector of result dependencies, or false on error. +-- @return Error object on failure. function e2tool.dlist(info, resultname) local t = {} - local deps - for _,f in ipairs(e2tool_ftab.dlist) do - deps = f(info, resultname) + local deps, re + for _,dlist_cb in ipairs(e2tool_ftab.dlist) do + deps, re = dlist_cb(info, resultname) + if not deps then + return false, re + end for _,d in ipairs(deps) do table.insert(t, d) end @@ -1348,10 +1352,14 @@ function e2tool.dlist_recursive(info, result) local t = {} if type(result) == "string" then - result = e2tool.dlist(info, result) + result, re = e2tool.dlist(info, result) + if not result then + return false, re + end end local function visit(res) + local deps, re if had[res] then return false, err.new("cyclic dependency: %s", table.concat(path, " ")) @@ -1359,7 +1367,11 @@ function e2tool.dlist_recursive(info, result) table.insert(path, res) had[res] = true col[res] = true - for _, d in ipairs(e2tool.dlist(info, res)) do + deps, re = e2tool.dlist(info, res) + if not deps then + return false, re + end + for _, d in ipairs(deps) do rc, re = visit(d) if not rc then return false, re