]> git.e2factory.org Git - e2factory.git/commitdiff
bugfix: fix error handling when cyclic dependencies are detected in the configuration.
authorGordon Hecker <gh@emlix.com>
Mon, 18 Jan 2010 13:48:13 +0000 (14:48 +0100)
committerGordon Hecker <gh@emlix.com>
Fri, 12 Feb 2010 09:51:58 +0000 (10:51 +0100)
Signed-off-by: Gordon Hecker <gh@emlix.com>
local/build.lua
local/dlist.lua
local/e2build.lua
local/e2tool.lua
local/ls-project.lua

index c3febeb9b558ee00590f67655b23306b933860a8..6eb3d625e11ba3ecfd338003a77eb0c6073b3808 100755 (executable)
@@ -121,9 +121,17 @@ end
 -- a list of results to build, topologically sorted
 local sel_res = {}             
 if #results > 0 then
-       sel_res = e2tool.dlist_recursive(info, results)
+       local re
+       sel_res, re = e2tool.dlist_recursive(info, results)
+       if not sel_res then
+               e2lib.abort(re)
+       end
 else
-       sel_res = e2tool.dsort(info)
+       local re
+       sel_res, re = e2tool.dsort(info)
+       if not sel_res then
+               e2lib.abort(re)
+       end
 end
 
 rc, re = e2tool.print_selection(info, sel_res)
index d475a32a50da0fa6ebc7945a96276c0a5bdbb74a..03011cd4a133cd7e965a718dd4dff7f7a07c41cf 100755 (executable)
@@ -55,13 +55,17 @@ if not info.results[ result ] then
   e2lib.abort("no such result: ", result)
 end
 
-local dep = opts.recursive
-  and e2tool.dlist_recursive(info, result)
-  or e2tool.dlist(info, result)
-
-if dep then
-  for i = 1, #dep do print(dep[i]) end
+local dep, re
+if opts.recursive then
+  dep, re = e2tool.dlist_recursive(info, result)
+else
+  dep, re = e2tool.dlist(info, result)
+end
+if not dep then
+  e2lib.abort(re)
 end
 
+for i = 1, #dep do print(dep[i]) end
+
 e2lib.finish()
 
index b9e15173258a9b90f749a6c7c1f2600788656d04..a30b9e6f2ef4d3af126c764edcbfa99962139ced 100644 (file)
@@ -1138,8 +1138,11 @@ function e2build.collect_project(info, r, return_flags)
        end
        -- write topologically sorted list of result
        local destdir = string.format("%s/project", res.build_config.T)
-       local tsorted_results = e2tool.dlist_recursive(info,
+       local tsorted_results, re = e2tool.dlist_recursive(info,
                                        res.collect_project_results)
+       if not tsorted_results then
+               return false, e:cat(re)
+       end
        local tsorted_results_string = table.concat(tsorted_results, "\n")
        local resultlist = string.format("%s/resultlist", destdir)
        rc, re = e2lib.write_file(resultlist, tsorted_results_string .. "\n")
index 2e02621b70460ca553ec167923c6701beeac8feb..4a97277b80d6ec364dfc43d5b49c46c7b9c77fd5 100644 (file)
@@ -845,23 +845,31 @@ function e2tool.dlist_recursive(info, result)
   local t = {}
   local function visit(res)
     if had[res] then
-      e2lib.warn("WOTHER", "cyclic dependency: " .. table.concat(path, " "))
-      t = nil
+      return false, new_error("cyclic dependency: %s", table.concat(path, " "))
     elseif t and not col[res] then
       table.insert(path, res)
       had[res] = true
       col[res] = true
-      for _, d in ipairs(e2tool.dlist(info, res)) do visit(d) end
+      for _, d in ipairs(e2tool.dlist(info, res)) do
+       local rc, re = visit(d)
+       if not rc then
+         return false, re
+       end
+      end
       if t then table.insert(t, res) end
       had[res] = nil
       path[#path] = nil
     end
+    return true
   end
   for _, r in ipairs(
        type(result) == "table" and result or e2tool.dlist(info, result)) do
-    visit(r)
+    local rc, re = visit(r)
+    if not rc then
+      return nil, re
+    end
   end
-  return t
+  return t, nil
 end
 
 function e2tool.dsort(info)
@@ -1885,6 +1893,7 @@ end
 function e2tool.check_collect_project(info, resultname)
        local res = info.results[resultname]
        local e = new_error("in result %s:", resultname)
+       local rc, re
        if not res.collect_project then
                -- insert empty tables, to avoid some conditionals in the code
                res.collect_project_results = {}
@@ -1908,8 +1917,11 @@ function e2tool.check_collect_project(info, resultname)
        if e:getcount() > 1 then
                return false, e
        end
-       res.collect_project_results = e2tool.dlist_recursive(info,
+       res.collect_project_results, re = e2tool.dlist_recursive(info,
                                res.collect_project_default_result)
+       if not res.collect_project_results then
+               return false, e:cat(re)
+       end
        -- store a sorted list of required results
        table.insert(res.collect_project_results,
                        res.collect_project_default_result)
index 5baf3cc14eccf9105863686ffda28561e2ca3bed..6af428799020e07347d1f140c6d8e5a911b80ed6 100755 (executable)
@@ -66,9 +66,15 @@ elseif #opts.arguments > 0 then
   end
 end
 if #results > 0 then
-  results = e2tool.dlist_recursive(info, results)
+  results, re = e2tool.dlist_recursive(info, results)
+  if not results then
+    e2lib.abort(re)
+  end
 else
-  results = e2tool.dsort(info)
+  results, re = e2tool.dsort(info)
+  if not results then
+    e2lib.abort(re)
+  end
 end
 table.sort(results)