]> git.e2factory.org Git - e2factory.git/commitdiff
Remove calls to e2lib.abort() in local tools
authorTobias Ulmer <tu@emlix.com>
Mon, 15 Apr 2013 13:55:58 +0000 (15:55 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 13:58:55 +0000 (14:58 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/e2-build-numbers.lua
local/e2-build.lua
local/e2-cf.lua
local/e2-dlist.lua
local/e2-dsort.lua
local/e2-fetch-sources.lua
local/e2-ls-project.lua
local/e2-new-source.lua
local/e2-playground.lua

index 72cb6459925053e85870463aafe5f3cc0475d947..8228ab2c562e9e30f228b1d1e7a37416b66b2ff8 100644 (file)
@@ -35,7 +35,7 @@ local function e2_build_numbers(arg)
     e2lib.init()
     local info, re = e2tool.local_init(nil, "build-numbers")
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     return false, err.new("e2-build-numbers is deprecated and has been removed")
index 6431f6f116627744881a30713ebe0da4ac29d499..c690852d6ddf550ae4b41db18afa783950e6a9ed 100644 (file)
@@ -40,7 +40,7 @@ local function e2_build(arg)
     e2lib.init()
     local info, re = e2tool.local_init(nil, "build")
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     e2option.flag("all", "build all results (default unless for working copy)")
@@ -72,14 +72,14 @@ local function e2_build(arg)
                 rc, re = info.cache:set_writeback(set.server, false)
                 if not rc then
                     local e = err.new(disable_msg, set.server)
-                    e2lib.abort(e:cat(re))
+                    return false, e:cat(re)
                 end
             elseif set.set == "enable" then
                 e2lib.logf(3, enable_msg, set.server)
                 rc, re = info.cache:set_writeback(set.server, true)
                 if not rc then
                     local e = err.new(enable_msg, set.server)
-                    e2lib.abort(e:cat(re))
+                    return false, e:cat(re)
                 end
             end
         end
@@ -94,17 +94,17 @@ local function e2_build(arg)
     -- get build mode from the command line
     local build_mode = policy.handle_commandline_options(opts, true)
     if not build_mode then
-        e2lib.abort("no build mode given")
+        return false, err.new("no build mode given")
     end
 
     info, re = e2tool.collect_project_info(info)
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
     perform_writeback_settings(writeback)
     local rc, re = e2tool.check_project_info(info)
     if not rc then
-        e2lib.abort(re)
+        return false, re
     end
 
     -- apply the standard build mode to all results
@@ -131,7 +131,7 @@ local function e2_build(arg)
     local build_mode = nil
     if opts["branch-mode"] and opts["wc-mode"] then
         e = err.new("--branch-mode and --wc-mode are mutually exclusive")
-        e2lib.abort(e)
+        return false, e
     end
     if opts["branch-mode"] then
         -- selected results get a special build mode
@@ -146,13 +146,16 @@ local function e2_build(arg)
     local playground = opts["playground"]
     if playground then
         if opts.release then
-            e2lib.abort("--release and --playground are mutually exclusive")
+            return false,
+                err.new("--release and --playground are mutually exclusive")
         end
         if opts.all then
-            e2lib.abort("--all and --playground are mutually exclusive")
+            return false,
+                err.new("--all and --playground are mutually exclusive")
         end
         if #arguments ~= 1 then
-            e2lib.abort("please select one single result for the playground")
+            return false,
+                err.new("please select one single result for the playground")
         end
     end
     local force_rebuild = opts["force-rebuild"]
@@ -160,10 +163,10 @@ local function e2_build(arg)
     local keep_chroot = opts["keep"]
 
     -- apply flags to the selected results
-    rc, re = e2tool.select_results(info, results, force_rebuild, request_buildno,
-    keep_chroot, build_mode, playground)
+    rc, re = e2tool.select_results(info, results, force_rebuild,
+        request_buildno, keep_chroot, build_mode, playground)
     if not rc then
-        e2lib.abort(re)
+        return false, re
     end
 
     -- a list of results to build, topologically sorted
@@ -172,30 +175,30 @@ local function e2_build(arg)
         local re
         sel_res, re = e2tool.dlist_recursive(info, results)
         if not sel_res then
-            e2lib.abort(re)
+            return false, re
         end
     else
         local re
         sel_res, re = e2tool.dsort(info)
         if not sel_res then
-            e2lib.abort(re)
+            return false, re
         end
     end
 
     rc, re = e2tool.print_selection(info, sel_res)
     if not rc then
-        e2lib.abort(re)
+        return false, re
     end
 
     if opts.release and not e2tool.e2_has_fixed_tag(info) then
-        e2lib.abort("Failure: e2 is on pseudo tag while building in release mode.")
+        return false, err.new("Failure: e2 is on pseudo tag while building in release mode.")
     end
 
     -- calculate buildids for selected results
     for _,r in ipairs(sel_res) do
         local bid, re = e2tool.buildid(info, r)
         if not bid then
-            e2lib.abort(re)
+            return false, re
         end
     end
 
@@ -203,13 +206,14 @@ local function e2_build(arg)
         for _,r in ipairs(sel_res) do
             print(string.format("%-20s [%s]", r, e2tool.buildid(info, r)))
         end
-        e2lib.finish()
+
+        return true
     end
 
     -- build
     local rc, re = e2build.build_results(info, sel_res)
     if not rc then
-        e2lib.abort(re)
+        return false, re
     end
 
     return true
index bdd0aab464fbbacec89f510216d893e021e42409..8014ed469d5fe562588e509b32d747bc2cc07db7 100644 (file)
@@ -320,7 +320,7 @@ local function e2_cf(arg)
     e2lib.init()
     local info, re = e2tool.local_init(nil, "cf")
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     local opts, arguments = e2option.parse(arg)
@@ -329,12 +329,12 @@ local function e2_cf(arg)
     -- the project configuration.
     info, re = e2tool.collect_project_info(info, true)
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     local rc, re = e2lib.chdir(info.root)
     if not rc then
-        e2lib.abort(re)
+        return false, re
     end
 
     commands.editbuildscript = editbuildscript
@@ -361,7 +361,7 @@ local function e2_cf(arg)
     end
 
     if #match == 0 then
-        e2lib.abort(err.new("unknown command"))
+        return false, err.new("unknown command")
     elseif #match == 1 then
         local a = {}
         for _,o in ipairs(arguments) do
@@ -370,11 +370,11 @@ local function e2_cf(arg)
         local f = commands[match[1]]
         rc, re = f(info, a)
         if not rc then
-            e2lib.abort(re)
+            return false, re
         end
     else
-        e2lib.abort(err.new("Ambiguous command: \"%s\" matches: %s",
-        cmd, table.concat(match, ', ')))
+        return false, err.new("Ambiguous command: \"%s\" matches: %s",
+            cmd, table.concat(match, ', '))
     end
 
     return true
index 6180b9c7ed80a9b04083d65f8754bdc7f0021ff4..37f9846ce35c9f5528f91abf432f36e47e9476c5 100644 (file)
@@ -36,24 +36,25 @@ local function e2_dlist(arg)
     e2lib.init()
     local info, re = e2tool.local_init(nil, "dlist")
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     e2option.flag("recursive", "show indirect dependencies, too")
     local opts, arguments = e2option.parse(arg)
 
     if #arguments == 0 then
-        e2lib.abort("no result given - enter `e2-dlist --help' for usage information")
+        return false,
+            err.new("no result given - enter `e2-dlist --help' for usage information")
     elseif #arguments ~= 1 then e2option.usage(1) end
 
     local result = arguments[1]
     info, re = e2tool.collect_project_info(info)
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     if not info.results[ result ] then
-        e2lib.abort("no such result: ", result)
+        return false, err.new("no such result: ", result)
     end
 
     local dep, re
@@ -63,7 +64,7 @@ local function e2_dlist(arg)
         dep, re = e2tool.dlist(info, result)
     end
     if not dep then
-        e2lib.abort(re)
+        return false, re
     end
 
     for i = 1, #dep do
index f1d1a8479c2ad7cfb6aa3d30e72ded7d241aa01b..12512628341b95a02d8f78d8def88f1265f517ad 100644 (file)
@@ -36,14 +36,14 @@ local function e2_dsort(arg)
     e2lib.init()
     local info, re = e2tool.local_init(nil, "dsort")
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     e2option.parse(arg)
 
     info, re = e2tool.collect_project_info(info)
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     local d = e2tool.dsort(info)
index d78a49b3af4cb067f9bd2110e5a2514ce8d770df..fde3612c67983117235843a146867eb42be3a5e7 100644 (file)
@@ -40,7 +40,7 @@ local function e2_fetch_source(arg)
     e2lib.init()
     local info, re = e2tool.local_init(nil, "fetch-sources")
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     local e = err.new()
@@ -60,11 +60,11 @@ local function e2_fetch_source(arg)
     local opts, arguments = e2option.parse(arg)
     info, re = e2tool.collect_project_info(info)
     if not info then
-        e2lib.abort(re)
+        return false, info
     end
     local rc, re = e2tool.check_project_info(info)
     if not rc then
-        e2lib.abort(e:cat(re))
+        return false, e:cat(re)
     end
 
     if not (opts.fetch or opts.update) then
@@ -110,7 +110,7 @@ local function e2_fetch_source(arg)
             for _,file in ipairs(info.chroot.groups_byname[c].files) do
                 local rc, e = info.cache:cache_file(file.server, file.location, {})
                 if not rc then
-                    return false, "caching file failed"
+                    return false, err.new("caching file failed")
                 end
             end
         end
@@ -184,9 +184,9 @@ local function e2_fetch_source(arg)
                     sel[s] = s
                 end
             elseif opts.result then
-                e2lib.abort("is not a result: " .. x)
+                return false, err.new("is not a result: %s", x)
             else
-                e2lib.abort("is not a source: " .. x)
+                return false, err.new("is not a source: %s", x)
             end
         end
     elseif opts["all"] then
@@ -212,7 +212,7 @@ local function e2_fetch_source(arg)
         end
     end
     if e:getcount() > 0 then
-        e2lib.abort(e)
+        return false, e
     end
 
     if opts.chroot then
@@ -234,7 +234,7 @@ local function e2_fetch_source(arg)
     end
 
     if e:getcount() > 0 then
-        e2lib.abort(e)
+        return false, e
     end
 
     return true
index b8bd350f0e3332e2b73ce5326fe0b26c6f02a9f4..8731ad4b488ac4c5b40d822d56696f74808dcfa7 100644 (file)
@@ -41,7 +41,7 @@ local function e2_ls_project(arg)
     e2lib.init()
     local info, re = e2tool.local_init(nil, "ls-project")
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     policy.register_commandline_options()
@@ -54,11 +54,11 @@ local function e2_ls_project(arg)
 
     info, re = e2tool.collect_project_info(info)
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
     local rc, re = e2tool.check_project_info(info)
     if not rc then
-        e2lib.abort(re)
+        return false, re
     end
 
     local results = {}
@@ -71,19 +71,19 @@ local function e2_ls_project(arg)
             if info.results[r] then
                 table.insert(results, r)
             else
-                e2lib.abort(err.new("not a result: %s", r))
+                return false, err.new("not a result: %s", r)
             end
         end
     end
     if #results > 0 then
         results, re = e2tool.dlist_recursive(info, results)
         if not results then
-            e2lib.abort(re)
+            return false, re
         end
     else
         results, re = e2tool.dsort(info)
         if not results then
-            e2lib.abort(re)
+            return false, re
         end
     end
     table.sort(results)
@@ -241,7 +241,7 @@ local function e2_ls_project(arg)
         p2(s1, s2, src.name)
         local t, re = scm.display(info, src.name)
         if not t then
-            e2lib.abort(re)
+            return false, re
         end
         for _,line in pairs(t) do
             p3(s1, s2, line)
index 257f3a02566c0e0ab57eef7f00e44868755bcafd..2a4a0a9728906656d9f30e7e9c8d06ba816d5462 100644 (file)
@@ -215,7 +215,7 @@ local function e2_new_source(arg)
     e2lib.init()
     local info, re = e2tool.local_init(nil, "new-source")
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     e2option.flag("git", "create a git repository")
@@ -226,12 +226,12 @@ local function e2_new_source(arg)
 
     info, re = e2tool.collect_project_info(info)
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     if opts.git then
         if #arguments ~= 1 then
-            e2lib.abort("<name> argument required")
+            return false, err.new("<name> argument required")
         end
         -- remote
         local rserver = info.default_repo_server
@@ -247,7 +247,7 @@ local function e2_new_source(arg)
         local rc, re = generic_git.new_repository(info.cache, lserver, llocation,
         rserver, rlocation, flags)
         if not rc then
-            e2lib.abort(re)
+            return false, re
         end
         e2lib.log(1, "Read e2-new-source(1) for the next step")
     elseif opts.files then
@@ -258,7 +258,7 @@ local function e2_new_source(arg)
         local location = arguments[1]
         local sl, e = e2lib.parse_server_location(location, info.default_files_server)
         if not sl then
-            e2lib.abort(e)
+            return false, e
         end
         local server = sl.server
         local location = sl.location
@@ -266,16 +266,16 @@ local function e2_new_source(arg)
         local checksum_file = arguments[3]
         local verify = not opts["no-checksum"]
         if verify and not checksum_file then
-            e2lib.abort("checksum file argument missing")
+            return false, err.new("checksum file argument missing")
         end
 
         local rc, re = new_files_source(info.cache, server, location, source_file,
         checksum_file, verify)
         if not rc then
-            e2lib.abort(re)
+            return false, re
         end
     else
-        e2lib.abort(err.new("Please specify either --files are --git"))
+        return false, err.new("Please specify either --files are --git")
     end
 
     return true
index 54abe0a3b2caeddebf2006efea7ca060e3ed6d03..65f1d879b7ca321168f2f865eb148eda1cd1852b 100644 (file)
@@ -41,7 +41,7 @@ local function e2_playground(arg)
     e2lib.init()
     local info, re = e2tool.local_init(nil, "playground")
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
 
     local e = err.new("entering playground failed")
@@ -55,15 +55,15 @@ local function e2_playground(arg)
     -- get build mode from the command line
     local build_mode = policy.handle_commandline_options(opts, true)
     if not build_mode then
-        e2lib.abort("no build mode given")
+        return false, err.new("no build mode given")
     end
     info, re = e2tool.collect_project_info(info)
     if not info then
-        e2lib.abort(re)
+        return false, re
     end
     local rc, re = e2tool.check_project_info(info)
     if not rc then
-        e2lib.abort(re)
+        return false, re
     end
 
     if #arguments ~= 1 then
@@ -78,10 +78,10 @@ local function e2_playground(arg)
     end
     rc, re = e2build.build_config(info, r, {})
     if not rc then
-        e2lib.abort(e:cat(re))
+        return false, e:cat(re)
     end
     if not e2build.chroot_exists(info, r) then
-        e2lib.abort("playground does not exist")
+        return false, err.new("playground does not exist")
     end
     if opts.showpath then
         print(info.results[r].build_config.c)
@@ -93,7 +93,7 @@ local function e2_playground(arg)
     local profile = string.format("%s/%s", bc.c, bc.profile)
     local f, msg = io.open(profile, "w")
     if not f then
-        e2lib.abort(e:cat(msg))
+        return false, e:cat(msg)
     end
     f:write(string.format("export TERM='%s'\n", e2lib.globals.osenv["TERM"]))
     f:write(string.format("export HOME=/root\n"))
@@ -119,7 +119,7 @@ local function e2_playground(arg)
     end
     rc, re = e2build.enter_playground(info, r, command)
     if not rc then
-        e2lib.abort(re)
+        return false, re
     end
 
     return true