From 3ea4e33873be03eb14f6551b5cd627e6d5d81a7a Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Mon, 20 Aug 2012 13:02:39 +0200 Subject: [PATCH] Fix indentation Signed-off-by: Tobias Ulmer --- local/build-numbers.lua | 28 +-- local/build.lua | 169 +++++++++--------- local/cf.lua | 282 ++++++++++++++--------------- local/dlist.lua | 17 +- local/dsort.lua | 9 +- local/fetch-sources.lua | 218 +++++++++++------------ local/ls-project.lua | 328 +++++++++++++++++----------------- local/new-source.lua | 382 ++++++++++++++++++++-------------------- local/playground.lua | 44 ++--- 9 files changed, 741 insertions(+), 736 deletions(-) diff --git a/local/build-numbers.lua b/local/build-numbers.lua index 00b6e07..16f50a3 100644 --- a/local/build-numbers.lua +++ b/local/build-numbers.lua @@ -25,8 +25,6 @@ along with this program. If not, see . ]] --- e2-buildnumbers -*- Lua -*- - local e2lib = require("e2lib") require("e2tool") local e2option = require("e2option") @@ -34,7 +32,7 @@ local e2option = require("e2option") e2lib.init() local info, re = e2tool.local_init(nil, "build-numbers") if not info then - e2lib.abort(re) + e2lib.abort(re) end e2option.documentation = [[ @@ -49,20 +47,20 @@ local opts = e2option.parse(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") + e2lib.abort("no build mode given") end info, re = e2tool.collect_project_info(info) if not info then - e2lib.abort(re) + e2lib.abort(re) end local rc, re = e2tool.check_project_info(info) if not rc then - e2lib.abort(re) + e2lib.abort(re) end -- apply the standard build mode to all results for _,res in pairs(info.results) do - res.build_mode = build_mode + res.build_mode = build_mode end -- read build numbers, @@ -76,30 +74,32 @@ end local rc, re rc, re = e2tool.buildnumber_read(info) if not rc then - e2lib.abort(re) + e2lib.abort(re) end rc, re = e2tool.buildnumber_mergetoresults(info) if not rc then - e2lib.abort(re) + e2lib.abort(re) end -- recalculate build ids ids e2tool.flush_buildids(info) e2tool.calc_buildids(info) rc, re = e2tool.buildnumber_mergefromresults(info) if not rc then - e2lib.abort(re) + e2lib.abort(re) end if opts["no-sync"] then - rc, re = e2tool.buildnumber_request_local(info) + rc, re = e2tool.buildnumber_request_local(info) else - rc, re = e2tool.buildnumber_request(info) + rc, re = e2tool.buildnumber_request(info) end if not rc then - e2lib.abort(re) + e2lib.abort(re) end rc, re = e2tool.buildnumber_write(info) if not rc then - e2lib.abort(re) + e2lib.abort(re) end e2tool.buildnumber_display(info.build_numbers, 1) e2lib.finish() + +-- vim:sw=4:sts=4:et: diff --git a/local/build.lua b/local/build.lua index 987f77d..379c3fa 100644 --- a/local/build.lua +++ b/local/build.lua @@ -25,8 +25,6 @@ along with this program. If not, see . ]] --- e2-build -*- Lua -*- - local e2lib = require("e2lib") require("e2tool") require("e2build") @@ -36,7 +34,7 @@ local e2option = require("e2option") e2lib.init() local info, re = e2tool.local_init(nil, "build") if not info then - e2lib.abort(re) + e2lib.abort(re) end e2option.documentation = [[ @@ -59,98 +57,98 @@ e2option.flag("buildid", "display buildids and exit") -- as the cache is initialized. local writeback = {} local function disable_writeback(server) - table.insert(writeback, { set = "disable", server = server }) + table.insert(writeback, { set = "disable", server = server }) end local function enable_writeback(server) - table.insert(writeback, { set = "enable", server = server }) + table.insert(writeback, { set = "enable", server = server }) end local function perform_writeback_settings(writeback) - local rc, re - local enable_msg = "enabling writeback for server '%s' [--enable-writeback]" - local disable_msg = - "disabling writeback for server '%s' [--disable-writeback]" - for _,set in ipairs(writeback) do - if set.set == "disable" then - e2lib.logf(3, disable_msg, set.server) - 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)) - 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)) - end - end - end + local rc, re + local enable_msg = "enabling writeback for server '%s' [--enable-writeback]" + local disable_msg = + "disabling writeback for server '%s' [--disable-writeback]" + for _,set in ipairs(writeback) do + if set.set == "disable" then + e2lib.logf(3, disable_msg, set.server) + 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)) + 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)) + end + end + end end e2option.option("disable-writeback", "disable writeback for server", nil, - disable_writeback, "SERVER") +disable_writeback, "SERVER") e2option.option("enable-writeback", "enable writeback for server", nil, - enable_writeback, "SERVER") +enable_writeback, "SERVER") local opts, arguments = e2option.parse(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") + e2lib.abort("no build mode given") end info, re = e2tool.collect_project_info(info) if not info then - e2lib.abort(re) + e2lib.abort(re) end perform_writeback_settings(writeback) local rc, re = e2tool.check_project_info(info) if not rc then - e2lib.abort(re) + e2lib.abort(re) end -- apply the standard build mode to all results for _,res in pairs(info.results) do - res.build_mode = build_mode + res.build_mode = build_mode end -- handle result selection local results = {} if opts["all"] then - for r,_ in pairs(info.results) do - table.insert(results, r) - end + for r,_ in pairs(info.results) do + table.insert(results, r) + end elseif #arguments > 0 then - for i,r in ipairs(arguments) do - table.insert(results, r) - end + for i,r in ipairs(arguments) do + table.insert(results, r) + end end -- handle command line flags 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) + e = err.new("--branch-mode and --wc-mode are mutually exclusive") + e2lib.abort(e) end if opts["branch-mode"] then - -- selected results get a special build mode - build_mode = policy.default_build_mode["branch"] + -- selected results get a special build mode + build_mode = policy.default_build_mode["branch"] end if opts["wc-mode"] then - build_mode = policy.default_build_mode["working-copy"] + build_mode = policy.default_build_mode["working-copy"] end local playground = opts["playground"] if playground then - if opts.release then - e2lib.abort("--release and --playground are mutually exclusive") - end - if opts.all then - e2lib.abort("--all and --playground are mutually exclusive") - end - if #arguments ~= 1 then - e2lib.abort("please select one single result for the playground") - end + if opts.release then + e2lib.abort("--release and --playground are mutually exclusive") + end + if opts.all then + e2lib.abort("--all and --playground are mutually exclusive") + end + if #arguments ~= 1 then + e2lib.abort("please select one single result for the playground") + end end local force_rebuild = opts["force-rebuild"] local request_buildno = opts["request-buildno"] @@ -158,68 +156,69 @@ 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) +keep_chroot, build_mode, playground) if not rc then - e2lib.abort(re) + e2lib.abort(re) end -- a list of results to build, topologically sorted local sel_res = {} if #results > 0 then - local re - sel_res, re = e2tool.dlist_recursive(info, results) - if not sel_res then - e2lib.abort(re) - end + local re + sel_res, re = e2tool.dlist_recursive(info, results) + if not sel_res then + e2lib.abort(re) + end else - local re - sel_res, re = e2tool.dsort(info) - if not sel_res then - e2lib.abort(re) - end + 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) if not rc then - e2lib.abort(re) + e2lib.abort(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.") + e2lib.abort("Failure: e2 is on pseudo tag while building in release mode.") end if opts["buildnumber"] then - e2lib.logf(1, "setting up build numbers") - local rc, re - rc, re = e2tool.buildnumber_read(info) - if not rc then - e2lib.abort(re) - end - rc, re = e2tool.buildnumber_mergetoresults(info) - if not rc then - e2lib.abort(re) - end + e2lib.logf(1, "setting up build numbers") + local rc, re + rc, re = e2tool.buildnumber_read(info) + if not rc then + e2lib.abort(re) + end + rc, re = e2tool.buildnumber_mergetoresults(info) + if not rc then + e2lib.abort(re) + end 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) - end + local bid, re = e2tool.buildid(info, r) + if not bid then + e2lib.abort(re) + end end if opts["buildid"] then - for _,r in ipairs(sel_res) do - print(string.format("%-20s [%s]", r, e2tool.buildid(info, r))) - end - e2lib.finish() + for _,r in ipairs(sel_res) do + print(string.format("%-20s [%s]", r, e2tool.buildid(info, r))) + end + e2lib.finish() end -- build local rc, re = e2build.build_results(info, sel_res) if not rc then - e2lib.abort(re) + e2lib.abort(re) end e2lib.finish() +-- vim:sw=4:sts=4:et: diff --git a/local/cf.lua b/local/cf.lua index f478808..9a355fa 100644 --- a/local/cf.lua +++ b/local/cf.lua @@ -25,8 +25,6 @@ along with this program. If not, see . ]] --- e2-cf -*- Lua -*- - local e2lib = require("e2lib") require("e2tool") local err = require("err") @@ -35,18 +33,18 @@ local e2option = require("e2option") e2lib.init() local info, re = e2tool.local_init(nil, "cf") if not info then - e2lib.abort(re) + e2lib.abort(re) end e2option.documentation = [[ usage: e2 cf ... commands: - newresult - newsource - editresult - editbuildscript - editsource +newresult +newsource +editresult +editbuildscript +editsource Commands starting with 'edit' can be abbreviated by using e... Commands starting with 'new' can be abbreviated by using n... @@ -63,12 +61,12 @@ local opts, arguments = e2option.parse(arg) -- the project configuration. info, re = e2tool.collect_project_info(info, true) if not info then - e2lib.abort(re) + e2lib.abort(re) end rc, re = e2lib.chdir(info.root) if not rc then - e2lib.abort(re) + e2lib.abort(re) end local editor = e2lib.globals.osenv["EDITOR"] @@ -76,127 +74,127 @@ local editor = e2lib.globals.osenv["EDITOR"] local commands = {} local function newsource(info, ...) - local e = err.new("newsource") - local t = ... - local name = t[2] - local scm = t[3] - if not name then - e:append("missing parameter: name") - end - if not scm then - e:append("missing parameter: scm") - end - if e:getcount() > 1 then - return false, e - end - local cfdir = e2tool.sourcedir(name) - local cf = e2tool.sourceconfig(name) - local cftemplate = string.format("%s/source.%s", info.local_template_path, - scm) - if not e2lib.isfile(cftemplate) then - return false, e:append("template not available:", cftemplate) - end - if not e2lib.isfile(cf) and e2lib.isfile(cftemplate) then - local rc, re = e2lib.mkdir(cfdir) - if not rc then - return false, e:cat(re) - end - local rc, re = e2lib.cp(cftemplate, cf) - if not rc then - return false, e:cat(re) - end - end - rc, re = commands.editsource(info, ...) - if not rc then - return false, e:cat(re) - end - return true, nil + local e = err.new("newsource") + local t = ... + local name = t[2] + local scm = t[3] + if not name then + e:append("missing parameter: name") + end + if not scm then + e:append("missing parameter: scm") + end + if e:getcount() > 1 then + return false, e + end + local cfdir = e2tool.sourcedir(name) + local cf = e2tool.sourceconfig(name) + local cftemplate = string.format("%s/source.%s", info.local_template_path, + scm) + if not e2lib.isfile(cftemplate) then + return false, e:append("template not available:", cftemplate) + end + if not e2lib.isfile(cf) and e2lib.isfile(cftemplate) then + local rc, re = e2lib.mkdir(cfdir) + if not rc then + return false, e:cat(re) + end + local rc, re = e2lib.cp(cftemplate, cf) + if not rc then + return false, e:cat(re) + end + end + rc, re = commands.editsource(info, ...) + if not rc then + return false, e:cat(re) + end + return true, nil end local function editsource(info, ...) - local e = err.new("editsource") - local t = ... - local name = t[2] - if not name then - e:append("missing parameter: name") - end - if e:getcount() > 1 then - return false, e - end - local cf = e2tool.sourceconfig(name) - rc = os.execute(string.format("%s %s", editor, cf)) - return true, nil + local e = err.new("editsource") + local t = ... + local name = t[2] + if not name then + e:append("missing parameter: name") + end + if e:getcount() > 1 then + return false, e + end + local cf = e2tool.sourceconfig(name) + rc = os.execute(string.format("%s %s", editor, cf)) + return true, nil end local function newresult(info, ...) - local e = err.new("newresult") - local t = ... - local name = t[2] - if not name then - e:append("missing parameter: name") - end - if e:getcount() > 1 then - return false, e - end - local cfdir = e2tool.resultdir(name) - local cf = e2tool.resultconfig(name) - local bs = e2tool.resultbuildscript(name) - local cftemplate = string.format("%s/result", info.local_template_path) - local bstemplate = string.format("%s/build-script", info.local_template_path) - if not e2lib.isfile(cf) and not e2lib.isfile(bs) and - e2lib.isfile(cftemplate) and e2lib.isfile(bstemplate) then - local rc, re = e2lib.mkdir(cfdir) - if not rc then - return false, e:cat(re) - end - local rc, re = e2lib.cp(cftemplate, cf) - if not rc then - return false, e:cat(re) - end - local rc, re = e2lib.cp(bstemplate, bs) - if not rc then - return false, e:cat(re) - end - end - rc, re = commands.editresult(info, ...) - if not rc then - return false, e:cat(re) - end - rc, re = commands.editbuildscript(info, ...) - if not rc then - return false, e:cat(re) - end - return true, nil + local e = err.new("newresult") + local t = ... + local name = t[2] + if not name then + e:append("missing parameter: name") + end + if e:getcount() > 1 then + return false, e + end + local cfdir = e2tool.resultdir(name) + local cf = e2tool.resultconfig(name) + local bs = e2tool.resultbuildscript(name) + local cftemplate = string.format("%s/result", info.local_template_path) + local bstemplate = string.format("%s/build-script", info.local_template_path) + if not e2lib.isfile(cf) and not e2lib.isfile(bs) and + e2lib.isfile(cftemplate) and e2lib.isfile(bstemplate) then + local rc, re = e2lib.mkdir(cfdir) + if not rc then + return false, e:cat(re) + end + local rc, re = e2lib.cp(cftemplate, cf) + if not rc then + return false, e:cat(re) + end + local rc, re = e2lib.cp(bstemplate, bs) + if not rc then + return false, e:cat(re) + end + end + rc, re = commands.editresult(info, ...) + if not rc then + return false, e:cat(re) + end + rc, re = commands.editbuildscript(info, ...) + if not rc then + return false, e:cat(re) + end + return true, nil end local function editresult(info, ...) - local e = err.new("editresult") - local t = ... - local name = t[2] - if not name then - e:append("missing parameter: name") - end - if e:getcount() > 1 then - return false, e - end - local cf = e2tool.resultconfig(name) - os.execute(string.format("%s %s", editor, cf)) - return true, nil + local e = err.new("editresult") + local t = ... + local name = t[2] + if not name then + e:append("missing parameter: name") + end + if e:getcount() > 1 then + return false, e + end + local cf = e2tool.resultconfig(name) + os.execute(string.format("%s %s", editor, cf)) + return true, nil end local function editbuildscript(info, ...) - local e = err.new("editbuildscript") - local t = ... - local name = t[2] - if not name then - e:append("missing parameter: name") - end - if e:getcount() > 1 then - return false, e - end - local cf = e2tool.resultbuildscript(name) - os.execute(string.format("%s %s", editor, cf)) - return true, nil + local e = err.new("editbuildscript") + local t = ... + local name = t[2] + if not name then + e:append("missing parameter: name") + end + if e:getcount() > 1 then + return false, e + end + local cf = e2tool.resultbuildscript(name) + os.execute(string.format("%s %s", editor, cf)) + return true, nil end commands.editbuildscript = editbuildscript @@ -214,32 +212,34 @@ local i = 1 local match = {} local cmd = arguments[1] if #arguments < 1 then - e2option.usage() - e2lib.finish(1) + e2option.usage() + e2lib.finish(1) end for c,f in pairs(commands) do - if c:match(string.format("^%s", cmd)) then - table.insert(match, c) - end + if c:match(string.format("^%s", cmd)) then + table.insert(match, c) + end end if #match == 1 then - local a = {} - for _,o in ipairs(arguments) do - table.insert(a, o) - end - local f = commands[match[1]] - rc, re = f(info, a) - if not rc then - e2lib.abort(re) - end + local a = {} + for _,o in ipairs(arguments) do + table.insert(a, o) + end + local f = commands[match[1]] + rc, re = f(info, a) + if not rc then + e2lib.abort(re) + end else - if #match > 1 then - print(string.format("Ambiguous command: %s", cmd)) - end - print("Available commands:") - for c,f in pairs(commands) do - print(c) - end - e2lib.finish(1) + if #match > 1 then + print(string.format("Ambiguous command: %s", cmd)) + end + print("Available commands:") + for c,f in pairs(commands) do + print(c) + end + e2lib.finish(1) end e2lib.finish(0) + +-- vim:sw=4:sts=4:et: diff --git a/local/dlist.lua b/local/dlist.lua index 44d16bc..9b06e48 100644 --- a/local/dlist.lua +++ b/local/dlist.lua @@ -25,8 +25,6 @@ along with this program. If not, see . ]] --- dlist - list sorted dependencies -*- Lua -*- - local e2lib = require("e2lib") require("e2tool") require("e2build") @@ -35,7 +33,7 @@ local e2option = require("e2option") e2lib.init() local info, re = e2tool.local_init(nil, "dlist") if not info then - e2lib.abort(re) + e2lib.abort(re) end e2option.documentation = [[ @@ -48,30 +46,31 @@ 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") + e2lib.abort("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) + e2lib.abort(re) end if not info.results[ result ] then - e2lib.abort("no such result: ", result) + e2lib.abort("no such result: ", result) end local dep, re if opts.recursive then - dep, re = e2tool.dlist_recursive(info, result) + dep, re = e2tool.dlist_recursive(info, result) else - dep, re = e2tool.dlist(info, result) + dep, re = e2tool.dlist(info, result) end if not dep then - e2lib.abort(re) + e2lib.abort(re) end for i = 1, #dep do print(dep[i]) end e2lib.finish() +-- vim:sw=4:sts=4:et: diff --git a/local/dsort.lua b/local/dsort.lua index c8da13f..6d4c812 100644 --- a/local/dsort.lua +++ b/local/dsort.lua @@ -25,8 +25,6 @@ along with this program. If not, see . ]] --- dsort -*- Lua -*- - local e2lib = require("e2lib") require("e2tool") require("e2build") @@ -35,7 +33,7 @@ local e2option = require("e2option") e2lib.init() local info, re = e2tool.local_init(nil, "dsort") if not info then - e2lib.abort(re) + e2lib.abort(re) end e2option.documentation = [[ @@ -48,13 +46,14 @@ e2option.parse(arg) info, re = e2tool.collect_project_info(info) if not info then - e2lib.abort(re) + e2lib.abort(re) end local d = e2tool.dsort(info) if d then - for i = 1, #d do print(d[i]) end + for i = 1, #d do print(d[i]) end end e2lib.finish() +-- vim:sw=4:sts=4:et: diff --git a/local/fetch-sources.lua b/local/fetch-sources.lua index ef53f27..2a2744f 100644 --- a/local/fetch-sources.lua +++ b/local/fetch-sources.lua @@ -36,7 +36,7 @@ local e2option = require("e2option") e2lib.init() local info, re = e2tool.local_init(nil, "fetch-sources") if not info then - e2lib.abort(re) + e2lib.abort(re) end e2option.documentation = [[ @@ -76,45 +76,45 @@ e2option.flag("result", "select sources by result names") local opts, arguments = e2option.parse(arg) info, re = e2tool.collect_project_info(info) if not info then - e2lib.abort(re) + e2lib.abort(re) end local rc, re = e2tool.check_project_info(info) if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end if not (opts.fetch or opts.update) then - opts.fetch = true - e2lib.warn("WOTHER", "Selecting fetch by default") + opts.fetch = true + e2lib.warn("WOTHER", "Selecting fetch by default") end if opts.all then - e2lib.warn("WOTHER", "--all selects all sources, even files sources") + e2lib.warn("WOTHER", "--all selects all sources, even files sources") end if #arguments > 0 then - opts.selection = true + opts.selection = true end if not (opts.scm or opts.files or opts.chroot or opts.selection - or opts.git or opts.cvs or opts.svn) then - e2lib.warn("WOTHER", "Selecting scm sources by default") - opts.scm = true + or opts.git or opts.cvs or opts.svn) then + e2lib.warn("WOTHER", "Selecting scm sources by default") + opts.scm = true end if opts.scm then - opts.git = true - opts.cvs = true - opts.svn = true + opts.git = true + opts.cvs = true + opts.svn = true end local select_type = {} if opts["git"] then - select_type["git"] = true + select_type["git"] = true end if opts["svn"] then - select_type["svn"] = true + select_type["svn"] = true end if opts["cvs"] then - select_type["cvs"] = true + select_type["cvs"] = true end if opts["files"] then - select_type["files"] = true + select_type["files"] = true end --- cache chroot files @@ -122,15 +122,15 @@ end -- @return bool -- @return nil, an error string on error function cache_chroot(info) - for _,c in ipairs(info.chroot.groups_sorted) do - 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" - end + for _,c in ipairs(info.chroot.groups_sorted) do + 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" + end + end end - end - return true, nil + return true, nil end --- fetch and upgrade sources @@ -140,121 +140,123 @@ end -- @return bool -- @return nil, an error string on error function fetch_sources(info, opts, sel) - local rc1 = true -- global return code - local nfail = 0 -- failure counter - local e = err.new() -- no message yet, append the summary later on + local rc1 = true -- global return code + local nfail = 0 -- failure counter + local e = err.new() -- no message yet, append the summary later on - -- fetch - for _, s in pairs(info.sources) do - local has_wc = scm.has_working_copy(info, s.name) - local wc_avail = scm.working_copy_available(info, s.name) - if opts.fetch and sel[s.name] then - if wc_avail then - e2lib.log(1, "working copy for " .. s.name .. " is already available") - else - e2lib.log(1, "fetching working copy for source " .. s.name) - local rc, re = scm.fetch_source(info, s.name) - if not rc then - e2lib.log(4, string.format("fetching source failed: %s", - s.name)) - e:cat(re) + -- fetch + for _, s in pairs(info.sources) do + local has_wc = scm.has_working_copy(info, s.name) + local wc_avail = scm.working_copy_available(info, s.name) + if opts.fetch and sel[s.name] then + if wc_avail then + e2lib.log(1, "working copy for " .. s.name .. " is already available") + else + e2lib.log(1, "fetching working copy for source " .. s.name) + local rc, re = scm.fetch_source(info, s.name) + if not rc then + e2lib.log(4, string.format("fetching source failed: %s", + s.name)) + e:cat(re) + end + end end - end end - end - -- update - for _, s in pairs(info.sources) do - local has_wc = scm.has_working_copy(info, s.name) - local wc_avail = scm.working_copy_available(info, s.name) - if opts.update and has_wc and sel[s.name] then - if not wc_avail then - e2lib.log(1, string.format("working copy for %s is not available", - s.name)) - else - e2lib.log(1, "updating working copy for " .. s.name) - local rc, re = scm.update(info, s.name) - if not rc then - e2lib.log(4, string.format("updating working copy failed: %s", - s.name)) - e:cat(re) + -- update + for _, s in pairs(info.sources) do + local has_wc = scm.has_working_copy(info, s.name) + local wc_avail = scm.working_copy_available(info, s.name) + if opts.update and has_wc and sel[s.name] then + if not wc_avail then + e2lib.log(1, string.format("working copy for %s is not available", + s.name)) + else + e2lib.log(1, "updating working copy for " .. s.name) + local rc, re = scm.update(info, s.name) + if not rc then + e2lib.log(4, string.format("updating working copy failed: %s", + s.name)) + e:cat(re) + end + end end - end end - end - local nfail = e:getcount() - if nfail > 0 then - e:append("There were errors fetching %d sources", nfail) - return false, e - end - return true, nil + local nfail = e:getcount() + if nfail > 0 then + e:append("There were errors fetching %d sources", nfail) + return false, e + end + return true, nil end local sel = {} -- selected sources if #arguments > 0 then - for _, x in pairs(arguments) do - if info.sources[x] and not opts.result then - e2lib.log(3, "is regarded as source: " .. x) - sel[x] = x - elseif info.results[x] and opts.result then - e2lib.log(3, "is regarded as result: " .. x) - local res = info.results[x] - for _, s in ipairs(res.sources) do - sel[s] = s - end - elseif opts.result then - e2lib.abort("is not a result: " .. x) - else - e2lib.abort("is not a source: " .. x) + for _, x in pairs(arguments) do + if info.sources[x] and not opts.result then + e2lib.log(3, "is regarded as source: " .. x) + sel[x] = x + elseif info.results[x] and opts.result then + e2lib.log(3, "is regarded as result: " .. x) + local res = info.results[x] + for _, s in ipairs(res.sources) do + sel[s] = s + end + elseif opts.result then + e2lib.abort("is not a result: " .. x) + else + e2lib.abort("is not a source: " .. x) + end end - end elseif opts["all"] then - -- select all sources - for s,src in pairs(info.sources) do - sel[s] = s - end + -- select all sources + for s,src in pairs(info.sources) do + sel[s] = s + end end -- select all sources by scm type for s, src in pairs(info.sources) do - if select_type[src.type] then - sel[s] = s - end + if select_type[src.type] then + sel[s] = s + end end for _, s in pairs(sel) do - e2lib.logf(2, "selecting source: %s" , s) - local src = info.sources[s] - if not src then - e:append("selecting invalid source: %s", s) - end + e2lib.logf(2, "selecting source: %s" , s) + local src = info.sources[s] + if not src then + e:append("selecting invalid source: %s", s) + end end if e:getcount() > 0 then - e2lib.abort(e) + e2lib.abort(e) end if opts.chroot then - e2lib.log(2, "caching chroot files") - local rc, re = cache_chroot(info) - if not rc then - e:append("Error: Caching chroot files failed") - e:cat(re) - end + e2lib.log(2, "caching chroot files") + local rc, re = cache_chroot(info) + if not rc then + e:append("Error: Caching chroot files failed") + e:cat(re) + end end if opts.scm or opts.files or opts.git or opts.cvs or opts.svn or - opts.selection then - e2lib.log(2, "fetching sources...") - local rc, re = fetch_sources(info, opts, sel) - if not rc then - e:cat(re) - end + opts.selection then + e2lib.log(2, "fetching sources...") + local rc, re = fetch_sources(info, opts, sel) + if not rc then + e:cat(re) + end end if e:getcount() > 0 then - e2lib.abort(e) + e2lib.abort(e) end e2lib.finish() + +-- vim:sw=4:sts=4:et: diff --git a/local/ls-project.lua b/local/ls-project.lua index 7381e88..757f477 100644 --- a/local/ls-project.lua +++ b/local/ls-project.lua @@ -35,7 +35,7 @@ local e2option = require("e2option") e2lib.init() local info, re = e2tool.local_init(nil, "ls-project") if not info then - e2lib.abort(re) + e2lib.abort(re) end e2option.documentation = [[ @@ -54,145 +54,145 @@ local opts, arguments = e2option.parse(arg) info, re = e2tool.collect_project_info(info) if not info then - e2lib.abort(re) + e2lib.abort(re) end local rc, re = e2tool.check_project_info(info) if not rc then - e2lib.abort(re) + e2lib.abort(re) end local results = {} if opts.all then - for r, _ in pairs(info.results) do - table.insert(results, r) - end + for r, _ in pairs(info.results) do + table.insert(results, r) + end elseif #arguments > 0 then - for _, r in ipairs(arguments) do - if info.results[r] then - table.insert(results, r) - else - e2lib.abort(err.new("not a result: %s", r)) + for _, r in ipairs(arguments) do + if info.results[r] then + table.insert(results, r) + else + e2lib.abort(err.new("not a result: %s", r)) + end end - end end if #results > 0 then - results, re = e2tool.dlist_recursive(info, results) - if not results then - e2lib.abort(re) - end + results, re = e2tool.dlist_recursive(info, results) + if not results then + e2lib.abort(re) + end else - results, re = e2tool.dsort(info) - if not results then - e2lib.abort(re) - end + results, re = e2tool.dsort(info) + if not results then + e2lib.abort(re) + end end table.sort(results) local sources = {} if opts.all then - for s, _ in pairs(info.sources) do - table.insert(sources, s) - end -else - local yet = {} - for _, r in pairs(results) do - for _, s in ipairs(info.results[r].sources) do - if not yet[s] then + for s, _ in pairs(info.sources) do table.insert(sources, s) - yet[s] = true - end end - end +else + local yet = {} + for _, r in pairs(results) do + for _, s in ipairs(info.results[r].sources) do + if not yet[s] then + table.insert(sources, s) + yet[s] = true + end + end + end end table.sort(sources) local function pempty(s1, s2, s3) - print(string.format(" %s %s %s", s1, s2, s3)) + print(string.format(" %s %s %s", s1, s2, s3)) end local function p0(s1, s2, v) - print(string.format("%s", v)) + print(string.format("%s", v)) end local function p1(s1, s2, v) - print(string.format(" o--%s", v)) + print(string.format(" o--%s", v)) end local function p2(s1, s2, v) - print(string.format(" %s o--%s", s1, v)) + print(string.format(" %s o--%s", s1, v)) end local function p3(s1, s2, k, v) - if v then - -- remove leading spaces, that allows easier string - -- append code below, where collecting multiple items - while v:sub(1,1) == " " do + if v then + -- remove leading spaces, that allows easier string + -- append code below, where collecting multiple items + while v:sub(1,1) == " " do - v = v:sub(2) - end - print(string.format(" %s %s o--%-10s = %s", s1, s2, k, v)) - else - print(string.format(" %s %s o--%s", s1, s2, k)) - end + v = v:sub(2) + end + print(string.format(" %s %s o--%-10s = %s", s1, s2, k, v)) + else + print(string.format(" %s %s o--%s", s1, s2, k)) + end end local function p3t(s1, s2, k, t) - local col = tonumber(e2lib.globals.osenv["COLUMNS"]) - local header1 = string.format(" %s %s o--%-10s =", s1, s2, k) - local header2 = string.format(" %s %s %-10s ", s1, s2, "") - local header = header1 - local l = nil - local i = 0 - for _,v in ipairs(t) do - i = i + 1 - if l then - if (l:len() + v:len() + 1) > col then - print(l) - l = nil - end - end - if not l then - l = string.format("%s %s", header, v) - else - l = string.format("%s %s", l, v) - end - header = header2 - end - if l then - print(l) - end + local col = tonumber(e2lib.globals.osenv["COLUMNS"]) + local header1 = string.format(" %s %s o--%-10s =", s1, s2, k) + local header2 = string.format(" %s %s %-10s ", s1, s2, "") + local header = header1 + local l = nil + local i = 0 + for _,v in ipairs(t) do + i = i + 1 + if l then + if (l:len() + v:len() + 1) > col then + print(l) + l = nil + end + end + if not l then + l = string.format("%s %s", header, v) + else + l = string.format("%s %s", l, v) + end + header = header2 + end + if l then + print(l) + end end if opts.dot or opts["dot-sources"] then - local arrow = "->" - print("digraph \"" .. info.name .. "\" {") - for _, r in pairs(results) do - local res = info.results[r] - local deps = e2tool.dlist(info, r) - if #deps > 0 then - for _, dep in pairs(deps) do - if opts.swap then - print(string.format(" \"%s\" %s \"%s\"", dep, arrow, r)) + local arrow = "->" + print("digraph \"" .. info.name .. "\" {") + for _, r in pairs(results) do + local res = info.results[r] + local deps = e2tool.dlist(info, r) + if #deps > 0 then + for _, dep in pairs(deps) do + if opts.swap then + print(string.format(" \"%s\" %s \"%s\"", dep, arrow, r)) + else + print(string.format(" \"%s\" %s \"%s\"", r, arrow, dep)) + end + end else - print(string.format(" \"%s\" %s \"%s\"", r, arrow, dep)) + print(string.format(" \"%s\"", r)) + end + if opts["dot-sources"] then + for _, src in ipairs(res.sources) do + if opts.swap then + print(string.format(" \"%s-src\" %s \"%s\"", src, arrow, r)) + else + print(string.format(" \"%s\" %s \"%s-src\"", r, arrow, src)) + end + end end - end - else - print(string.format(" \"%s\"", r)) end if opts["dot-sources"] then - for _, src in ipairs(res.sources) do - if opts.swap then - print(string.format(" \"%s-src\" %s \"%s\"", src, arrow, r)) - else - print(string.format(" \"%s\" %s \"%s-src\"", r, arrow, src)) + for _, s in pairs(sources) do + print(string.format(" \"%s-src\" [label=\"%s\", shape=box]", s, s)) end - end end - end - if opts["dot-sources"] then - for _, s in pairs(sources) do - print(string.format(" \"%s-src\" [label=\"%s\", shape=box]", s, s)) - end - end - print("}") - e2lib.finish() + print("}") + e2lib.finish() end --------------- project name @@ -206,22 +206,22 @@ local s2 = "|" p1(s1, s2, "servers") local servers_sorted = info.cache:servers() for i = 1, #servers_sorted, 1 do - local ce = info.cache:ce_by_server(servers_sorted[i]) - if i < #servers_sorted then - s2 = "|" - else - s2 = " " - end - p2(s1, s2, ce.server) - p3(s1, s2, "url", ce.remote_url) - local flags = {} - for k,v in pairs(ce.flags) do - table.insert(flags, k) - end - table.sort(flags) - for _,k in ipairs(flags) do - p3(s1, s2, k, tostring(ce.flags[k])) - end + local ce = info.cache:ce_by_server(servers_sorted[i]) + if i < #servers_sorted then + s2 = "|" + else + s2 = " " + end + p2(s1, s2, ce.server) + p3(s1, s2, "url", ce.remote_url) + local flags = {} + for k,v in pairs(ce.flags) do + table.insert(flags, k) + end + table.sort(flags) + for _,k in ipairs(flags) do + p3(s1, s2, k, tostring(ce.flags[k])) + end end print(" |") @@ -231,21 +231,21 @@ local s2 = " " p1(s1, s2, "src") local len = #sources for _, s in pairs(sources) do - local src = info.sources[s] - len = len - 1 - if len == 0 then - s2 = " " - else - s2 = "|" - end - p2(s1, s2, src.name) - local t, re = scm.display(info, src.name) - if not t then - e2lib.abort(re) - end - for _,line in pairs(t) do - p3(s1, s2, line) - end + local src = info.sources[s] + len = len - 1 + if len == 0 then + s2 = " " + else + s2 = "|" + end + p2(s1, s2, src.name) + local t, re = scm.display(info, src.name) + if not t then + e2lib.abort(re) + end + for _,line in pairs(t) do + p3(s1, s2, line) + end end --------------------- results @@ -257,21 +257,21 @@ s2 = " " p1(s1, s2, "res") local len = #results for _, r in pairs(results) do - local res = info.results[r] - p2(s1, s2, r) - len = len - 1 - if len == 0 then - s2 = " " - else - s2 = "|" - end - p3t(s1, s2, "sources", res.sources) - p3t(s1, s2, "depends", res.depends) - if res.collect_project then - p3(s1, s2, "collect_project", "enabled") - p3(s1, s2, "collect_project_default_result", - res.collect_project_default_result) - end + local res = info.results[r] + p2(s1, s2, r) + len = len - 1 + if len == 0 then + s2 = " " + else + s2 = "|" + end + p3t(s1, s2, "sources", res.sources) + p3t(s1, s2, "depends", res.depends) + if res.collect_project then + p3(s1, s2, "collect_project", "enabled") + p3(s1, s2, "collect_project_default_result", + res.collect_project_default_result) + end end --------------------- licences @@ -283,15 +283,15 @@ s2 = "|" p1(s1, s2, "licences") llen = #info.licences_sorted for _,l in pairs(info.licences_sorted) do - local lic = info.licences[l] - llen = llen - 1 - if llen == 0 then - s2 = " " - end - p2(s1, s2, l) - for _,f in ipairs(lic.files) do - p3(s1, s2, "file", string.format("%s:%s", f.server, f.location)) - end + local lic = info.licences[l] + llen = llen - 1 + if llen == 0 then + s2 = " " + end + p2(s1, s2, l) + for _,f in ipairs(lic.files) do + p3(s1, s2, "file", string.format("%s:%s", f.server, f.location)) + end end --------------------- chroot @@ -304,18 +304,20 @@ local s1 = " " local s2 = "|" local len = #info.chroot.groups_sorted for _,g in ipairs(info.chroot.groups_sorted) do - local grp = info.chroot.groups_byname[g] - len = len - 1 - if len == 0 then - s2 = " " - end - p2(s1, s2, grp.name, grp.name) - for _,f in ipairs(grp.files) do - p3(s1, s2, "file", string.format("%s:%s", f.server, f.location)) - end - if grp.groupid then - p3(s1, s2, "groupid", grp.groupid) - end + local grp = info.chroot.groups_byname[g] + len = len - 1 + if len == 0 then + s2 = " " + end + p2(s1, s2, grp.name, grp.name) + for _,f in ipairs(grp.files) do + p3(s1, s2, "file", string.format("%s:%s", f.server, f.location)) + end + if grp.groupid then + p3(s1, s2, "groupid", grp.groupid) + end end e2lib.finish() + +-- vim:sw=4:sts=4:et: diff --git a/local/new-source.lua b/local/new-source.lua index caf4184..7578814 100644 --- a/local/new-source.lua +++ b/local/new-source.lua @@ -38,7 +38,7 @@ local e2option = require("e2option") e2lib.init() local info, re = e2tool.local_init(nil, "new-source") if not info then - e2lib.abort(re) + e2lib.abort(re) end e2option.documentation = [[ @@ -74,45 +74,45 @@ local opts, arguments = e2option.parse(arg) -- @return a table with fields checksum and checksum_type ("sha1", "md5") -- @return nil, or an error string on error function read_checksum(checksum_file, filename) - e2lib.log(4, string.format("read_checksum(%s, %s)", checksum_file, - filename)) - local f, e = io.open(checksum_file, "r") - if not f then - return nil, e - end - local rc = nil - local e = err.new("no checksum available") - while true do - local line = f:read() - if not line then - break - end - local c, f = line:match("(%S+) (%S+)") - if (not c) or (not f) then - e:append("Checksum file has wrong format. ") - e:append("The standard sha1sum or md5sum format is ".. - "required.") - return nil, e - end - if c and f and f == filename then - local cs = {} - cs.checksum = c - if c:len() == 40 then - cs.checksum_type = "sha1" - elseif c:len() == 32 then - cs.checksum_type = "md5" - else - rc = nil - e = "can't guess checksum type" - break - end - rc = cs - e = nil - break - end - end - f:close() - return rc, e + e2lib.log(4, string.format("read_checksum(%s, %s)", checksum_file, + filename)) + local f, e = io.open(checksum_file, "r") + if not f then + return nil, e + end + local rc = nil + local e = err.new("no checksum available") + while true do + local line = f:read() + if not line then + break + end + local c, f = line:match("(%S+) (%S+)") + if (not c) or (not f) then + e:append("Checksum file has wrong format. ") + e:append("The standard sha1sum or md5sum format is ".. + "required.") + return nil, e + end + if c and f and f == filename then + local cs = {} + cs.checksum = c + if c:len() == 40 then + cs.checksum_type = "sha1" + elseif c:len() == 32 then + cs.checksum_type = "md5" + else + rc = nil + e = "can't guess checksum type" + break + end + rc = cs + e = nil + break + end + end + f:close() + return rc, e end --- generate a sha1 checksum file @@ -121,36 +121,36 @@ end -- @return bool -- @return nil, an error string on error function write_checksum_file_sha1(source_file, checksum_file) - e2lib.log(4, string.format("write_checksum_file_sha1(%s, %s)", - source_file, checksum_file)) - local cmd = string.format("sha1sum %s > %s", - e2lib.shquote(source_file), e2lib.shquote(checksum_file)) - local rc = e2lib.callcmd_capture(cmd) - if rc ~= 0 then - return false, "error writing checksum file" - end - return true, nil + e2lib.log(4, string.format("write_checksum_file_sha1(%s, %s)", + source_file, checksum_file)) + local cmd = string.format("sha1sum %s > %s", + e2lib.shquote(source_file), e2lib.shquote(checksum_file)) + local rc = e2lib.callcmd_capture(cmd) + if rc ~= 0 then + return false, "error writing checksum file" + end + return true, nil end function download(f) - local name = e2lib.basename(f) - local cmd = string.format("curl --silent --fail %s > %s", - e2lib.shquote(f), e2lib.shquote(name)) - local rc = e2lib.callcmd_capture(cmd) - if rc ~= 0 then - return false, err.new("download failed: %s", f) - end - return true, nil + local name = e2lib.basename(f) + local cmd = string.format("curl --silent --fail %s > %s", + e2lib.shquote(f), e2lib.shquote(name)) + local rc = e2lib.callcmd_capture(cmd) + if rc ~= 0 then + return false, err.new("download failed: %s", f) + end + return true, nil end function mv(s, d) - local cmd = string.format("mv %s %s", e2lib.shquote(s), - e2lib.shquote(d)) - local rc = e2lib.callcmd_capture(cmd) - if rc ~= 0 then - return false, "mv failed" - end - return true, nil + local cmd = string.format("mv %s %s", e2lib.shquote(s), + e2lib.shquote(d)) + local rc = e2lib.callcmd_capture(cmd) + if rc ~= 0 then + return false, "mv failed" + end + return true, nil end --- new files source @@ -161,142 +161,144 @@ end -- @return bool -- @return nil, an error string on error function new_files_source(c, server, location, source_file, checksum_file, - checksum_file_format, no_checksum) - local source_file_base = e2lib.basename(source_file) - local do_checksum = (not no_checksum) - local checksum_type = "sha1" - local checksum_file_base - local checksum_file1 - local checksum_file2 = string.format("%s.%s", source_file_base, - checksum_type) - local cs1, cs2 - local rc, e - if not do_checksum then - e2lib.warn("WOTHER", "Checksum verifying is disabled!") - end - - -- change to a temporary directory - local tmpdir, e = e2lib.mktempdir() - if not e2lib.chdir(tmpdir) then - e2lib.abort("can't chdir") - end - - -- download - e2lib.log(1, string.format("fetching %s ...", source_file)) - local rc, re = download(source_file) - if not rc then - e2lib.abort(re) - end - - -- checksum checking - if do_checksum then - e2lib.log(1, string.format("fetching %s ...", checksum_file)) - local rc, re = download(checksum_file) - if not rc then - e2lib.abort(re) - end - checksum_file_base = e2lib.basename(checksum_file) - checksum_file1 = string.format("%s.orig", - checksum_file_base) - rc = mv(checksum_file_base, checksum_file1) - if not rc then - e2lib.abort(e) - end - cs1, e = read_checksum(checksum_file1, source_file_base) - if not cs1 then - e2lib.abort(e) - end - checksum_type = cs1.checksum_type - end - - -- write the checksum file to store on the server - rc = write_checksum_file_sha1(source_file_base, checksum_file2) - cs2, e = read_checksum(checksum_file2, source_file_base) - if not cs2 then - e2lib.abort(e) - end - - -- compare checksums - if do_checksum then - if cs1.checksum == cs2.checksum then - e2lib.log(2, string.format( - "checksum matches (%s): %s", - cs1.checksum_type, cs1.checksum)) - else - e2lib.abort("checksum mismatch") - end - end - - -- store - local flags = {} - local rlocation = string.format("%s/%s", location, source_file_base) - e2lib.log(1, string.format("storing file %s to %s:%s", - source_file_base, server, rlocation)) - local rc, e = cache.push_file(c, source_file_base, server, - rlocation, flags) - if not rc then - e2lib.abort(e) - end - local rlocation = string.format("%s/%s", location, checksum_file2) - e2lib.log(1, string.format("storing file %s to %s:%s", - checksum_file2, server, rlocation)) - local rc, e = cache.push_file(c, checksum_file2, server, - rlocation, flags) - if not rc then - e2lib.abort(e) - end - if not e2lib.chdir("/") then - e2lib.abort("can't chdir") - end - return true, nil + checksum_file_format, no_checksum) + local source_file_base = e2lib.basename(source_file) + local do_checksum = (not no_checksum) + local checksum_type = "sha1" + local checksum_file_base + local checksum_file1 + local checksum_file2 = string.format("%s.%s", source_file_base, + checksum_type) + local cs1, cs2 + local rc, e + if not do_checksum then + e2lib.warn("WOTHER", "Checksum verifying is disabled!") + end + + -- change to a temporary directory + local tmpdir, e = e2lib.mktempdir() + if not e2lib.chdir(tmpdir) then + e2lib.abort("can't chdir") + end + + -- download + e2lib.log(1, string.format("fetching %s ...", source_file)) + local rc, re = download(source_file) + if not rc then + e2lib.abort(re) + end + + -- checksum checking + if do_checksum then + e2lib.log(1, string.format("fetching %s ...", checksum_file)) + local rc, re = download(checksum_file) + if not rc then + e2lib.abort(re) + end + checksum_file_base = e2lib.basename(checksum_file) + checksum_file1 = string.format("%s.orig", + checksum_file_base) + rc = mv(checksum_file_base, checksum_file1) + if not rc then + e2lib.abort(e) + end + cs1, e = read_checksum(checksum_file1, source_file_base) + if not cs1 then + e2lib.abort(e) + end + checksum_type = cs1.checksum_type + end + + -- write the checksum file to store on the server + rc = write_checksum_file_sha1(source_file_base, checksum_file2) + cs2, e = read_checksum(checksum_file2, source_file_base) + if not cs2 then + e2lib.abort(e) + end + + -- compare checksums + if do_checksum then + if cs1.checksum == cs2.checksum then + e2lib.log(2, string.format( + "checksum matches (%s): %s", + cs1.checksum_type, cs1.checksum)) + else + e2lib.abort("checksum mismatch") + end + end + + -- store + local flags = {} + local rlocation = string.format("%s/%s", location, source_file_base) + e2lib.log(1, string.format("storing file %s to %s:%s", + source_file_base, server, rlocation)) + local rc, e = cache.push_file(c, source_file_base, server, + rlocation, flags) + if not rc then + e2lib.abort(e) + end + local rlocation = string.format("%s/%s", location, checksum_file2) + e2lib.log(1, string.format("storing file %s to %s:%s", + checksum_file2, server, rlocation)) + local rc, e = cache.push_file(c, checksum_file2, server, + rlocation, flags) + if not rc then + e2lib.abort(e) + end + if not e2lib.chdir("/") then + e2lib.abort("can't chdir") + end + return true, nil end info, re = e2tool.collect_project_info(info) if not info then - e2lib.abort(re) + e2lib.abort(re) end if opts.git then - if #arguments ~= 1 then - e2lib.abort(" argument required") - end - -- remote - local rserver = info.default_repo_server - if opts["server"] then - rserver = opts["server"] - end - local name = arguments[1] - local rlocation = string.format("%s/git/%s.git", info.project_location, name) - -- local - local lserver = info.root_server_name - local llocation = string.format("in/%s/.git", name) - local flags = {} - local rc, re = generic_git.new_repository(info.cache, lserver, llocation, - rserver, rlocation, flags) - if not rc then - e2lib.abort(re) - end - e2lib.log(1, + if #arguments ~= 1 then + e2lib.abort(" argument required") + end + -- remote + local rserver = info.default_repo_server + if opts["server"] then + rserver = opts["server"] + end + local name = arguments[1] + local rlocation = string.format("%s/git/%s.git", info.project_location, name) + -- local + local lserver = info.root_server_name + local llocation = string.format("in/%s/.git", name) + local flags = {} + local rc, re = generic_git.new_repository(info.cache, lserver, llocation, + rserver, rlocation, flags) + if not rc then + e2lib.abort(re) + end + e2lib.log(1, "See e2-new-source(1) to see how to go on") elseif opts.files then - local location = arguments[1] - local sl, e = e2lib.parse_server_location(location, info.default_files_server) - if not sl then - e2lib.abort(e) - end - local server = sl.server - local location = sl.location - local source_file = arguments[2] - local checksum_file = arguments[3] - local checksum_file_format = opts["checksum-file"] - local no_checksum = opts["no-checksum"] - if not no_checksum and not checksum_file then - e2lib.abort("checksum file not given") - end - local rc = new_files_source(info.cache, server, location, source_file, - checksum_file, checksum_file_format, no_checksum) + local location = arguments[1] + local sl, e = e2lib.parse_server_location(location, info.default_files_server) + if not sl then + e2lib.abort(e) + end + local server = sl.server + local location = sl.location + local source_file = arguments[2] + local checksum_file = arguments[3] + local checksum_file_format = opts["checksum-file"] + local no_checksum = opts["no-checksum"] + if not no_checksum and not checksum_file then + e2lib.abort("checksum file not given") + end + local rc = new_files_source(info.cache, server, location, source_file, + checksum_file, checksum_file_format, no_checksum) else - e2lib.log(1, "Creating repositories other than git is not supported yet.") + e2lib.log(1, "Creating repositories other than git is not supported yet.") end e2lib.finish(0) + +-- vim:sw=4:sts=4:et: diff --git a/local/playground.lua b/local/playground.lua index dc5b440..b0688e2 100644 --- a/local/playground.lua +++ b/local/playground.lua @@ -36,7 +36,7 @@ local e2option = require("e2option") e2lib.init() local info, re = e2tool.local_init(nil, "playground") if not info then - e2lib.abort(re) + e2lib.abort(re) end local e = err.new("entering playground failed") @@ -55,37 +55,37 @@ local opts, arguments = e2option.parse(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") + e2lib.abort("no build mode given") end info, re = e2tool.collect_project_info(info) if not info then - e2lib.abort(re) + e2lib.abort(re) end local rc, re = e2tool.check_project_info(info) if not rc then - e2lib.abort(re) + e2lib.abort(re) end if #arguments ~= 1 then - e2option.usage(1) + e2option.usage(1) end r = arguments[1] -- apply the standard build mode to all results for _,res in pairs(info.results) do - res.build_mode = build_mode + res.build_mode = build_mode end rc, re = e2build.build_config(info, r, {}) if not rc then - e2lib.abort(e:cat(re)) + e2lib.abort(e:cat(re)) end if not e2build.chroot_exists(info, r) then - e2lib.abort("playground does not exist") + e2lib.abort("playground does not exist") end if opts.showpath then - print(info.results[r].build_config.c) - e2lib.finish(0) + print(info.results[r].build_config.c) + e2lib.finish(0) end -- interactive mode, use bash profile local res = info.results[r] @@ -93,32 +93,34 @@ local bc = res.build_config 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)) + e2lib.abort(e:cat(msg)) end f:write(string.format("export TERM='%s'\n", e2lib.globals.osenv["TERM"])) f:write(string.format("export HOME=/root\n")) if opts.runinit then - f:write(string.format("source %s/script/%s\n", bc.Tc, bc.buildrc_file)) + f:write(string.format("source %s/script/%s\n", bc.Tc, bc.buildrc_file)) else - f:write(string.format("function runinit() { source %s/script/%s; }\n", - bc.Tc, bc.buildrc_file)) - f:write(string.format("source %s/script/%s\n", bc.Tc, - bc.buildrc_noinit_file)) + f:write(string.format("function runinit() { source %s/script/%s; }\n", + bc.Tc, bc.buildrc_file)) + f:write(string.format("source %s/script/%s\n", bc.Tc, + bc.buildrc_noinit_file)) end f:close() local command = nil if opts.command then - command = string.format("/bin/bash --rcfile '%s' -c '%s'", bc.profile, - opts.command) + command = string.format("/bin/bash --rcfile '%s' -c '%s'", bc.profile, + opts.command) else - command = string.format("/bin/bash --rcfile '%s'", bc.profile) + command = string.format("/bin/bash --rcfile '%s'", bc.profile) end e2lib.logf(2, "entering playground for %s", r) if not opts.runinit then - e2lib.log(2, "type `runinit' to run the init files") + e2lib.log(2, "type `runinit' to run the init files") end rc, re = e2build.enter_playground(info, r, command) if not rc then - e2lib.abort(re) + e2lib.abort(re) end e2lib.finish() + +-- vim:sw=4:sts=4:et: -- 2.39.5