require("e2lib")
local transport = require("transport")
local url = require("url")
+local err = require("err")
--- cache
-- @class table
((remote_url and flags) and (alias_server and alias_location)))
local ru, cu
local rc, re
- local e = new_error("error setting up cache entry")
+ local e = err.new("error setting up cache entry")
local ce = {}
local cache_url = nil
if not remote_url then
return ce, nil
end
end
- return nil, new_error("no cache entry for url: %s", url)
+ return nil, err.new("no cache entry for url: %s", url)
end
--- get cache entry by server
return ce, nil
end
end
- return nil, new_error("no cache entry for server: %s", server)
+ return nil, err.new("no cache entry for server: %s", server)
end
--- check if server is valid
if cache.ce_by_server(c, server) then
return true
else
- return false, new_error("not a valid server: %s", server)
+ return false, err.new("not a valid server: %s", server)
end
end
-- @return an error object on failure
function cache.fetch_file(c, server, location, destdir, destname, flags)
local rc, re
- local e = new_error("cache: fetching file failed")
+ local e = err.new("cache: fetching file failed")
local ce, re = cache.ce_by_server(c, server)
if not ce then
return false, e:cat(re)
-- @return an error object on failure
function cache.push_file(c, sourcefile, server, location, flags)
local rc, re
- local e = new_error("error pushing file to cache/server")
+ local e = err.new("error pushing file to cache/server")
local ce, re = cache.ce_by_server(c, server)
if not ce then
return false, e:cat(re)
-- @return bool
-- @return an error object on failure
function cache.writeback(c, server, location, flags)
- local e = new_error("writeback failed")
+ local e = err.new("writeback failed")
local rc, re
local ce, re = cache.ce_by_server(c, server)
if not ce then
-- @return bool
-- @return an error object on failure
function cache.cache_file(c, server, location, flags)
- local e = new_error("caching file failed: %s:%s", server, location)
+ local e = err.new("caching file failed: %s:%s", server, location)
local rc, re
local ce, re = cache.ce_by_server(c, server)
if not ce then
-- @return an error object on failure
function cache.file_path(c, server, location, flags)
local rc, re
- local e = new_error("providing file path failed")
+ local e = err.new("providing file path failed")
-- get the cache entry
local ce, re = cache.ce_by_server(c, server)
if not ce then
-- @return an error object on failure
function cache.set_writeback(c, server, value)
if type(value) ~= "boolean" then
- return false, new_error(
+ return false, err.new(
"cache.set_writeback(): value is not boolean")
end
local rc, re = cache.valid_server(c, server)
require("strict")
require("buildconfig")
local lock = require("lock")
-require("err")
+local err = require("err")
require("plugin")
local tools = require("tools")
local cache = require("cache")
function init2()
local rc, re
- local e = new_error("initializing globals (step2)")
+ local e = err.new("initializing globals (step2)")
-- get the global configuration
local config = get_global_config()
end
function rotate_log(file)
- local e = new_error("rotating logfile: %s", file)
+ local e = err.new("rotating logfile: %s", file)
local rc, re
local logdir = dirname(file)
local logfile = basename(file)
elseif filename:match("tar$") then
tartype = "tar"
else
- e = new_error("unknown suffix for filename: %s", filename)
+ e = err.new("unknown suffix for filename: %s", filename)
return false, e
end
return tartype
function read_line(path)
local f, msg = io.open(path)
if not f then
- return nil, new_error("%s", msg)
+ return nil, err.new("%s", msg)
end
local l, msg = f:read("*l")
if not l then
- return nil, new_error("%s", msg)
+ return nil, err.new("%s", msg)
end
f:close()
return l
end
function write_extension_config(extensions)
- local e = new_error("writing extensions config: %s", globals.extension_config)
+ local e = err.new("writing extensions config: %s", globals.extension_config)
local f, re = io.open(globals.extension_config, "w")
if not f then
return false, e:cat(re)
-- @return the extension configuration table
-- @return an error object on failure
function read_extension_config()
- local e = new_error("reading extension config file: %s",
+ local e = err.new("reading extension config file: %s",
globals.extension_config)
local rc = e2util.exists(globals.extension_config)
if not rc then
end
function dofile2(path, gtable)
- local e = new_error("error loading config file: %s", path)
+ local e = err.new("error loading config file: %s", path)
local chunk, msg = loadfile(path)
if not chunk then
return false, e:cat(msg)
function locate_project_root(path)
local rc, re
- local e = new_error("checking for project directory failed")
+ local e = err.new("checking for project directory failed")
local save_path = e2util.cwd()
if not save_path then
return nil, e:append("cannot get current working directory")
end
end
chdir(save_path)
- return nil, new_error("not in a project directory")
+ return nil, err.new("not in a project directory")
end
-- parse version files:
-- @return an error object on failure
function git(gitdir, subtool, args)
local rc, re
- local e = new_error("calling git failed")
+ local e = err.new("calling git failed")
if not gitdir then
gitdir = ".git"
end
function sha1sum(path)
assert(type(path) == "string")
- local e = new_error("calculating SHA1 checksum failed")
+ local e = err.new("calculating SHA1 checksum failed")
local sha1sum, re = tools.get_tool("sha1sum")
if not sha1sum then
-- @return an error object on failure
function get_sys_arch()
local rc, re
- local e = new_error("getting host system architecture failed")
+ local e = err.new("getting host system architecture failed")
local uname = tools.get_tool("uname")
local cmd = string.format("%s -m", e2lib.shquote(uname))
local p, msg = io.popen(cmd, "r")
function read_file(file)
local f, msg = io.open(file, "r")
if not f then
- return nil, new_error("%s", msg)
+ return nil, err.new("%s", msg)
end
local s, msg = f:read("*a")
if not s then
- return nil, new_error("%s", msg)
+ return nil, err.new("%s", msg)
end
f:close()
return s, nil
-- @return string: the file content
-- @return an error object on failure
function read_template(file)
- local e = new_error("error reading template file")
+ local e = err.new("error reading template file")
local filename = string.format("%s/%s", globals.template_path, file)
local template, re = read_file(filename)
if not template then
-- @return a cache object
-- @return an error object on failure
function setup_cache()
- local e = new_error("setting up cache failed")
+ local e = err.new("setting up cache failed")
local config = get_global_config()
if type(config.cache) ~= "table" or type(config.cache.path) ~= "string" then
return false, e:append("invalid cache configuration: config.cache.path")
local rc, re
rc, re = e2util.cd(path)
if not rc then
- return false, new_error("chdir %s failed: %s", path, re)
+ return false, err.new("chdir %s failed: %s", path, re)
end
return true, nil
end
require("e2util")
require("collection")
require("plugin")
+local err = require("err")
-- Parsing of command-line options
-- @return nil
function flag(name, doc, func, category)
if options[ name ] then
- return false, new_error("option exists: %s", name)
+ return false, err.new("option exists: %s", name)
end
options[ name ] = {type = "flag", documentation = doc or "", name = name,
proc=func, default = true,
-- @return nil
function option(name, doc, default, func, argname)
if options[ name ] then
- return false, new_error("option exists: %s", name)
+ return false, err.new("option exists: %s", name)
end
options[ name ] = {type = "option", documentation = doc or "", name = name,
proc=func, default=default or true,
local cache = require("cache")
local url = require("url")
local tools = require("tools")
+local err = require("err")
--- clone a git repository
-- @param surl url to the server
e2lib.abort("git_clone_url1(): missing parameter")
end
local rc, re
- local e = new_error("cloning git repository")
+ local e = err.new("cloning git repository")
local full_url = string.format("%s/%s", surl, location)
local u, re = url.parse(full_url)
if not u then
e2lib.shquote(start_point))
local rc = e2lib.callcmd_capture(cmd)
if rc ~= 0 then
- return false, new_error("creating new branch failed")
+ return false, err.new("creating new branch failed")
end
return true, nil
end
e2lib.shquote(branch))
local rc = e2lib.callcmd_capture(cmd)
if rc ~= 0 then
- return false, new_error("git checkout failed")
+ return false, err.new("git checkout failed")
end
return true, nil
end
function generic_git.git_rev_list1(gitdir, ref)
e2lib.log(4, string.format("git_rev_list(): %s %s",
tostring(gitdir), tostring(ref)))
- local e = new_error("git rev-list failed")
+ local e = err.new("git rev-list failed")
local rc, re
local tmpfile = e2lib.mktempfile()
local args = string.format("--max-count=1 '%s' -- >'%s'", ref, tmpfile)
f:close()
e2lib.rmtempfile(tmpfile)
if (not rev) or (not rev:match("^%S+$")) then
- return nil, new_error("can't parse git rev-list output")
+ return nil, err.new("can't parse git rev-list output")
end
if rev then
e2lib.log(4, string.format("git_rev_list: %s", rev))
if (not rurl) then
e2lib.abort("git_init_db1(): missing parameter")
end
- local e = new_error("running git_init_db")
+ local e = err.new("running git_init_db")
local rc, re
local u, re = url.parse(rurl)
if not u then
e2lib.abort("git_push1(): missing parameter")
end
local rc, re
- local e = new_error("git push failed")
+ local e = err.new("git push failed")
local u, re = url.parse(rurl)
if not u then
return false, e:cat(re)
e2lib.abort("missing parameter")
end
local rc, re
- local e = new_error("git remote-add failed")
+ local e = err.new("git remote-add failed")
local lrepo, re = url.parse(lurl)
if not lrepo then
return false, e:cat(re)
elseif u.transport == "file" then
giturl = string.format("/%s", u.path)
else
- return nil, new_error("transport not supported: %s", u.transport)
+ return nil, err.new("transport not supported: %s", u.transport)
end
return giturl, nil
end
function generic_git.git_clone_from_server(c, server, location, destdir,
skip_checkout)
local rc, re
- local e = new_error("cloning git repository")
+ local e = err.new("cloning git repository")
local surl, re = cache.remote_url(c, server, location)
if not surl then
return false, e:cat(re)
-- @return an error object on failure
function generic_git.git_init_db(c, server, location)
local rc, re
- local e = new_error("initializing git repository")
+ local e = err.new("initializing git repository")
local rurl, re = cache.remote_url(c, server, location)
if not rurl then
return false, e:cat(re)
-- @return an error object on failure
function generic_git.git_push(c, gitdir, server, location, refspec)
local rc, re
- local e = new_error("git push failed")
+ local e = err.new("git push failed")
local rurl, re = cache.remote_url(c, server, location)
if not rurl then
return false, e:cat(re)
-- @return an error object on failure
function generic_git.git_config(gitdir, query)
local rc, re
- local e = new_error("running git config")
+ local e = err.new("running git config")
local tmpfile = e2lib.mktempfile()
local cmd = string.format("GIT_DIR=%s git config %s > %s",
e2lib.shquote(gitdir), e2lib.shquote(query), e2lib.shquote(tmpfile))
-- @return an error object on failure
function generic_git.git_add(gitdir, args)
local rc, re
- local e = new_error("running git add")
+ local e = err.new("running git add")
if not gitdir then
gitdir = ".git"
end
-- @return an error object on failure
function generic_git.git_commit(gitdir, args)
local rc, re
- local e = new_error("git commit failed")
+ local e = err.new("git commit failed")
return e2lib.git("commit", gitdir, args)
end
function generic_git.verify_remote_tag(gitdir, tag)
e2lib.logf(4, "generic_git.verify_remote_tag(%s, %s)", tostring(gitdir),
tostring(tag))
- local e = new_error("verifying remote tag")
+ local e = err.new("verifying remote tag")
local rc, re
-- fetch the remote tag
tag, rtag)
rc, re = e2lib.git(gitdir, "fetch", args)
if not rc then
- return false, new_error("remote tag is not available: %s", tag)
+ return false, err.new("remote tag is not available: %s", tag)
end
-- store commit ids for use in the error message, if any
function generic_git.verify_clean_repository(gitwc)
e2lib.logf(4, "generic_git.verify_clean_repository(%s)", tostring(gitwc))
gitwc = gitwc or "."
- local e = new_error("verifying that repository is clean")
+ local e = err.new("verifying that repository is clean")
local rc, re
local tmp = e2lib.mktempfile()
rc, re = e2lib.chdir(gitwc)
if #files > 0 then
local msg = "the following files are not checked into the repository:\n"
msg = msg .. files
- return false, new_error("%s", msg)
+ return false, err.new("%s", msg)
end
-- verify that the working copy matches HEAD
local args = string.format("--name-only HEAD >%s", tmp)
if #files > 0 then
msg = "the following files are modified:\n"
msg = msg..files
- return false, new_error("%s", msg)
+ return false, err.new("%s", msg)
end
-- verify that the index matches HEAD
local args = string.format("--name-only --cached HEAD >%s", tmp)
if #files > 0 then
msg = "the following files in index are modified:\n"
msg = msg..files
- return false, new_error("%s", msg)
+ return false, err.new("%s", msg)
end
return true
end
tostring(verify_tag))
assert(verify_tag)
gitwc = gitwc or "."
- local e = new_error("verifying that HEAD matches 'refs/tags/%s'", verify_tag)
+ local e = err.new("verifying that HEAD matches 'refs/tags/%s'", verify_tag)
local rc, re
local tmp = e2lib.mktempfile()
local args = string.format("--tags --match '%s' >%s", verify_tag, tmp)
-- @return nil, or an error string on error
function generic_git.new_repository(c, lserver, llocation, rserver, rlocation, flags)
local rc, re
- local e = new_error("setting up new git repository failed")
+ local e = err.new("setting up new git repository failed")
local lserver_url, re = cache.remote_url(c, lserver, llocation)
if not lserver_url then
return false, e:cat(re)
local hash = {}
require("sha1")
+local err = require("err")
--- create a hash context
-- @return a hash context object, or nil on error
local fd = io.open(path, "r")
if not fd then
- return nil, new_error("could not open file '%s'", path)
+ return nil, err.new("could not open file '%s'", path)
end
local buf = ""
-- Remaining lock directories can be removed by calling the cleanup
-- method.
local lock = {}
+local err = require("err")
--- create a new lock context
-- @return table: the lock context
-- @param dir string: lock directory
-- @return boolean
function lock.lock(l, dir)
- local e = new_error("locking failed")
+ local e = err.new("locking failed")
local rc, re = e2lib.mkdir(dir)
if not rc then
-- @param dir string: lock directory
-- @return boolean
function lock.unlock(l, dir)
- local e = new_error("unlocking failed")
+ local e = err.new("unlocking failed")
local rc, re
for i,x in ipairs(l.locks) do
local test=false
if test then
-- some dummy functions to test without context...
- function new_error(x)
+ function err.new(x)
return true
end
e2lib = {}
module("plugin", package.seeall)
+local err = require("err")
--- plugin descriptor
-- @class table
-- @return bool
-- @return an error object on failure
local function load_plugin(dir, p, ctx)
- local e = new_error("loading plugin failed: %s", p)
+ local e = err.new("loading plugin failed: %s", p)
local plugin_file = string.format("%s/%s", dir, p)
local chunk, msg = loadfile(plugin_file)
if not chunk then
-- @return bool
-- @return an error object on failure
function load_plugins(dir, ctx)
- local e = new_error("loading plugins failed")
+ local e = err.new("loading plugins failed")
e2lib.logf(4, "loading plugins from: %s", dir)
for p in e2lib.directory(dir) do
local rc, re = load_plugin(dir, p, ctx)
-- @return bool
-- @return an error object on failure
function init_plugins()
- local e = new_error("initializing plugins failed")
+ local e = err.new("initializing plugins failed")
for _, pd in ipairs(plugins) do
local rc, re = init_plugin(pd)
if not rc then
-- @return bool
-- @return an error object on failure
function exit_plugins()
- local e = new_error("deinitializing plugins failed")
+ local e = err.new("deinitializing plugins failed")
for _, pd in ipairs(plugins) do
local rc, re = exit_plugin(pd)
if not rc then
local transport = {}
local url = require("url")
local tools = require("tools")
+local err = require("err")
--- call rsync with appropriate rsh argument according to the tools
-- configuration
local rc, re = rsync_ssh(argv, emptydir .. "/", dest)
if not rc then
e2lib.rmtempdir(emptydir)
- local e = new_error("could not create remote directory")
+ local e = err.new("could not create remote directory")
return false, e:cat(re)
end
end
destname = e2lib.basename(location)
end
local rc, re
- local e = new_error("transport: fetching file failed")
+ local e = err.new("transport: fetching file failed")
local u, re = url.parse(surl)
if not u then
return false, e:cat(re)
e2lib.log(4, string.format("%s: %s %s %s %s", "transport.push_file()",
sourcefile, durl, location, tostring(push_permissions)))
local rc, e
- e = new_error("error pushing file to server")
+ e = err.new("error pushing file to server")
durl = string.format("%s/%s", durl, location)
local u, re = url.parse(durl)
if not u then
function transport.file_path(surl, location)
e2lib.log(4, string.format("%s: %s %s", "file_path()", surl,
location))
- local e = new_error("can't get path to file")
+ local e = err.new("can't get path to file")
local u, re = url.parse(surl)
if not u then
return nil, e:cat(re)
require("e2option")
local cache = require("cache")
local generic_git = require("generic_git")
+local err = require("err")
e2lib.init()
e2lib.abort(e)
end
e2lib.init2()
-local e = new_error("creating project failed")
+local e = err.new("creating project failed")
local config, re = e2lib.get_global_config()
if not config then
require("e2option")
local generic_git = require("generic_git")
local cache = require("cache")
+local err = require("err")
e2lib.init()
-local e = new_error("fetching project failed")
+local e = err.new("fetching project failed")
local doc = [[
usage: e2-fetch-project [<option> ...] [<server>:]<location> [<destination>]
e2lib.shquote(buildconfig.LUA), e2lib.shquote(buildconfig.TOOLDIR))
rc, re = e2lib.callcmd_log(e2_install_e2)
if rc ~= 0 then
- e2lib.abort(new_error("installing local e2 failed"))
+ e2lib.abort(err.new("installing local e2 failed"))
end
e2lib.finish()
require("e2lib")
require("e2option")
local generic_git = require("generic_git")
+local err = require("err")
e2lib.init()
e2lib.abort(e)
end
e2lib.init2()
-local e = new_error("e2-install-e2 failed")
+local e = err.new("e2-install-e2 failed")
local config = e2lib.get_global_config()
local servers = config.servers
require("e2local")
require("e2tool")
require("e2build")
+local err = require("err")
+
e2lib.init()
local info, re = e2tool.local_init(nil, "build")
if not info then
e2lib.logf(3, disable_msg, set.server)
rc, re = info.cache:set_writeback(set.server, false)
if not rc then
- local e = new_error(disable_msg, set.server)
+ 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 = new_error(enable_msg, set.server)
+ local e = err.new(enable_msg, set.server)
e2lib.abort(e:cat(re))
end
end
-- handle command line flags
local build_mode = nil
if opts["branch-mode"] and opts["wc-mode"] then
- e = new_error("--branch-mode and --wc-mode are mutually exclusive")
+ e = err.new("--branch-mode and --wc-mode are mutually exclusive")
e2lib.abort(e)
end
if opts["branch-mode"] then
require("e2local")
require("e2tool")
+local err = require("err")
+
e2lib.init()
local info, re = e2tool.local_init(nil, "cf")
if not info then
local commands = {}
local function newsource(info, ...)
- local e = new_error("newsource")
+ local e = err.new("newsource")
local t = ...
local name = t[2]
local scm = t[3]
end
local function editsource(info, ...)
- local e = new_error("editsource")
+ local e = err.new("editsource")
local t = ...
local name = t[2]
if not name then
end
local function newresult(info, ...)
- local e = new_error("newresult")
+ local e = err.new("newresult")
local t = ...
local name = t[2]
if not name then
end
local function editresult(info, ...)
- local e = new_error("editresult")
+ local e = err.new("editresult")
local t = ...
local name = t[2]
if not name then
end
local function editbuildscript(info, ...)
- local e = new_error("editbuildscript")
+ local e = err.new("editbuildscript")
local t = ...
local name = t[2]
if not name then
local hash = require("hash")
local url = require("url")
local tools = require("tools")
+local err = require("err")
--- validate source configuration, log errors to the debug log
-- @param info the info table
if not src.sourceid then
src.sourceid = {}
end
- local e = new_error("in source %s:", sourcename)
+ local e = err.new("in source %s:", sourcename)
rc, re = git.source_apply_default_working(info, sourcename)
if not rc then
return false, e:cat(re)
elseif u.transport == "cvspserver" then
cvsroot = string.format(":pserver:%s:/%s", u.server, u.path)
else
- return nil, new_error("cvs: transport not supported")
+ return nil, err.new("cvs: transport not supported")
end
return cvsroot, nil
end
rev = src.tag
end
if not rev then
- return nil, new_error("source set not allowed")
+ return nil, err.new("source set not allowed")
end
return rev, nil
end
if not rc then
return false, re
end
- local e = new_error("fetching source failed: %s", sourcename)
+ local e = err.new("fetching source failed: %s", sourcename)
local src = info.sources[ sourcename ]
local location = src.cvsroot
local server = src.server
if not rc then
return false, re
end
- local e = new_error("cvs.prepare_source failed")
+ local e = err.new("cvs.prepare_source failed")
local src = info.sources[ sourcename ]
local location = src.cvsroot
local server = src.server
if not rc then
e2lib.abort(re)
end
- local e = new_error("updating cvs source failed")
+ local e = err.new("updating cvs source failed")
local src = info.sources[ sourcename ]
local working = string.format("%s/%s", info.root, src.working)
local rsh = tools.get_tool("ssh")
if src.sourceid[source_set] then
return true, nil, src.sourceid[source_set]
end
- local e = new_error("calculating sourceid failed for source %s",
+ local e = err.new("calculating sourceid failed for source %s",
sourcename)
local hc = hash.hash_start()
hash.hash_line(hc, src.name)
-- <directory>/makefile
-- <directory>/licences
local rc, re
- local e = new_error("converting result")
+ local e = err.new("converting result")
rc, re = git.check(info, sourcename, true)
if not rc then
return false, e:cat(re)
function cvs.check_workingcopy(info, sourcename)
local rc, re
- local e = new_error("checking working copy failed")
+ local e = err.new("checking working copy failed")
e:append("in source %s (cvs configuration):", sourcename)
e:setcount(0)
rc, re = cvs.validate_source(info, sourcename)
module("e2build", package.seeall)
local transport = require("transport")
local tools = require("tools")
+local err = require("err")
--- cache a result
-- @param info
local buildid = res.build_mode.buildid(e2tool.buildid(info, r))
local sbid = e2tool.bid_display(buildid)
local rc, re
- local e = new_error("error while checking if result is available: %s", r)
+ local e = err.new("error while checking if result is available: %s", r)
local columns = tonumber(e2lib.globals.osenv["COLUMNS"])
if res.playground then
return_flags.message = e2lib.align(columns,
function build_config(info, r)
e2lib.log(4, string.format("build_config(%s, %s)",
tostring(info), tostring(r)))
- local e = new_error("setting up build configuration for result `%s' failed",
+ local e = err.new("setting up build configuration for result `%s' failed",
r)
local res = info.results[r]
if not res then
function chroot_lock(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("error locking chroot")
+ local e = err.new("error locking chroot")
rc, re = e2lib.mkdir(res.build_config.c, "-p")
if not rc then
return false, e:cat(re)
function chroot_unlock(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("error unlocking chroot")
+ local e = err.new("error unlocking chroot")
rc, re = e2lib.globals.lock:unlock(res.build_config.chroot_lock)
if not rc then
return false, e:cat(re)
function setup_chroot(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("error setting up chroot")
+ local e = err.new("error setting up chroot")
-- create the chroot path and create the chroot marker file without root
-- permissions. That makes sure we have write permissions here.
rc, re = e2lib.mkdir(res.build_config.c, "-p")
end
local res = info.results[r]
local rc, re
- local e = new_error("entering playground")
+ local e = err.new("entering playground")
e2lib.log(4, "entering playground for " .. r .. " ...")
local term = e2lib.globals.terminal
local e2_su = tools.get_tool("e2-su-2.2")
function fix_permissions(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("fixing permissions failed")
+ local e = err.new("fixing permissions failed")
e2lib.log(3, "fix permissions")
e2tool.set_umask(info)
local argv = { "chroot_2_3", res.build_config.base, "chown", "-R",
function runbuild(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("build failed")
+ local e = err.new("build failed")
e2lib.log(3, "building " .. r .. " ...")
local runbuild = string.format("/bin/bash -e -x %s/%s/%s",
e2lib.shquote(res.build_config.Tc),
e2tool.reset_umask(info)
out:close()
if rc ~= 0 then
- e = new_error("build script for %s failed with exit status %d", r, rc)
+ e = err.new("build script for %s failed with exit status %d", r, rc)
e:append("see %s for more information", res.build_config.buildlog)
return false, e
end
function chroot_remove(info, r, return_flags)
local res = info.results[r]
- local e = new_error("removing chroot failed")
+ local e = err.new("removing chroot failed")
e2tool.set_umask(info)
local rc, re = e2lib.e2_su_2_2({"remove_chroot_2_3", res.build_config.base})
e2tool.reset_umask(info)
local res = info.results[r]
local rc, re
local tmpdir = e2lib.mktempdir()
- local e = new_error("unpacking result failed: %s", dep)
+ local e = err.new("unpacking result failed: %s", dep)
local d = info.results[dep]
local buildid = e2tool.buildid(info, dep)
end
function sources(info, r, return_flags)
- local e = new_error("installing sources")
+ local e = err.new("installing sources")
local i, k, l, source, cp
-- the development build case
local function install_directory_structure(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("installing directory structure")
+ local e = err.new("installing directory structure")
local dirs = {"out", "init", "script", "build", "root", "env", "dep"}
for _, v in pairs(dirs) do
local d = string.format("%s/%s", res.build_config.T, v)
local function install_build_script(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("installing build script")
+ local e = err.new("installing build script")
local location = e2tool.resultbuildscript(info.results[r].directory)
local destdir = string.format("%s/script", res.build_config.T)
rc, re = transport.fetch_file(info.root_server, location, destdir, nil)
local function install_env(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("installing environment files failed")
+ local e = err.new("installing environment files failed")
-- install builtin environment variables
local file = string.format("%s/env/builtin", res.build_config.T)
rc, re = write_environment_script(res.build_config.builtin_env, file)
local function install_init_files(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("installing init files")
+ local e = err.new("installing init files")
for x in e2lib.directory(info.root .. "/proj/init") do
if not e2lib.is_backup_file(x) then
local location = string.format("proj/init/%s", x)
local function install_build_driver(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("writing build driver script failed")
+ local e = err.new("writing build driver script failed")
local bc = res.build_config
local destdir = string.format("%s/%s", bc.T, bc.scriptdir)
rc, re = write_build_driver(info, r, destdir)
local function install_build_time_dependencies(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("installing build time dependencies")
+ local e = err.new("installing build time dependencies")
e2lib.log(3, string.format("install_build_time_dependencies"))
local deps
deps = e2tool.get_depends(info, r)
local function install_sources(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("installing sources")
+ local e = err.new("installing sources")
e2lib.log(3, "install sources")
for i, source in pairs(res.sources) do
- local e = new_error("installing source failed: %s", source)
+ local e = err.new("installing source failed: %s", source)
local destdir = string.format("%s/build", res.build_config.T)
local source_set = res.build_mode.source_set()
local rc, re = scm.prepare_source(info, source, source_set,
function linklast(info, r, return_flags)
local res = info.results[r]
local rc, re
- local e = new_error("creating link to last results")
+ local e = err.new("creating link to last results")
-- calculate the path to the result
local server, location = res.build_mode.storage(info.project_location,
info.release_id)
tostring(return_flags))
local res = info.results[r]
local rc, re
- local e = new_error("fetching build results from chroot")
+ local e = err.new("fetching build results from chroot")
e2lib.log(4, string.format("store_result"))
-- create a temporary directory to build up the result
function build_results_default(info, results)
e2lib.logf(3, "building results")
for _, r in ipairs(results) do
- local e = new_error("building result failed: %s", r)
+ local e = err.new("building result failed: %s", r)
local flags = {}
local t1 = os.time()
local rc, re = build_result(info, r, flags)
end
end
end
- return false, new_error("registering build_results function failed")
+ return false, err.new("registering build_results function failed")
end
--- build a result
e2lib.log(4, "writing build driver")
local res = info.results[r]
local rc, re
- local e = new_error("generating build driver script failed")
+ local e = err.new("generating build driver script failed")
local buildrc_file = string.format("%s/%s", destdir,
res.build_config.buildrc_file)
local buildrc_noinit_file = string.format("%s/%s", destdir,
-- @return bool
-- @return an error object on failure
function write_environment_script(env, file)
- local e = new_error("writing environment script")
+ local e = err.new("writing environment script")
local f, msg = io.open(file, "w")
if not f then
e:append("%s: %s", file, msg)
end
e2lib.log(3, "providing project data to this build")
local rc, re
- local e = new_error("providing project data to this build failed")
+ local e = err.new("providing project data to this build failed")
-- project/proj/init/<files>
local destdir = string.format("%s/project/proj/init",
res.build_config.T)
local config = string.format("%s/config", destdir)
local f, msg = io.open(config, "w")
if not f then
- e:cat(new_error("%s: %s", config, msg))
+ e:cat(err.new("%s: %s", config, msg))
return false, e
end
f:write(string.format(
-- @return bool
-- @return an error object on failure
function register_build_function(info, name, func, pos)
- local e = new_error("register build function")
+ local e = err.new("register build function")
local ipos = nil
for i=1, #build_process, 1 do
if build_process[i].name == pos then
require("e2lib")
require("strict")
require("collection")
-require("err")
+local err = require("err")
require("scm")
require("files")
require("git")
-- @return bool
local function listofstrings(l, unique, unify)
if type(l) ~= "table" then
- return false, new_error("not a table")
+ return false, err.new("not a table")
end
local values = {}
local unified = {}
for i,s in pairs(l) do
if type(i) ~= "number" then
- return false, new_error("found non-numeric index")
+ return false, err.new("found non-numeric index")
end
if type(s) ~= "string" then
- return false, new_error("found non-string value")
+ return false, err.new("found non-string value")
end
if unique and values[s] then
- return false, new_error("found non-unique value: '%s'", s)
+ return false, err.new("found non-unique value: '%s'", s)
end
if unify and not values[s] then
table.insert(unified, s)
-- @return bool
-- @return an error object on failure
local function check_tab(tab, keys, inherit)
- local e = new_error("checking file configuration")
+ local e = err.new("checking file configuration")
if type(tab) ~= "table" then
return false, e:append("not a table")
function opendebuglogfile(info)
local rc, re = e2lib.mkdir(info.root .. "/log", "-p")
if not rc then
- local e = new_error("error making log directory")
+ local e = err.new("error making log directory")
return false, e:cat(re)
end
local logfile = info.root .. "/log/debug.log"
local rc, re = e2lib.rotate_log(logfile)
local debuglogfile, msg = io.open(logfile, "w")
if not debuglogfile then
- local e = new_error("error opening debug logfile")
+ local e = err.new("error opening debug logfile")
return false, e:append(msg)
end
e2lib.globals.debuglogfile = debuglogfile
-- @return an error object on failure
function load_user_config(info, path, dest, index, var)
local rc, re
- local e = new_error("loading configuration failed")
+ local e = err.new("loading configuration failed")
e2lib.log(3, "loading " .. path)
if not e2util.exists(path) then
return false, e:append("file does not exist: %s", path)
-- @return list of config items
-- @return an error object on failure
function load_user_config2(info, path, types)
- local e = new_error("loading configuration file failed")
+ local e = err.new("loading configuration file failed")
local rc, re
local list = {}
-- @return an error object on failure
function local_init(path, tool)
local rc, re
- local e = new_error("initializing")
+ local e = err.new("initializing")
local info = {}
-- provide the current tool name to allow conditionals in plugin
function collect_project_info(info, skip_load_config)
local rc, re
- local e = new_error("reading project configuration")
+ local e = err.new("reading project configuration")
-- check for configuration compatibility
info.config_syntax_compat = buildconfig.SYNTAX
return false, e:cat(re)
end
info.project[".fix"] = nil
- local e = new_error("in project configuration:")
+ local e = err.new("in project configuration:")
if not info.project.release_id then
e:append("key is not set: release_id")
end
e2lib.abort(e:cat(re))
end
if not rc then
- e = new_error("project repository is not clean")
+ e = err.new("project repository is not clean")
e2lib.abort(e:cat(re))
end
end
function check_project_info(info, all, access, verbose)
local rc, re
- local e = new_error("error in project configuration")
+ local e = err.new("error in project configuration")
rc, re = check_chroot_config(info)
if not rc then
return false, e:cat(re)
local t = {}
local function visit(res)
if had[res] then
- return false, new_error("cyclic dependency: %s", table.concat(path, " "))
+ return false, err.new("cyclic dependency: %s", table.concat(path, " "))
elseif t and not col[res] then
table.insert(path, res)
had[res] = true
end
function read_hash_file(info, server, location)
- local e = new_error("error reading hash file")
+ local e = err.new("error reading hash file")
local cs = nil
local cache_flags = { cache = true }
local rc, re = info.cache:cache_file(server, location, cache_flags)
assert(type(path) == "string")
assert(string.len(path) > 0)
- local e = new_error("error hashing path")
+ local e = err.new("error hashing path")
local ctx = hash.hash_start()
-- @return string the hash value, nil on error
-- @return nil, an error string on error
function hash_file(info, server, location)
- local e = new_error("error hashing file")
+ local e = err.new("error hashing file")
local cache_flags = { cache = true }
local rc, re = info.cache:cache_file(server, location, cache_flags)
if not rc then
e2lib.logf(4, "verify_hash %s %s %s %s", tostring(info), tostring(server),
tostring(location), tostring(sha1))
local rc, re
- local e = new_error("error verifying checksum")
+ local e = err.new("error verifying checksum")
local is_sha1, re = hash_file(info, server, location)
if not is_sha1 then
return false, e:cat(re)
end
if is_sha1 ~= sha1 then
- e = new_error("checksum mismatch in file:")
+ e = err.new("checksum mismatch in file:")
return false, e:append("%s:%s", server, location)
end
e2lib.logf(4, "checksum matches: %s:%s", server, location)
-- @return bool
-- @return an error object on failure
function calc_sourceids(info, sourceset)
- local e = new_error("calculating sourceids failed")
+ local e = err.new("calculating sourceids failed")
for _,src in pairs(info.sources) do
local sourceid, re = scm.sourceid(info, src.name, sourceset)
if not sourceid then
end
function hashcache_setup(info)
- local e = new_error("reading hash cache")
+ local e = err.new("reading hash cache")
local rc, re
e2lib.logf(4, "loading hashcache from file: %s", info.hashcache_file)
info.hashcache = {}
end
function hashcache_write(info)
- local e = new_error("writing hash cache file")
+ local e = err.new("writing hash cache file")
local f, msg = io.open(info.hashcache_file, "w")
if not f then
return false, e:append(msg)
end
function hashcache(info, file)
- local e = new_error("getting fileid from hash cache failed")
+ local e = err.new("getting fileid from hash cache failed")
local rc, re, fileid
local p, re = info.cache:file_path(file.server, file.location, {})
if not p then
end
local s, msg = e2util.stat(p)
if not s then
- return nil, new_error("%s: %s", p, msg)
+ return nil, err.new("%s: %s", p, msg)
end
local id = string.format("%s:%s", file.server, file.location)
local fileid
-- @return an error object on failure
function verify_remote_fileid(info, file, fileid)
local rc, re
- local e = new_error("error calculating remote file id for file: %s:%s",
+ local e = err.new("error calculating remote file id for file: %s:%s",
file.server, file.location)
if not info.cache:cache_enabled(file.server) or
not e2option.opts["check-remote"] then
return false, e:cat(re)
end
else
- return false, new_error("transport not supported: %s",
+ return false, err.new("transport not supported: %s",
u.transport)
end
if fileid ~= remote_fileid then
- return false, new_error(
+ return false, err.new(
"checksum for remote file %s:%s (%s) does not match" ..
" configured checksum (%s)",
file.server, file.location, remote_fileid, fileid)
function fileid(info, file)
local fileid
local re
- local e = new_error("error calculating file id for file: %s:%s",
+ local e = err.new("error calculating file id for file: %s:%s",
file.server, file.location)
if file.sha1 then
fileid = file.sha1
-- @return an error object on failure
function licenceid(info, licence)
local rc, re
- local e = new_error("calculating licence id failed for licence: %s",
+ local e = err.new("calculating licence id failed for licence: %s",
licence)
local lic = info.licences[licence]
if lic.licenceid then
-- @return bool
-- @return an error object on failure
function calc_licenceids(info)
- local e = new_error("calculating licenceids failed")
+ local e = err.new("calculating licenceids failed")
for l,_ in pairs(info.licences) do
local licenceid, re = licenceid(info, l)
if not licenceid then
-- @return the buildid
function pbuildid(info, resultname)
e2lib.log(4, string.format("get pbuildid for %s", resultname))
- local e = new_error("error calculating result id for result: %s",
+ local e = err.new("error calculating result id for result: %s",
resultname)
local r = info.results[resultname]
if r.pbuildid then
end
function chrootgroupid(info, groupname)
- local e = new_error("calculating chroot group id failed for group %s",
+ local e = err.new("calculating chroot group id failed for group %s",
groupname)
local g = info.chroot.groups_byname[groupname]
if g.groupid then
local src = info.sources[sourcename]
local rc, e, re
if not src then
- e = new_error("no source by that name: %s", sourcename)
+ e = err.new("no source by that name: %s", sourcename)
return false, e
end
- local e = new_error("in source: %s", sourcename)
+ local e = err.new("in source: %s", sourcename)
if not src.type then
e2lib.warnf("WDEFAULT", "in source %s", sourcename)
e2lib.warnf("WDEFAULT", " type attribute defaults to `files'")
end
function check_sources(info)
- local e = new_error("Error while checking sources")
+ local e = err.new("Error while checking sources")
local rc, re
for n,s in pairs(info.sources) do
rc, re = check_source(info, n)
end
function check_licence(info, l)
- local e = new_error("in licence: %s", l)
+ local e = err.new("in licence: %s", l)
local lic = info.licences[l]
if not lic.server then
e:append("no server attribute")
end
function check_licences(info)
- local e = new_error("Error while checking licences")
+ local e = err.new("Error while checking licences")
local rc, re
for l, lic in pairs(info.licences) do
rc, re = check_licence(info, l)
end
function check_workingcopies(info)
- local e = new_error("Error while checking working copies")
+ local e = err.new("Error while checking working copies")
local rc, re
for n,s in pairs(info.sources) do
rc, re = scm.check_workingcopy(info, n)
end
function check_results(info)
- local e = new_error("Error while checking results")
+ local e = err.new("Error while checking results")
local rc, re
for _,f in ipairs(info.ftab.check_result) do
for r,_ in pairs(info.results) do
-- @param resultname string: the result to check
function check_result(info, resultname)
local res = info.results[resultname]
- local e = new_error("in result %s:", resultname)
+ local e = err.new("in result %s:", resultname)
if not res then
e:append("result does not exist: %s", resultname)
return false, e
-- @param resultname string: the result to check
function check_collect_project(info, resultname)
local res = info.results[resultname]
- local e = new_error("in result %s:", resultname)
+ local e = err.new("in result %s:", resultname)
local rc, re
if not res.collect_project then
-- insert empty tables, to avoid some conditionals in the code
build_numbers = info.build_numbers
end
local rc
- local re = new_error("error parsing build numbers:")
+ local re = err.new("error parsing build numbers:")
e2lib.log(3, "parsing build numbers")
local line = 0
for l in s:gmatch("[^\n]+") do
if not build_numbers then
build_numbers = info.build_numbers
end
- local e = new_error("error writing build number file:")
+ local e = err.new("error writing build number file:")
e2lib.logf(3, "writing build numbers to %s", file)
local s, re = bn2string(info)
if not s then
if not build_numbers then
build_numbers = info.build_numbers
end
- local e = new_error("error reading build number file:")
+ local e = err.new("error reading build number file:")
e2lib.logf(3, "reading build-numbers from %s", file)
local s, re = e2lib.read_file(file)
if not s and e2lib.isfile(file) then
-- @return nil, an error object on failure
function buildnumber_mergetoresults(info)
e2lib.log(3, string.format("merging build numbers to results"))
- local e = new_error("merging build numbers to results:")
+ local e = err.new("merging build numbers to results:")
for r, res in pairs(info.results) do
local bn = info.build_numbers[r]
if not bn then
e2lib.log(3, "requesting build numbers from server")
if e2lib.globals.buildnumber_server_url == nil then
- return false, new_error("no build number server configured")
+ return false, err.new("no build number server configured")
end
local rc, re
- local e = new_error("error requesting build numbers")
+ local e = err.new("error requesting build numbers")
local tmpdir = e2lib.mktempdir()
local tmpreq = string.format("%s/build-number.req.tmp", tmpdir)
local tmpres = string.format("%s/build-number.res.tmp", tmpdir)
local req -- the request
local sta -- the state
local res -- the response
- local e = new_error("error in local buildnumber request")
+ local e = err.new("error in local buildnumber request")
-- compose the request
req = info.build_numbers
-- compose the state
-- @return an error object on failure
function print_selection(info, results)
for _,r in ipairs(results) do
- local e = new_error("error printing selected results")
+ local e = err.new("error printing selected results")
local res = info.results[r]
if not res then
return false, e:append("no such result: %s", r)
-- @return bool
-- @return an error object on failure
function lcd(info, dir)
- local e = new_error("chdir failed")
+ local e = err.new("chdir failed")
local abspath = string.format("%s/%s", info.root, dir)
local rc, re = e2lib.chdir(abspath)
if not rc then
-- @return bool
-- @return an error object on failure
function check_config_syntax_compat(info)
- local e = new_error("checking configuration syntax compatibilitly failed")
+ local e = err.new("checking configuration syntax compatibilitly failed")
local l, re = e2lib.read_line(info.config_syntax_file)
if not l then
return false, e:cat(re)
-- @return bool
-- @return an error object on failure
function read_chroot_config(info)
- local e = new_error("reading chroot config failed")
+ local e = err.new("reading chroot config failed")
local t = {}
local rc, re = load_user_config(info, info.chroot_config_file,
t, "chroot", "e2chroot")
-- @return bool
-- @return an error object on failure
function check_chroot_config(info)
- local e = new_error("error validating chroot configuration")
+ local e = err.new("error validating chroot configuration")
for g,grp in pairs(info.chroot.groups) do
if not grp.server then
e:append("in group: %s", grp.name)
local msg = "only digits, alphabetic characters, and '-_./' " ..
"are allowed"
if not str:match("^[-_0-9a-zA-Z/.]+$") then
- return false, new_error(msg)
+ return false, err.new(msg)
else
return true
end
local msg = "only digits, alphabetic characters, and '-_.' " ..
"are allowed"
if not str:match("^[-_0-9a-zA-Z.]+$") then
- return false, new_error(msg)
+ return false, err.new(msg)
else
return true
end
end
function load_source_config(info)
- local e = new_error("error loading source configuration")
+ local e = err.new("error loading source configuration")
info.sources = {}
for _,src in ipairs(gather_source_paths(info)) do
end
function load_result_config(info)
- local e = new_error("error loading result configuration")
+ local e = err.new("error loading result configuration")
info.results = {}
for _,res in ipairs(gather_result_paths(info)) do
function register_collect_project_info(info, func)
if type(info) ~= "table" or type(func) ~= "function" then
- return false, new_error("register_collect_project_info: invalid argument")
+ return false, err.new("register_collect_project_info: invalid argument")
end
table.insert(info.ftab.collect_project_info, func)
return true, nil
function register_check_result(info, func)
if type(info) ~= "table" or type(func) ~= "function" then
- return false, new_error("register_check_result: invalid argument")
+ return false, err.new("register_check_result: invalid argument")
end
table.insert(info.ftab.check_result, func)
return true, nil
function register_resultid(info, func)
if type(info) ~= "table" or type(func) ~= "function" then
- return false, new_error("register_resultid: invalid argument")
+ return false, err.new("register_resultid: invalid argument")
end
table.insert(info.ftab.resultid, func)
return true, nil
function register_pbuildid(info, func)
if type(info) ~= "table" or type(func) ~= "function" then
- return false, new_error("register_pbuildid: invalid argument")
+ return false, err.new("register_pbuildid: invalid argument")
end
table.insert(info.ftab.pbuildid, func)
return true, nil
function register_dlist(info, func)
if type(info) ~= "table" or type(func) ~= "function" then
- return false, new_error("register_dlist: invalid argument")
+ return false, err.new("register_dlist: invalid argument")
end
table.insert(info.ftab.dlist, func)
return true, nil
function load_env_config(info, file)
e2lib.logf(4, "loading environment: %s", file)
- local e = new_error("loading environment: %s", file)
+ local e = err.new("loading environment: %s", file)
local rc, re
local info = info
for var, val in pairs(data) do
if type(var) ~= "string" or
(type(val) ~= "string" and type(val) ~= "table") then
- merge_error = new_error("invalid environment entry in %s: %s=%s",
+ merge_error = err.new("invalid environment entry in %s: %s=%s",
file, tostring(var), tostring(val))
return nil
end
for var1, val1 in pairs(val) do
if type(var1) ~= "string" or
(type(val1) ~= "string" and type(val1) ~= "table") then
- merge_error = new_error(
+ merge_error = err.new(
"invalid environment entry in %s [%s]: %s=%s",
file, var, tostring(var1), tostring(val1))
return nil
require("e2local")
require("e2tool")
require("e2build")
+local err = require("err")
+
e2lib.init()
local info, re = e2tool.local_init(nil, "fetch-sources")
if not info then
-- --fetch, --cache fetch selected sources
-- --update update selected sources
-local e = new_error()
+local e = err.new()
e2option.flag("all", "select all sources, even files sources")
e2option.flag("chroot", "select chroot files")
function fetch_sources(info, opts, sel)
local rc1 = true -- global return code
local nfail = 0 -- failure counter
- local e = new_error() -- no message yet, append the summary later on
+ local e = err.new() -- no message yet, append the summary later on
-- fetch
for _, s in pairs(info.sources) do
module("files", package.seeall)
require("scm")
local hash = require("hash")
+local err = require("err")
--- validate source configuration, log errors to the debug log
-- @param info the info table
if not rc then
return false, e
end
- e = new_error("in source %s:", sourcename)
+ e = err.new("in source %s:", sourcename)
e:setcount(0)
local src = info.sources[ sourcename ]
if not src.file then
function files.fetch_source(info, sourcename)
local rc, re
- local e = new_error("fetching source failed: %s", sourcename)
+ local e = err.new("fetching source failed: %s", sourcename)
rc, re = files.validate_source(info, sourcename)
if not rc then
return false, e:cat(re)
-- @return nil, maybe an error string on error
function files.prepare_source(info, sourcename, sourceset, buildpath)
local rc, re
- local e = new_error("error preparing source: %s", sourcename)
+ local e = err.new("error preparing source: %s", sourcename)
rc, re = files.validate_source(info, sourcename)
if not rc then
return false, e:cat(re)
-- @return an error string on error
function files.sourceid(info, sourcename, sourceset)
local rc, re
- local e = new_error("error calculating sourceid for source: %s",
+ local e = err.new("error calculating sourceid for source: %s",
sourcename)
rc, re = files.validate_source(info, sourcename)
if not rc then
-- export the source to a result structure
function files.toresult(info, sourcename, sourceset, directory)
local rc, re
- local e = new_error("converting result failed")
+ local e = err.new("converting result failed")
rc, re = files.validate_source(info, sourcename)
if not rc then
return false, e:cat(re)
local cache = require("cache")
local generic_git = require("generic_git")
local url = require("url")
+local err = require("err")
--- git branch wrapper
-- get the current branch
function git.get_revision_id(info, source, sourceset, check_remote)
local sourcename = source
local rc, re
- local e = new_error("getting revision id failed for source: %s", source)
+ local e = err.new("getting revision id failed for source: %s", source)
local s = info.sources[source]
rc, re = git.validate_source(info, sourcename)
if not rc then
-- @return bool
-- @return an error object on failure
function source_apply_default_licences(info, sourcename)
- local e = new_error("applying default licences failed.")
+ local e = err.new("applying default licences failed.")
local src = info.sources[ sourcename ]
if src.licences_default_applied then
return true
local rc, re
local e
if not src then
- return false, new_error("invalid source: %s", sourcename)
+ return false, err.new("invalid source: %s", sourcename)
end
- e = new_error("in source %s:", sourcename)
+ e = err.new("in source %s:", sourcename)
rc, re = source_apply_default_licences(info, sourcename)
if not rc then
return false, e:cat(re)
end
rc, re = scm.working_copy_available(info, sourcename)
if (not rc) and require_workingcopy then
- return false, new_error("working copy is not available")
+ return false, err.new("working copy is not available")
end
rc, re = scm.check_workingcopy(info, sourcename)
if not rc then
return false, re
end
local src = info.sources[ sourcename ]
- local e = new_error("in source %s:", sourcename)
+ local e = err.new("in source %s:", sourcename)
rc, re = source_apply_default_working(info, sourcename)
if not rc then
return false, e:cat(re)
function git.update(info, sourcename)
local src = info.sources[ sourcename ]
local rc, re
- local e = new_error("updating source failed")
+ local e = err.new("updating source failed")
rc, re = scm.working_copy_available(info, sourcename)
if not rc then
return false, e:cat(re)
function git.fetch_source(info, sourcename)
local src = info.sources[ sourcename ]
local rc, re
- local e = new_error("fetching source failed: %s", sourcename)
+ local e = err.new("fetching source failed: %s", sourcename)
rc, re = git.validate_source(info, sourcename)
if not rc then
return false, e:cat(re)
function git.prepare_source(info, sourcename, sourceset, buildpath)
local src = info.sources[ sourcename ]
local rc, re, e
- local e = new_error("preparing git sources failed")
+ local e = err.new("preparing git sources failed")
rc, re = check(info, sourcename, true)
if not rc then
return false, e:cat(re)
function git.working_copy_available(info, sourcename)
local src = info.sources[sourcename]
local rc, re
- local e = new_error("checking if working copy is available for source %s",
+ local e = err.new("checking if working copy is available for source %s",
sourcename)
rc, re = git.validate_source(info, sourcename)
if not rc then
-- @return string: the git url, or nil
-- @return an error object on failure
function git.git_url(c, server, location)
- local e = new_error("translating server:location to git url")
+ local e = err.new("translating server:location to git url")
local rurl, re = cache.remote_url(c, server, location)
if not rurl then
return nil, e:cat(re)
function git.display(info, sourcename)
local src = info.sources[sourcename]
local rc, re
- local e = new_error("display source information failed")
+ local e = err.new("display source information failed")
rc, re = git.validate_source(info, sourcename)
if not rc then
return nil, e:cat(re)
function git.toresult(info, sourcename, sourceset, directory)
local rc, re
- local e = new_error("converting result")
+ local e = err.new("converting result")
rc, re = check(info, sourcename, true)
if not rc then
return false, e:cat(re)
function git.check_workingcopy(info, sourcename)
local rc, re
- local e = new_error("checking working copy failed")
+ local e = err.new("checking working copy failed")
e:append("in source %s (git configuration):", sourcename)
e:setcount(0)
rc, re = git.validate_source(info, sourcename)
require("e2local")
require("e2tool")
+local err = require("err")
+
e2lib.init()
local info, re = e2tool.local_init(nil, "ls-project")
if not info then
if info.results[r] then
table.insert(results, r)
else
- e2lib.abort(new_error("not a result: %s", r))
+ e2lib.abort(err.new("not a result: %s", r))
end
end
end
require("e2tool")
local generic_git = require("generic_git")
local cache = require("cache")
+local err = require("err")
e2lib.init()
local info, re = e2tool.local_init(nil, "new-source")
return nil, e
end
local rc = nil
- local e = new_error("no checksum available")
+ local e = err.new("no checksum available")
while true do
local line = f:read()
if not line then
e2lib.shquote(f), e2lib.shquote(name))
local rc = e2lib.callcmd_capture(cmd)
if rc ~= 0 then
- return false, new_error("download failed: %s", f)
+ return false, err.new("download failed: %s", f)
end
return true, nil
end
require("e2local")
require("e2tool")
require("e2build")
+local err = require("err")
+
e2lib.init()
local info, re = e2tool.local_init(nil, "playground")
if not info then
e2lib.abort(re)
end
-local e = new_error("entering playground failed")
+local e = err.new("entering playground failed")
local rc, re
e2option.documentation = [[
]]
module("policy", package.seeall)
+local err = require("err")
function source_set_lazytag()
return "lazytag"
-- @return the buildid
function init(info)
- local e = new_error("checking policy")
+ local e = err.new("checking policy")
-- check if all required servers exist
local storage = {
storage_release,
local location = "test/test"
local release_id = "release-id"
local server, location = s(location, release_id)
- local se = new_error("checking server configuration for '%s'",
+ local se = err.new("checking server configuration for '%s'",
server)
local ce, re = info.cache:ce_by_server(server)
if not ce then
]]
scm = module("scm", package.seeall)
+local err = require("err")
-- scm modules
local scms = {}
-- @return bool
-- @return an error object on failure
function register(scmname, mod)
- local e = new_error("error registering scm")
+ local e = err.new("error registering scm")
if scms[scmname] then
return false, e:append("scm with that name exists")
end
-- @return bool
-- @return an error object on failure
function register_interface(name)
- local e = new_error("registering scm interface failed")
+ local e = err.new("registering scm interface failed")
if intf[name] then
return false, e:append(
"interface with that name exists: %s", name)
local function func(info, sourcename, ...)
local src = info.sources[sourcename]
local rc, re, e
- e = new_error("calling scm operation failed")
+ e = err.new("calling scm operation failed")
if not scms[src.type] then
return false, e:append("no such source type: %s", src.type)
end
-- @return bool
-- @return an error object on failure
function register_function(type, name, func)
- local e = new_error("registering scm function failed")
+ local e = err.new("registering scm function failed")
if not scms[type] then
return false, e:append("no scm type by that name: %s", type)
end
local hash = require("hash")
local url = require("url")
local tools = require("tools")
+local err = require("err")
--- translate url into subversion url
-- @param u table: url table
-- @return an error object on failure
function mksvnurl(surl)
local rc, re
- local e = new_error("cannot translate url into subversion url:")
+ local e = err.new("cannot translate url into subversion url:")
e:append("%s", surl)
local u, re = url.parse(surl)
if not u then
if not rc then
return false, re
end
- local e = new_error("fetching source failed: %s", sourcename)
+ local e = err.new("fetching source failed: %s", sourcename)
local src = info.sources[sourcename]
local location = src.location
local server = src.server
if not rc then
return false, re
end
- local e = new_error("svn.prepare_source failed")
+ local e = err.new("svn.prepare_source failed")
local src = info.sources[ sourcename ]
local location = src.location
local server = src.server
function svn.check_workingcopy(info, sourcename) --OK
local rc, re
- local e = new_error("checking working copy failed")
+ local e = err.new("checking working copy failed")
e:append("in source %s (svn configuration):", sourcename)
e:setcount(0)
rc, re = svn.validate_source(info, sourcename)
-- <directory>/makefile
-- <directory>/licences
local rc, re
- local e = new_error("converting result")
+ local e = err.new("converting result")
rc, re = git.check(info, sourcename, true)
if not rc then
return false, e:cat(re)
if not rc then
e2lib.abort(re)
end
- local e = new_error("updating svn source failed")
+ local e = err.new("updating svn source failed")
local src = info.sources[ sourcename ]
local working = string.format("%s/%s", info.root, src.working)
rc, re = e2lib.chdir(working)
if not src.sourceid then
src.sourceid = {}
end
- local e = new_error("in source %s:", sourcename)
+ local e = err.new("in source %s:", sourcename)
rc, re = git.source_apply_default_working(info, sourcename)
if not rc then
return false, e:cat(re)