From: Tobias Ulmer Date: Mon, 15 Apr 2013 13:55:58 +0000 (+0200) Subject: Remove calls to e2lib.abort() in local tools X-Git-Tag: e2factory-2.3.15rc1~533 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=a584c54783ddbd8beca173e3b9c0f53c02284857;p=e2factory.git Remove calls to e2lib.abort() in local tools Signed-off-by: Tobias Ulmer --- diff --git a/local/e2-build-numbers.lua b/local/e2-build-numbers.lua index 72cb645..8228ab2 100644 --- a/local/e2-build-numbers.lua +++ b/local/e2-build-numbers.lua @@ -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") diff --git a/local/e2-build.lua b/local/e2-build.lua index 6431f6f..c690852 100644 --- a/local/e2-build.lua +++ b/local/e2-build.lua @@ -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 diff --git a/local/e2-cf.lua b/local/e2-cf.lua index bdd0aab..8014ed4 100644 --- a/local/e2-cf.lua +++ b/local/e2-cf.lua @@ -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 diff --git a/local/e2-dlist.lua b/local/e2-dlist.lua index 6180b9c..37f9846 100644 --- a/local/e2-dlist.lua +++ b/local/e2-dlist.lua @@ -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 diff --git a/local/e2-dsort.lua b/local/e2-dsort.lua index f1d1a84..1251262 100644 --- a/local/e2-dsort.lua +++ b/local/e2-dsort.lua @@ -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) diff --git a/local/e2-fetch-sources.lua b/local/e2-fetch-sources.lua index d78a49b..fde3612 100644 --- a/local/e2-fetch-sources.lua +++ b/local/e2-fetch-sources.lua @@ -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 diff --git a/local/e2-ls-project.lua b/local/e2-ls-project.lua index b8bd350..8731ad4 100644 --- a/local/e2-ls-project.lua +++ b/local/e2-ls-project.lua @@ -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) diff --git a/local/e2-new-source.lua b/local/e2-new-source.lua index 257f3a0..2a4a0a9 100644 --- a/local/e2-new-source.lua +++ b/local/e2-new-source.lua @@ -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(" argument required") + return false, err.new(" 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 diff --git a/local/e2-playground.lua b/local/e2-playground.lua index 54abe0a..65f1d87 100644 --- a/local/e2-playground.lua +++ b/local/e2-playground.lua @@ -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