local ssh = nil
ssh = e2lib.globals.osenv["E2_SSH"]
if ssh then
- e2lib.log(3, string.format(
- "using ssh command from the E2_SSH environment variable: %s", ssh))
+ e2lib.logf(3, "using E2_SSH environment variable: %s", ssh)
tools.set_tool("ssh", ssh)
end
out = out .. ")"
e2lib.log(4, out)
else
- e2lib.log(4, string.format("< %s%s", module, ftbl.name))
+ e2lib.logf(4, "< %s%s", module, ftbl.name)
end
end
function e2lib.cleanup()
local rc, re = plugin.exit_plugins()
if not rc then
- e2lib.logf(1, "deinitializing plugins failed (ignoring)")
+ e2lib.log(1, "deinitializing plugins failed (ignoring)")
end
e2lib.rmtempdirs()
e2lib.rmtempfiles()
c.config = function(x)
c.data = x
end
- e2lib.log(4, string.format("reading global config file: %s", path))
+ e2lib.logf(4, "reading global config file: %s", path)
local rc = e2util.exists(path)
if rc then
- e2lib.log(3, string.format("using global config file: %s", path))
+ e2lib.logf(3, "using global config file: %s", path)
local rc, e = e2lib.dofile_protected(path, c, true)
if not rc then
return nil, e
e2lib.use_global_config()
return true, nil
else
- e2lib.log(4, string.format(
- "global config file does not exist: %s", path))
+ e2lib.logf(4, "global config file does not exist: %s", path)
end
end
return false, "no config file available"
if not devnull then
e2lib.abort("could not open /dev/null")
end
- e2lib.log(3, "+ " .. cmd)
+ e2lib.logf(3, "+ %s", cmd)
pid = e2util.fork()
if pid == 0 then
rc = e2lib.callcmd(devnull, out, out, cmd)
else
o = outfile or ew
end
- e2lib.log(3, "+ " .. cmds[n])
+ e2lib.logf(3, "+ %s", cmds[n])
local pid = e2util.fork()
if pid == 0 then
if n < c then fr:close() end
if not devnull then
e2lib.abort("could not open /dev/null")
end
- e2lib.log(4, "+ " .. cmd)
+ e2lib.logf(4, "+ %s", cmd)
pid = e2util.fork()
if pid == 0 then
oread:close()
filename)
v.tag = match() or e2lib.abort("invalid tag name `", l, "' in e2 version file ",
filename)
- e2lib.log(3, "using e2 branch " .. v.branch .. " tag " .. v.tag)
+ e2lib.logf(3, "using e2 branch %s tag %s", v.branch, v.tag)
return v
end
mktemp:close()
-- register tmp for removing with rmtempfiles() later on
table.insert(e2lib.globals.tmpfiles, tmp)
- e2lib.log(4, string.format("creating temporary file: %s", tmp))
+ e2lib.logf(4, "creating temporary file: %s", tmp)
return tmp
end
for i,v in ipairs(e2lib.globals.tmpfiles) do
if v == tmpfile then
table.remove(e2lib.globals.tmpfiles, i)
- e2lib.log(4, string.format("removing temporary file: %s", tmpfile))
+ e2lib.logf(4, "removing temporary file: %s", tmpfile)
e2lib.rm(tmpfile, "-f")
end
end
mktemp:close()
-- register tmpdir for removing with rmtempdirs() later on
table.insert(e2lib.globals.tmpdirs, tmpdir)
- e2lib.log(4, string.format("creating temporary directory: %s", tmpdir))
+ e2lib.logf(4, "creating temporary directory: %s", tmpdir)
return tmpdir
end
for i,v in ipairs(e2lib.globals.tmpdirs) do
if v == tmpdir then
table.remove(e2lib.globals.tmpdirs, i)
- e2lib.log(4, string.format("removing temporary directory: %s", tmpdir))
+ e2lib.logf(4, "removing temporary directory: %s", tmpdir)
e2lib.rm(tmpdir, "-fr")
end
end
for k,m in ipairs(e.msg) do
if type(m) == "string" then
- e2lib.log(1, string.format("%s%s", prefix, m))
+ e2lib.logf(1, "%s%s", prefix, m)
prefix = string.format(" [%d]: ", depth)
else
-- it's a sub error
-- @return bool
-- @return an error object on failure
function generic_git.git_checkout1(gitwc, branch)
- e2lib.log(3, string.format("checking out branch: %s", branch))
+ e2lib.logf(3, "checking out branch: %s", branch)
-- git checkout <branch>
local cmd = string.format("cd %s && git checkout %s", e2lib.shquote(gitwc),
e2lib.shquote(branch))
-- @return string: the commit id matching the ref parameter, or nil on error
-- @return an error object on failure
function generic_git.git_rev_list1(gitdir, ref)
- e2lib.log(4, string.format("git_rev_list(): %s %s",
- tostring(gitdir), tostring(ref)))
local e = err.new("git rev-list failed")
local rc, re
local tmpfile = e2lib.mktempfile()
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))
+ e2lib.logf(4, "git_rev_list: %s", rev)
else
- e2lib.log(4, string.format("git_rev_list: unknown ref: %s", ref))
+ e2lib.logf(4, "git_rev_list: unknown ref: %s", ref)
end
return rev, nil
end
end
function generic_git.git_remote_add(c, lserver, llocation, name, rserver, rlocation)
- e2lib.log(4, string.format("%s, %s, %s, %s, %s, %s",
- tostring(c), tostring(lserver), tostring(llocation),
- tostring(name), tostring(rserver), tostring(rlocation)))
local rurl, e = cache.remote_url(c, rserver, rlocation)
if not rurl then
e2lib.abort(e)
-- @return string: the git url
-- @return an error object on failure
function generic_git.git_url1(u)
- e2lib.log(4, string.format("git_url(%s)", tostring(u)))
local giturl
if u.transport == "ssh" or u.transport == "scp" or
u.transport == "rsync+ssh" then
-- @return bool, or nil on error
-- @return an error object on failure
function generic_git.verify_remote_tag(gitdir, tag)
- e2lib.logf(4, "generic_git.verify_remote_tag(%s, %s)", tostring(gitdir),
- tostring(tag))
local e = err.new("verifying remote tag")
local rc, re
-- @return bool, or nil on error
-- @return an error object on failure
function generic_git.verify_clean_repository(gitwc)
- e2lib.logf(4, "generic_git.verify_clean_repository(%s)", tostring(gitwc))
gitwc = gitwc or "."
local e = err.new("verifying that repository is clean")
local rc, re
-- @return bool, or nil on error
-- @return an error object on failure
function generic_git.verify_head_match_tag(gitwc, verify_tag)
- e2lib.logf(4, "generic_git.verify_head_match_tag(%s, %s)", tostring(gitwc),
- tostring(verify_tag))
assert(verify_tag)
gitwc = gitwc or "."
local e = err.new("verifying that HEAD matches 'refs/tags/%s'", verify_tag)
-- @return true on success, false on error
-- @return an error object on failure
function transport.fetch_file(surl, location, destdir, destname)
- e2lib.log(4, string.format("%s: %s %s %s", "fetch_file()", surl,
- location, destdir))
if not destname then
destname = e2lib.basename(location)
end
if rc then
done = true
else
- e2lib.logf(4, "Creating hardlink failed. "..
+ e2lib.log(4, "Creating hardlink failed. "..
"Falling back to copying.")
end
end
-- @return true on success, false on error
-- @return nil, an error string on error
function transport.file_path(surl, location)
- e2lib.log(4, string.format("%s: %s %s", "file_path()", surl,
- location))
local e = err.new("can't get path to file")
local u, re = url.parse(surl)
if not u then
local wc_avail = scm.working_copy_available(info, s.name)
if opts.fetch and sel[s.name] then
if wc_avail then
- e2lib.log(1, "working copy for " .. s.name .. " is already available")
+ e2lib.logf(1,
+ "working copy for %s is already available", s.name)
else
- e2lib.log(1, "fetching working copy for source " .. s.name)
+ e2lib.logf(1, "fetching working copy for source %s", s.name)
local rc, re = scm.fetch_source(info, s.name)
if not rc then
- e2lib.log(4, string.format("fetching source failed: %s",
- s.name))
e:cat(re)
end
end
local wc_avail = scm.working_copy_available(info, s.name)
if opts.update and has_wc and sel[s.name] then
if not wc_avail then
- e2lib.log(1, string.format("working copy for %s is not available",
- s.name))
+ e2lib.logf(1, "working copy for %s is not available", s.name)
else
- e2lib.log(1, "updating working copy for " .. s.name)
+ e2lib.logf(1, "updating working copy for %s", s.name)
local rc, re = scm.update(info, s.name)
if not rc then
- e2lib.log(4, string.format("updating working copy failed: %s",
- s.name))
e:cat(re)
end
end
if #arguments > 0 then
for _, x in pairs(arguments) do
if info.sources[x] and not opts.result then
- e2lib.log(3, "is regarded as source: " .. x)
+ e2lib.logf(3, "is regarded as source: %s", x)
sel[x] = x
elseif info.results[x] and opts.result then
- e2lib.log(3, "is regarded as result: " .. x)
+ e2lib.logf(3, "is regarded as result: %s", x)
local res = info.results[x]
for _, s in ipairs(res.sources) do
sel[s] = s
-- @return bool
-- @return an error object on failure
local function result_available(info, r, return_flags)
- e2lib.log(4, string.format("result_available(%s)", tostring(r)))
local res = info.results[r]
local mode = res.build_mode
local buildid = e2tool.buildid(info, r)
-- @return bool
-- @return an error object on failure
function e2build.build_config(info, r)
- e2lib.log(4, string.format("build_config(%s, %s)",
- tostring(info), tostring(r)))
local e = err.new("setting up build configuration for result `%s' failed",
r)
local res = info.results[r]
e2lib.logf(4, "build config for result %s: ", r)
for k,v in pairs(tab) do
v = tostring(v)
- e2lib.log(4, string.format("\t%-10s = %s", k, v))
+ e2lib.logf(4, "\t%-10s = %s", k, v)
end
tab.groups = {}
for _,g in ipairs(res.chroot) do
local res = info.results[r]
local rc, re
local e = err.new("entering playground")
- e2lib.log(4, "entering playground for " .. r .. " ...")
+ e2lib.logf(4, "entering playground for %s ...", r)
local term = e2lib.globals.terminal
local e2_su = tools.get_tool("e2-su-2.2")
local cmd = string.format("%s %s chroot_2_3 %s %s",
local res = info.results[r]
local rc, re
local e = err.new("build failed")
- e2lib.log(3, "building " .. r .. " ...")
+ e2lib.logf(3, "building %s ...", r)
local runbuild = string.format("/bin/bash -e -x %s/%s/%s",
e2lib.shquote(res.build_config.Tc),
e2lib.shquote(res.build_config.scriptdir),
local dep_set = d.build_mode.dep_set(buildid)
local server, location = d.build_mode.storage(info.project_location,
info.release_id)
- e2lib.log(3, string.format("searching for dependency %s in %s:%s",
- dep, server, location))
+ e2lib.logf(3, "searching for dependency %s in %s:%s", dep, server, location)
local location1 = string.format("%s/%s/%s/result.tar", location, dep,
dep_set)
local cache_flags = {}
-- @return bool
-- @return an error object on failure
local function write_build_driver(info, r, destdir)
- e2lib.log(4, "writing build driver")
local res = info.results[r]
local rc, re
local e = err.new("generating build driver script failed")
local res = info.results[r]
local rc, re
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)
for i, dep in pairs(deps) do
--]]
local res = info.results[r]
if not res.build_mode.deploy then
- e2lib.logf(4, "deployment disabled for this build mode")
+ e2lib.log(4, "deployment disabled for this build mode")
return true
end
if not res._deploy then
- e2lib.logf(4, "deployment disabled for this result")
+ e2lib.log(4, "deployment disabled for this result")
return true
end
local files = {}
-- @return bool
-- @return an error object on failure
local function store_result(info, r, return_flags)
- e2lib.logf(4, 'e2_build.store_result(%s, "%s", %s', tostring(info), r,
- tostring(return_flags))
local res = info.results[r]
local rc, re
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
local tmpdir = e2lib.mktempdir()
e2lib.logf(3, "building result: %s", result)
local res = info.results[result]
for _,f in ipairs(build_process) do
- -- e2lib.logf(3, "running function: %s", f.name)
local t1 = os.time()
local flags = {}
local rc, re = f.func(info, result, flags)
e2lib.mkdir(destdir, "-p")
local init_files = e2util.directory(info.root .. "/proj/init")
for _,f in ipairs(init_files) do
- e2lib.log(3, string.format("init file: %s", f))
+ e2lib.logf(3, "init file: %s", f)
local server = "."
local location = string.format("proj/init/%s", f)
local cache_flags = {}
-- generate build driver file for each result
-- project/chroot/<group>/<files>
for _,g in pairs(res.collect_project_chroot_groups) do
- e2lib.log(3, string.format("chroot group: %s", g))
+ e2lib.logf(3, "chroot group: %s", g)
local grp = info.chroot.groups_byname[g]
local destdir = string.format("%s/project/chroot/%s",
res.build_config.T, g)
end
-- project/results/<res>/<files>
for _,n in ipairs(res.collect_project_results) do
- e2lib.log(3, string.format("result: %s", n))
+ e2lib.logf(3, "result: %s", n)
local rn = info.results[n]
rc, re = e2build.build_config(info, n)
if not rc then
end
for _,s in ipairs(info.results[r].collect_project_sources) do
local src = info.sources[s]
- e2lib.log(3, string.format("source: %s", s))
+ e2lib.logf(3, "source: %s", s)
local destdir = string.format("%s/project/%s",
res.build_config.T, e2tool.sourcedir(s))
e2lib.mkdir(destdir, "-p")
local function load_user_config(info, path, dest, index, var)
local rc, re
local e = err.new("loading configuration failed")
- e2lib.log(3, "loading " .. path)
+ e2lib.logf(3, "loading %s", path)
if not e2util.exists(path) then
return false, e:append("file does not exist: %s", path)
end
info.project_location_config)
end
info.project_location = l
- e2lib.log(4, string.format("project location is %s", info.project_location))
+ e2lib.logf(4, "project location is %s", info.project_location)
-- read global interface version and check if this version of the local
-- tools supports the version used for the project
-- @return bool true if verify succeeds, false otherwise
-- @return nil, an error string on error
function e2tool.verify_hash(info, server, location, sha1)
- e2lib.logf(4, "verify_hash %s %s %s %s", tostring(info), tostring(server),
- tostring(location), tostring(sha1))
local rc, re
local e = err.new("error verifying checksum")
local is_sha1, re = hash_file(info, server, location)
-- @param resultname
-- @return the buildid
function e2tool.buildid(info, resultname)
- e2lib.log(4, string.format("get buildid for %s", resultname))
local r = info.results[resultname]
local id, e = e2tool.pbuildid(info, resultname)
if not id then
end
hc:hash_line(fileid)
end
- e2lib.log(4, string.format("hash data for chroot group %s\n%s",
- groupname, hc.data))
+ e2lib.logf(4, "hash data for chroot group %s\n%s", groupname, hc.data)
g.groupid = hc:hash_finish()
return g.groupid
end
-- @param resultname
-- @return the buildid
function e2tool.pbuildid(info, resultname)
- e2lib.log(4, string.format("get pbuildid for %s", resultname))
local e = err.new("error calculating result id for result: %s",
resultname)
local r = info.results[resultname]
hc:hash_line(hash)
end
end
- e2lib.log(4, string.format("hash data for resultid %s\n%s",
- resultname, hc.data))
+ e2lib.logf(4, "hash data for resultid %s\n%s", resultname, hc.data)
r.resultid = hash.hash_finish(hc) -- result id (without deps)
hc = hash.hash_start()
hc:hash_line(hash)
end
end
- e2lib.log(4, string.format("hash data for buildid %s\n%s",
- resultname, hc.data))
+ e2lib.logf(4, "hash data for buildid %s\n%s", resultname, hc.data)
r.pbuildid = hash.hash_finish(hc) -- buildid (with deps)
return r.build_mode.buildid(r.pbuildid)
end
-- @param info
-- @return nothing
function e2tool.calc_buildids(info)
- e2lib.logf(3, "calculating buildids")
+ e2lib.log(3, "calculating buildids")
for _,r in ipairs(info.results) do
local bid, pbid
bid = buildid(info, r)
pbid = e2tool.pbuildid(info, r)
- e2lib.logf(3, "result %20s: pbid(%s) bid(%s)",
- r, e2tool.bid_display(pbid), e2tool.bid_display(bid))
+ e2lib.logf(3, "result %20s: pbid(%s) bid(%s)", r,
+ e2tool.bid_display(pbid), e2tool.bid_display(bid))
end
end
--- add source result.
local function add_source_result(info, sourcename, source_set)
- e2lib.log(3, string.format("adding source result for source %s",
- sourcename))
+ e2lib.logf(3, "adding source result for source %s", sourcename)
local src = info.sources[sourcename]
local r = {}
r.name = string.format("src-%s", src.name)
--- add source results.
local function add_source_results(info, source_set)
- e2lib.log(4, "add source results")
for _, src in pairs(info.sources) do
add_source_result(info, src.name)
end
if not res then
return false, e:append("no such result: %s", r)
end
- local s = res.selected and "[ selected ]" or
- "[dependency]"
+ local s = res.selected and "[ selected ]" or "[dependency]"
local f = res.force_rebuild and "[force rebuild]" or ""
local b = res.request_buildno and "[request buildno]" or ""
local p = res.playground and "[playground]" or ""
- e2lib.log(3, string.format(
- "Selected result: %-20s %s %s %s %s",
- r, s, f, b, p))
+ e2lib.logf(3, "Selected result: %-20s %s %s %s %s", r, s, f, b, p)
end
return true, nil
end
local s = info.sources[sourcename]
-- cache all files for this source
for i,f in pairs(s.file) do
- e2lib.log(4, string.format("files.cache_source: caching file %s:%s",
- f.server, f.location))
+ e2lib.logf(4, "files.cache_source: caching file %s:%s", f.server,
+ f.location)
local flags = { cache = true }
if f.server ~= info.root_server_name then
local rc, e = info.cache:cache_file(f.server, f.location, flags)
return false, e
end
else
- e2lib.log(4, string.format("not caching %s:%s (stored locally)",
- f.server, f.location))
+ e2lib.logf(4, "not caching %s:%s (stored locally)", f.server,
+ f.location)
end
end
return true, nil
return false, e:cat(re)
end
local symlink = nil
- e2lib.log(4, string.format("prepare source: %s", sourcename))
local s = info.sources[sourcename]
for _,file in ipairs(info.sources[sourcename].file) do
if file.sha1 then
hash.hash_line(hc, tostring(f.patch))
hash.hash_line(hc, tostring(f.copy))
end
- e2lib.log(4, string.format("hash data for source %s\n%s", src.name,
- hc.data))
+ e2lib.logf(4, "hash data for source %s\n%s", src.name, hc.data)
src.sourceid = hash.hash_finish(hc)
return true, nil, src.sourceid
end
f:write(string.format(".PHONY: place\n\nplace:\n"))
for _,file in ipairs(s.file) do
- e2lib.log(4, string.format("export file: %s", file.location))
+ e2lib.logf(4, "export file: %s", file.location)
local destdir = string.format("%s/%s", directory, source)
local destname = nil
e2lib.mkdir(destdir, "-p")
if not rc then
return false, e:cat(re)
end
- e2lib.log(4, string.format("export file: %s done",
- file.location))
+ e2lib.logf(4, "export file: %s done", file.location)
end
f:close()
return true, nil
return false, e:cat(re)
end
local wrk = info.root .. "/" .. src.working
- e2lib.log(2, string.format("cloning %s:%s [%s]",
- src.server, src.location, src.branch))
+ e2lib.logf(2, "cloning %s:%s [%s]", src.server, src.location, src.branch)
local skip_checkout = e2lib.globals.git_skip_checkout
rc, re = generic_git.git_clone_from_server(info.cache, src.server,
src.location, wrk, false)
hash.hash_line(hc, src.location)
hash.hash_line(hc, src.working)
hash.hash_line(hc, src.commitid[sourceset])
- e2lib.log(4, string.format("hash data for source %s\n%s", src.name,
- hc.data))
+ e2lib.logf(4, "hash data for source %s\n%s", src.name, hc.data)
src.sourceid[sourceset] = hash.hash_finish(hc)
return true, nil, src.sourceid[sourceset]
end