local e2tool = require("e2tool")
local err = require("err")
-e2lib.init()
-local info, re = e2tool.local_init(nil, "build-numbers")
-if not info then
+local function e2_build_numbers(arg)
+ e2lib.init()
+ local info, re = e2tool.local_init(nil, "build-numbers")
+ if not info then
+ e2lib.abort(re)
+ end
+
+ return false, err.new("e2-build-numbers is deprecated and has been removed")
+end
+
+local rc, re = e2_build_numbers(arg)
+if not rc then
e2lib.abort(re)
end
-e2lib.abort(err.new("e2-build-numbers is deprecated and has been removed"))
+e2lib.finish(0)
-- vim:sw=4:sts=4:et:
local scm = require("scm")
local policy = require("policy")
-e2lib.init()
-local info, re = e2tool.local_init(nil, "build")
-if not info then
- e2lib.abort(re)
-end
+local function e2_build(arg)
+ e2lib.init()
+ local info, re = e2tool.local_init(nil, "build")
+ if not info then
+ e2lib.abort(re)
+ end
-e2option.flag("all", "build all results (default unless for working copy)")
-policy.register_commandline_options()
-e2option.flag("branch-mode", "build selected results in branch mode")
-e2option.flag("wc-mode", "build selected results in working-copy mode")
-e2option.flag("force-rebuild", "force rebuilding even if a result exists [broken]")
-e2option.flag("playground", "prepare environment but do not build")
-e2option.flag("keep", "do not remove chroot environment after build")
-e2option.flag("buildid", "display buildids and exit")
--- cache is not yet initialized when parsing command line options, so
--- remember settings in order of appearance, and perform settings as soon
--- as the cache is initialized.
-local writeback = {}
-local function disable_writeback(server)
- table.insert(writeback, { set = "disable", server = server })
-end
-local function enable_writeback(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))
+ e2option.flag("all", "build all results (default unless for working copy)")
+ policy.register_commandline_options()
+ e2option.flag("branch-mode", "build selected results in branch mode")
+ e2option.flag("wc-mode", "build selected results in working-copy mode")
+ e2option.flag("force-rebuild", "force rebuilding even if a result exists [broken]")
+ e2option.flag("playground", "prepare environment but do not build")
+ e2option.flag("keep", "do not remove chroot environment after build")
+ e2option.flag("buildid", "display buildids and exit")
+ -- cache is not yet initialized when parsing command line options, so
+ -- remember settings in order of appearance, and perform settings as soon
+ -- as the cache is initialized.
+ local writeback = {}
+ local function disable_writeback(server)
+ table.insert(writeback, { set = "disable", server = server })
+ end
+ local function enable_writeback(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
end
-end
-e2option.option("disable-writeback", "disable writeback for server", nil,
-disable_writeback, "SERVER")
-e2option.option("enable-writeback", "enable writeback for server", nil,
-enable_writeback, "SERVER")
+ e2option.option("disable-writeback", "disable writeback for server", nil,
+ disable_writeback, "SERVER")
+ e2option.option("enable-writeback", "enable writeback for server", nil,
+ enable_writeback, "SERVER")
-local opts, arguments = e2option.parse(arg)
+ 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")
-end
+ -- 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")
+ end
-info, re = e2tool.collect_project_info(info)
-if not info then
- e2lib.abort(re)
-end
-perform_writeback_settings(writeback)
-local rc, re = e2tool.check_project_info(info)
-if not rc then
- e2lib.abort(re)
-end
+ info, re = e2tool.collect_project_info(info)
+ if not info then
+ e2lib.abort(re)
+ end
+ perform_writeback_settings(writeback)
+ local rc, re = e2tool.check_project_info(info)
+ if not rc then
+ e2lib.abort(re)
+ end
--- apply the standard build mode to all results
-for _,res in pairs(info.results) do
- res.build_mode = build_mode
-end
+ -- apply the standard build mode to all results
+ for _,res in pairs(info.results) do
+ res.build_mode = build_mode
+ end
--- handle result selection
-local results = {}
+ -- handle result selection
+ local results = {}
-if opts["all"] and #arguments ~= 0 then
- e2lib.abort("--all with additional results does not make sense")
-elseif opts["all"] then
- 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)
+ if opts["all"] and #arguments ~= 0 then
+ e2lib.abort("--all with additional results does not make sense")
+ elseif opts["all"] then
+ 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
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)
-end
-if opts["branch-mode"] then
- -- selected results get a special build mode
- build_mode = policy.default_build_mode("branch")
-end
-if opts["wc-mode"] then
- if #results == 0 then
- e2lib.abort("--wc-mode requires one or more results")
+ -- 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)
end
- 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")
+ if opts["branch-mode"] then
+ -- selected results get a special build mode
+ build_mode = policy.default_build_mode("branch")
end
- if opts.all then
- e2lib.abort("--all and --playground are mutually exclusive")
+ if opts["wc-mode"] then
+ if #results == 0 then
+ e2lib.abort("--wc-mode requires one or more results")
+ end
+ 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
end
- if #arguments ~= 1 then
- e2lib.abort("please select one single result for the playground")
+ local force_rebuild = opts["force-rebuild"]
+ local request_buildno = opts["request-buildno"]
+ 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)
+ if not rc then
+ e2lib.abort(re)
end
-end
-local force_rebuild = opts["force-rebuild"]
-local request_buildno = opts["request-buildno"]
-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)
-if not rc then
- 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
+ else
+ local re
+ sel_res, re = e2tool.dsort(info)
+ if not sel_res then
+ e2lib.abort(re)
+ end
+ 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
+ rc, re = e2tool.print_selection(info, sel_res)
+ if not rc then
e2lib.abort(re)
end
-else
- local re
- sel_res, re = e2tool.dsort(info)
- if not sel_res then
- e2lib.abort(re)
+
+ 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.")
end
-end
-rc, re = e2tool.print_selection(info, sel_res)
-if not rc then
- e2lib.abort(re)
-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
+ 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.")
-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()
+ end
--- calculate buildids for selected results
-for _,r in ipairs(sel_res) do
- local bid, re = e2tool.buildid(info, r)
- if not bid then
+ -- build
+ local rc, re = e2build.build_results(info, sel_res)
+ if not rc 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()
+ return true
end
--- build
-local rc, re = e2build.build_results(info, sel_res)
+local rc, re = e2_build(arg)
if not rc then
e2lib.abort(re)
end
-e2lib.finish()
+
+e2lib.finish(0)
-- vim:sw=4:sts=4:et:
local err = require("err")
local e2option = require("e2option")
-e2lib.init()
-local info, re = e2tool.local_init(nil, "cf")
-if not info then
- e2lib.abort(re)
-end
-
-local opts, arguments = e2option.parse(arg)
-
--- initialize some basics in the info structure without actually loading
--- the project configuration.
-info, re = e2tool.collect_project_info(info, true)
-if not info then
- e2lib.abort(re)
-end
-
-local rc, re = e2lib.chdir(info.root)
-if not rc then
- e2lib.abort(re)
-end
-
local commands = {}
--- Start external editor.
return editor(cf)
end
-commands.editbuildscript = editbuildscript
-commands.editresult = editresult
-commands.newresult = newresult
-commands.newsource = newsource
-commands.editsource = editsource
-commands.ebuildscript = editbuildscript
-commands.eresult = editresult
-commands.nresult = newresult
-commands.nsource = newsource
-commands.esource = editsource
-
-if #arguments < 1 then
- e2option.usage(1)
-end
-
-local match = {}
-local cmd = arguments[1]
-for c,f in pairs(commands) do
- if c:match(string.format("^%s", cmd)) then
- table.insert(match, c)
+local function e2_cf(arg)
+ e2lib.init()
+ local info, re = e2tool.local_init(nil, "cf")
+ if not info then
+ e2lib.abort(re)
end
-end
-if #match == 0 then
- e2lib.abort(err.new("unknown command"))
-elseif #match == 1 then
- local a = {}
- for _,o in ipairs(arguments) do
- table.insert(a, o)
+ local opts, arguments = e2option.parse(arg)
+
+ -- initialize some basics in the info structure without actually loading
+ -- the project configuration.
+ info, re = e2tool.collect_project_info(info, true)
+ if not info then
+ e2lib.abort(re)
end
- local f = commands[match[1]]
- rc, re = f(info, a)
+
+ local rc, re = e2lib.chdir(info.root)
if not rc then
e2lib.abort(re)
end
-else
- e2lib.abort(err.new("Ambiguous command: \"%s\" matches: %s",
+
+ commands.editbuildscript = editbuildscript
+ commands.editresult = editresult
+ commands.newresult = newresult
+ commands.newsource = newsource
+ commands.editsource = editsource
+ commands.ebuildscript = editbuildscript
+ commands.eresult = editresult
+ commands.nresult = newresult
+ commands.nsource = newsource
+ commands.esource = editsource
+
+ if #arguments < 1 then
+ e2option.usage(1)
+ end
+
+ local match = {}
+ local cmd = arguments[1]
+ for c,f in pairs(commands) do
+ if c:match(string.format("^%s", cmd)) then
+ table.insert(match, c)
+ end
+ end
+
+ if #match == 0 then
+ e2lib.abort(err.new("unknown command"))
+ elseif #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
+ else
+ e2lib.abort(err.new("Ambiguous command: \"%s\" matches: %s",
cmd, table.concat(match, ', ')))
+ end
+
+ return true
+end
+
+local rc, re = e2_cf(arg)
+if not rc then
+ e2lib.abort(re)
end
e2lib.finish(0)
local e2tool = require("e2tool")
local e2option = require("e2option")
-e2lib.init()
-local info, re = e2tool.local_init(nil, "dlist")
-if not info then
- e2lib.abort(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")
-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)
-end
-
-if not info.results[ result ] then
- e2lib.abort("no such result: ", result)
+local function e2_dlist(arg)
+ e2lib.init()
+ local info, re = e2tool.local_init(nil, "dlist")
+ if not info then
+ e2lib.abort(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")
+ 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)
+ end
+
+ if not info.results[ result ] then
+ e2lib.abort("no such result: ", result)
+ 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
+
+ return true
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
+local rc, re = e2_dlist(arg)
+if not rc then
e2lib.abort(re)
end
-for i = 1, #dep do print(dep[i]) end
-
-e2lib.finish()
+e2lib.finish(0)
-- vim:sw=4:sts=4:et:
local e2tool = require("e2tool")
local e2option = require("e2option")
-e2lib.init()
-local info, re = e2tool.local_init(nil, "dsort")
-if not info then
- e2lib.abort(re)
-end
+local function e2_dsort(arg)
+ e2lib.init()
+ local info, re = e2tool.local_init(nil, "dsort")
+ if not info then
+ e2lib.abort(re)
+ end
-e2option.parse(arg)
+ e2option.parse(arg)
-info, re = e2tool.collect_project_info(info)
-if not info then
- e2lib.abort(re)
+ info, re = e2tool.collect_project_info(info)
+ if not info then
+ e2lib.abort(re)
+ end
+
+ local d = e2tool.dsort(info)
+ if d then
+ for i = 1, #d do print(d[i]) end
+ end
+
+ return true
end
-local d = e2tool.dsort(info)
-if d then
- for i = 1, #d do print(d[i]) end
+local rc, re = e2_dsort(arg)
+if not rc then
+ e2lib.abort(re)
end
-e2lib.finish()
+e2lib.finish(0)
-- vim:sw=4:sts=4:et:
local e2option = require("e2option")
local scm = require("scm")
-e2lib.init()
-local info, re = e2tool.local_init(nil, "fetch-sources")
-if not info then
- e2lib.abort(re)
-end
+local function e2_fetch_source(arg)
+ e2lib.init()
+ local info, re = e2tool.local_init(nil, "fetch-sources")
+ if not info then
+ e2lib.abort(re)
+ end
-local e = err.new()
-
-e2option.flag("all", "select all sources, even files sources")
-e2option.flag("chroot", "select chroot files")
-e2option.flag("files", "select files sources")
-e2option.flag("scm", "select all scm sources")
-e2option.flag("git", "select scm sources")
-e2option.flag("cvs", "select cvs sources")
-e2option.flag("svn", "select svn sources")
-e2option.flag("fetch", "fetch selected sources (default)")
-e2option.flag("update", "update selected source")
-e2option.flag("source", "select sources by source names (default)")
-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)
-end
-local rc, re = e2tool.check_project_info(info)
-if not rc then
- e2lib.abort(e:cat(re))
-end
+ local e = err.new()
+
+ e2option.flag("all", "select all sources, even files sources")
+ e2option.flag("chroot", "select chroot files")
+ e2option.flag("files", "select files sources")
+ e2option.flag("scm", "select all scm sources")
+ e2option.flag("git", "select scm sources")
+ e2option.flag("cvs", "select cvs sources")
+ e2option.flag("svn", "select svn sources")
+ e2option.flag("fetch", "fetch selected sources (default)")
+ e2option.flag("update", "update selected source")
+ e2option.flag("source", "select sources by source names (default)")
+ 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)
+ end
+ local rc, re = e2tool.check_project_info(info)
+ if not rc then
+ e2lib.abort(e:cat(re))
+ end
-if not (opts.fetch or opts.update) then
- 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")
-end
-if #arguments > 0 then
- 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
-end
-if opts.scm then
- opts.git = true
- opts.cvs = true
- opts.svn = true
-end
-local select_type = {}
-if opts["git"] then
- select_type["git"] = true
-end
-if opts["svn"] then
- select_type["svn"] = true
-end
-if opts["cvs"] then
- select_type["cvs"] = true
-end
-if opts["files"] then
- select_type["files"] = true
-end
+ if not (opts.fetch or opts.update) then
+ 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")
+ end
+ if #arguments > 0 then
+ 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
+ end
+ if opts.scm then
+ opts.git = true
+ opts.cvs = true
+ opts.svn = true
+ end
+ local select_type = {}
+ if opts["git"] then
+ select_type["git"] = true
+ end
+ if opts["svn"] then
+ select_type["svn"] = true
+ end
+ if opts["cvs"] then
+ select_type["cvs"] = true
+ end
+ if opts["files"] then
+ select_type["files"] = true
+ end
---- cache chroot files
--- @param info the info table
--- @return bool
--- @return nil, an error string on error
-local 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"
+ --- cache chroot files
+ -- @param info the info table
+ -- @return bool
+ -- @return nil, an error string on error
+ local 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
end
end
+ return true, nil
end
- return true, nil
-end
---- fetch and upgrade sources
--- @param info the info table
--- @param opts the option table
--- @param sel table of selected results
--- @return bool
--- @return nil, an error string on error
-local 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
-
- -- 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.logf(1,
+ --- fetch and upgrade sources
+ -- @param info the info table
+ -- @param opts the option table
+ -- @param sel table of selected results
+ -- @return bool
+ -- @return nil, an error string on error
+ local 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
+
+ -- 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.logf(1,
"working copy for %s is already available", s.name)
- else
- e2lib.logf(1, "fetching working copy for source %s", s.name)
- local rc, re = scm.fetch_source(info, s.name)
- if not rc then
- e:cat(re)
+ else
+ e2lib.logf(1, "fetching working copy for source %s", s.name)
+ local rc, re = scm.fetch_source(info, s.name)
+ if not rc then
+ e:cat(re)
+ 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.logf(1, "working copy for %s is not available", s.name)
- else
- e2lib.logf(1, "updating working copy for %s", s.name)
- local rc, re = scm.update(info, s.name)
- if not rc then
- 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.logf(1, "working copy for %s is not available", s.name)
+ else
+ e2lib.logf(1, "updating working copy for %s", s.name)
+ local rc, re = scm.update(info, s.name)
+ if not rc then
+ e:cat(re)
+ 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
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
-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.logf(3, "is regarded as source: %s", x)
- sel[x] = x
- elseif info.results[x] and opts.result then
- e2lib.logf(3, "is regarded as result: %s", x)
- local res = info.results[x]
- for _, s in ipairs(res.sources) do
- sel[s] = s
+ local sel = {} -- selected sources
+
+ if #arguments > 0 then
+ for _, x in pairs(arguments) do
+ if info.sources[x] and not opts.result then
+ e2lib.logf(3, "is regarded as source: %s", x)
+ sel[x] = x
+ elseif info.results[x] and opts.result then
+ e2lib.logf(3, "is regarded as result: %s", 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
- elseif opts.result then
- e2lib.abort("is not a result: " .. x)
- else
- e2lib.abort("is not a source: " .. x)
+ end
+ elseif opts["all"] then
+ -- select all sources
+ for s,src in pairs(info.sources) do
+ sel[s] = s
end
end
-elseif opts["all"] then
- -- 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
+ -- select all sources by scm type
+ for s, src in pairs(info.sources) do
+ if select_type[src.type] then
+ sel[s] = s
+ end
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)
+ 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
+ end
+ if e:getcount() > 0 then
+ e2lib.abort(e)
end
-end
-if e:getcount() > 0 then
- 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)
+ 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
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)
+ 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
+ end
+
+ if e:getcount() > 0 then
+ e2lib.abort(e)
end
+
+ return true
end
-if e:getcount() > 0 then
- e2lib.abort(e)
+local rc, re = e2_fetch_source(arg)
+if not rc then
+ e2lib.abort(re)
end
-e2lib.finish()
+e2lib.finish(0)
-- vim:sw=4:sts=4:et:
if not rc then
e2lib.abort(re)
end
+
e2lib.finish(0)
-- vim:sw=4:sts=4:et:
local scm = require("scm")
local policy = require("policy")
-e2lib.init()
-local info, re = e2tool.local_init(nil, "ls-project")
-if not info then
- e2lib.abort(re)
-end
-
-policy.register_commandline_options()
-e2option.flag("dot", "generate dot(1) graph")
-e2option.flag("dot-sources", "generate dot(1) graph with sources included")
-e2option.flag("swap", "swap arrow directions in dot graph")
-e2option.flag("all", "show unused results and sources, too")
+local function e2_ls_project(arg)
+ e2lib.init()
+ local info, re = e2tool.local_init(nil, "ls-project")
+ if not info then
+ e2lib.abort(re)
+ end
-local opts, arguments = e2option.parse(arg)
+ policy.register_commandline_options()
+ e2option.flag("dot", "generate dot(1) graph")
+ e2option.flag("dot-sources", "generate dot(1) graph with sources included")
+ e2option.flag("swap", "swap arrow directions in dot graph")
+ e2option.flag("all", "show unused results and sources, too")
-info, re = e2tool.collect_project_info(info)
-if not info then
- e2lib.abort(re)
-end
-local rc, re = e2tool.check_project_info(info)
-if not rc then
- e2lib.abort(re)
-end
+ local opts, arguments = e2option.parse(arg)
-local results = {}
-if opts.all then
- 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))
- end
- end
-end
-if #results > 0 then
- results, re = e2tool.dlist_recursive(info, results)
- if not results then
+ info, re = e2tool.collect_project_info(info)
+ if not info then
e2lib.abort(re)
end
-else
- results, re = e2tool.dsort(info)
- if not results then
+ local rc, re = e2tool.check_project_info(info)
+ if not rc 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
- table.insert(sources, s)
- yet[s] = true
+ local results = {}
+ if opts.all then
+ 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))
end
end
end
-end
-table.sort(sources)
-
-local function pempty(s1, s2, s3)
- print(string.format(" %s %s %s", s1, s2, s3))
-end
-local function p0(s1, s2, v)
- print(string.format("%s", v))
-end
-local function p1(s1, s2, v)
- print(string.format(" o--%s", v))
-end
-local function p2(s1, s2, 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
-
- v = v:sub(2)
+ if #results > 0 then
+ results, re = e2tool.dlist_recursive(info, results)
+ if not results then
+ e2lib.abort(re)
end
- print(string.format(" %s %s o--%-10s = %s", s1, s2, k, v))
else
- print(string.format(" %s %s o--%s", s1, s2, k))
+ results, re = e2tool.dsort(info)
+ if not results then
+ e2lib.abort(re)
+ end
end
-end
+ table.sort(results)
-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
+ local sources = {}
+ if opts.all then
+ for s, _ in pairs(info.sources) do
+ table.insert(sources, s)
end
- if not l then
- l = string.format("%s %s", header, v)
- else
- l = string.format("%s %s", l, v)
+ 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
- header = header2
end
- if l then
- print(l)
+ table.sort(sources)
+
+ local function pempty(s1, s2, s3)
+ print(string.format(" %s %s %s", s1, s2, s3))
end
-end
+ local function p0(s1, s2, v)
+ print(string.format("%s", v))
+ end
+ local function p1(s1, s2, v)
+ print(string.format(" o--%s", v))
+ end
+ local function p2(s1, s2, 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 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))
- else
- print(string.format(" \"%s\" %s \"%s\"", r, arrow, dep))
- end
+ v = v:sub(2)
end
+ print(string.format(" %s %s o--%-10s = %s", s1, s2, k, v))
else
- print(string.format(" \"%s\"", r))
+ print(string.format(" %s %s o--%s", s1, s2, k))
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
+
+ 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
end
- if opts["dot-sources"] then
- for _, s in pairs(sources) do
- print(string.format(" \"%s-src\" [label=\"%s\", shape=box]", s, s))
+
+ 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))
+ else
+ print(string.format(" \"%s\" %s \"%s\"", r, arrow, dep))
+ 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))
+ 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()
end
- print("}")
- e2lib.finish()
-end
---------------- project name
-local s1 = "|"
-local s2 = "|"
-p0(s1, s2, info.name)
+ --------------- project name
+ local s1 = "|"
+ local s2 = "|"
+ p0(s1, s2, info.name)
---------------- servers
-local s1 = "|"
-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]))
+ --------------- servers
+ local s1 = "|"
+ 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
end
-end
-print(" |")
+ print(" |")
---------------------- sources
-local s1 = "|"
-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)
+ --------------------- sources
+ local s1 = "|"
+ 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
end
-end
---------------------- results
-local s1 = "|"
-local s2 = " "
-local s3 = " "
-pempty(s1, s2, s3)
-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)
+ --------------------- results
+ local s1 = "|"
+ local s2 = " "
+ local s3 = " "
+ pempty(s1, s2, s3)
+ 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
end
-end
---------------------- licences
-local s1 = "|"
-local s2 = " "
-local s3 = " "
-pempty(s1, s2, s3)
-s2 = "|"
-p1(s1, s2, "licences")
-local 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 = " "
+ --------------------- licences
+ local s1 = "|"
+ local s2 = " "
+ local s3 = " "
+ pempty(s1, s2, s3)
+ s2 = "|"
+ p1(s1, s2, "licences")
+ local 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
end
- p2(s1, s2, l)
- for _,f in ipairs(lic.files) do
- p3(s1, s2, "file", string.format("%s:%s", f.server, f.location))
+
+ --------------------- chroot
+ local s1 = "|"
+ local s2 = " "
+ local s3 = " "
+ pempty(s1, s2, s3)
+ p1(s1, s2, "chroot groups")
+ 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
end
+
+ return true
end
---------------------- chroot
-local s1 = "|"
-local s2 = " "
-local s3 = " "
-pempty(s1, s2, s3)
-p1(s1, s2, "chroot groups")
-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 rc, re = e2_ls_project(arg)
+if not rc then
+ e2lib.abort(re)
end
-e2lib.finish()
+e2lib.finish(0)
-- vim:sw=4:sts=4:et:
local digest = require("digest")
local url = require("url")
-
-e2lib.init()
-local info, re = e2tool.local_init(nil, "new-source")
-if not info then
- e2lib.abort(re)
-end
-
-e2option.flag("git", "create a git repository")
-e2option.flag("files", "create a new file on a files server")
-e2option.option("server", "specify server")
-e2option.flag("no-checksum", "do not verify checksum file")
-local opts, arguments = e2option.parse(arg)
-
--- Download a file.
-- @param f string: url or path to file.
-- @return temporary filename or false.
return true
end
-info, re = e2tool.collect_project_info(info)
-if not info then
- e2lib.abort(re)
-end
-
-if opts.git then
- if #arguments ~= 1 then
- e2lib.abort("<name> 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
+local function e2_new_source(arg)
+ e2lib.init()
+ local info, re = e2tool.local_init(nil, "new-source")
+ if not info then
e2lib.abort(re)
end
- e2lib.log(1, "Read e2-new-source(1) for the next step")
-elseif opts.files then
- if #arguments < 2 or #arguments > 3 then
- e2option.usage(1)
- end
- 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 verify = not opts["no-checksum"]
- if verify and not checksum_file then
- e2lib.abort("checksum file argument missing")
- end
+ e2option.flag("git", "create a git repository")
+ e2option.flag("files", "create a new file on a files server")
+ e2option.option("server", "specify server")
+ e2option.flag("no-checksum", "do not verify checksum file")
+ local opts, arguments = e2option.parse(arg)
- local rc, re = new_files_source(info.cache, server, location, source_file,
- checksum_file, verify)
- if not rc then
+ info, re = e2tool.collect_project_info(info)
+ if not info then
e2lib.abort(re)
end
-else
- e2lib.abort(err.new("Please specify either --files are --git"))
+
+ if opts.git then
+ if #arguments ~= 1 then
+ e2lib.abort("<name> 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, "Read e2-new-source(1) for the next step")
+ elseif opts.files then
+ if #arguments < 2 or #arguments > 3 then
+ e2option.usage(1)
+ end
+
+ 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 verify = not opts["no-checksum"]
+ if verify and not checksum_file then
+ e2lib.abort("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)
+ end
+ else
+ e2lib.abort(err.new("Please specify either --files are --git"))
+ end
+
+ return true
+end
+
+local rc, re = e2_new_source(arg)
+if not rc then
+ e2lib.abort(re)
end
e2lib.finish(0)
local e2option = require("e2option")
local policy = require("policy")
-e2lib.init()
-local info, re = e2tool.local_init(nil, "playground")
-if not info then
- e2lib.abort(re)
+local function e2_playground(arg)
+ e2lib.init()
+ local info, re = e2tool.local_init(nil, "playground")
+ if not info then
+ e2lib.abort(re)
+ end
+
+ local e = err.new("entering playground failed")
+ local rc, re
+
+ e2option.option("command","execute command in chroot")
+ e2option.flag("runinit","run init files automatically")
+ e2option.flag("showpath", "prints the path of the build directory inside the chroot to stdout" )
+
+ 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")
+ end
+ info, re = e2tool.collect_project_info(info)
+ if not info then
+ e2lib.abort(re)
+ end
+ local rc, re = e2tool.check_project_info(info)
+ if not rc then
+ e2lib.abort(re)
+ end
+
+ if #arguments ~= 1 then
+ e2option.usage(1)
+ end
+
+ local r = arguments[1]
+
+ -- apply the standard build mode to all results
+ for _,res in pairs(info.results) do
+ res.build_mode = build_mode
+ end
+ rc, re = e2build.build_config(info, r, {})
+ if not rc then
+ e2lib.abort(e:cat(re))
+ end
+ if not e2build.chroot_exists(info, r) then
+ e2lib.abort("playground does not exist")
+ end
+ if opts.showpath then
+ print(info.results[r].build_config.c)
+ e2lib.finish(0)
+ end
+ -- interactive mode, use bash profile
+ local res = info.results[r]
+ 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))
+ 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))
+ 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))
+ end
+ f:close()
+ local command = nil
+ if opts.command then
+ command = string.format("/bin/bash --rcfile '%s' -c '%s'", bc.profile,
+ opts.command)
+ else
+ 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")
+ end
+ rc, re = e2build.enter_playground(info, r, command)
+ if not rc then
+ e2lib.abort(re)
+ end
+
+ return true
end
-local e = err.new("entering playground failed")
-local rc, re
-
-e2option.option("command","execute command in chroot")
-e2option.flag("runinit","run init files automatically")
-e2option.flag("showpath", "prints the path of the build directory inside the chroot to stdout" )
-
-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")
-end
-info, re = e2tool.collect_project_info(info)
-if not info then
- e2lib.abort(re)
-end
-local rc, re = e2tool.check_project_info(info)
+local rc, re = e2_playground(arg)
if not rc then
e2lib.abort(re)
end
-if #arguments ~= 1 then
- e2option.usage(1)
-end
-
-local r = arguments[1]
-
--- apply the standard build mode to all results
-for _,res in pairs(info.results) do
- res.build_mode = build_mode
-end
-rc, re = e2build.build_config(info, r, {})
-if not rc then
- e2lib.abort(e:cat(re))
-end
-if not e2build.chroot_exists(info, r) then
- e2lib.abort("playground does not exist")
-end
-if opts.showpath then
- print(info.results[r].build_config.c)
- e2lib.finish(0)
-end
--- interactive mode, use bash profile
-local res = info.results[r]
-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))
-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))
-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))
-end
-f:close()
-local command = nil
-if opts.command then
- command = string.format("/bin/bash --rcfile '%s' -c '%s'", bc.profile,
- opts.command)
-else
- 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")
-end
-rc, re = e2build.enter_playground(info, r, command)
-if not rc then
- e2lib.abort(re)
-end
-e2lib.finish()
+e2lib.finish(0)
-- vim:sw=4:sts=4:et: