From: Tobias Ulmer Date: Wed, 17 Apr 2013 15:41:05 +0000 (+0200) Subject: plugin: remove call to abort() X-Git-Tag: e2factory-2.3.15rc1~522 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=ec7bcf2900f5104302bc398f3ad5b345aece3a75;p=e2factory.git plugin: remove call to abort() Signed-off-by: Tobias Ulmer --- diff --git a/generic/plugin.lua b/generic/plugin.lua index 4d97f69..e8fb1ba 100644 --- a/generic/plugin.lua +++ b/generic/plugin.lua @@ -162,8 +162,11 @@ end --- Depth first search visitor that does the sorting. local function plugin_dfs_visit(plugin, plugins, pluginsvisited, pluginssorted, cycledetect) + + local rc, re + if pluginsvisited[plugin] then - return + return true end pluginsvisited[plugin] = true @@ -179,27 +182,37 @@ local function plugin_dfs_visit(plugin, plugins, pluginsvisited, pluginssorted, c = " " .. p.file end e:append("somewhere in this branch:" .. c) - e2lib.abort(e) + return false, e end - plugin_dfs_visit(pluginm, plugins, pluginsvisited, + rc, re = plugin_dfs_visit(pluginm, plugins, pluginsvisited, pluginssorted, cycledetect) + if not rc then + return false, re + end end end end table.insert(pluginssorted, 1, plugin) + + return true end --- Topological sort for plugins according to their dependencies. --- When cycles are encountered, it aborts. --- @return a sorted plugin table +-- @return Sorted plugin table or false on error. +-- @return Error object on failure. local function plugin_tsort(plugins) + local rc, re local pluginsvisited = {} local pluginssorted = {} for _, plugin in ipairs(plugins) do if not pluginsvisited[plugin] then - plugin_dfs_visit(plugin, plugins, pluginsvisited, pluginssorted, {}) + rc, re = plugin_dfs_visit(plugin, plugins, + pluginsvisited, pluginssorted, {}) + if not rc then + return false, re + end end end @@ -211,8 +224,12 @@ end -- @return an error object on failure function plugin.init_plugins() local e = err.new("initializing plugins failed") + local re - plugins = plugin_tsort(plugins) + plugins, re = plugin_tsort(plugins) + if not plugins then + return false, e:cat(re) + end for _, pd in ipairs(plugins) do e2lib.logf(4, "init plugin %s", pd.file)