return true, nil
end
--- assemble a path from parts
--- the returned string is created from the input parameters like
--- "base[/str][/postfix]"
-local function generatePath(base, str, postfix)
- if str then
- base = base .. "/" .. str
- end
- if postfix then
- base = base .. "/" .. postfix
- end
- return base
-end
-
--- get directory for a result
--- Returns the path to the resultdir and the optional postfix is appended
--- with a slash (e.g. res/name/build-script)
--- @param result name optional
--- @param optional postfix for the direcory
--- @return path of the result
-function e2lib.resultdir(name, postfix)
- return generatePath("res",name,postfix)
-end
-
--- get directory for a source
--- Returns the path to the sourcedir and the optional postfix is appended
--- with a slash (e.g. src/name/config)
--- @param source name optional
--- @param optional postfix for the direcory
--- @return path of the source
-function e2lib.sourcedir(name, postfix)
- return generatePath("src",name,postfix)
-end
-
--- get path to the result config
--- @param resultname
--- @return path to the resultconfig
-function e2lib.resultconfig(name)
- return e2lib.resultdir(name,"config")
-end
-
--- get path to the result build-script
--- @param resultname
--- @return path to the result build-script
-function e2lib.resultbuildscript(name)
- return e2lib.resultdir(name,"build-script")
-end
-
--- get path to the source config
--- @param sourcename
--- @return path to the sourceconfig
-function e2lib.sourceconfig(name)
- return e2lib.sourcedir(name,"config")
-end
-
--------------------------------------------------------------------------------
-- "seal" modules e2util and e2lib
if e:getcount() > 1 then
return false, e
end
- local cfdir = e2lib.sourcedir(name)
- local cf = e2lib.sourceconfig(name)
+ local cfdir = e2tool.sourcedir(name)
+ local cf = e2tool.sourceconfig(name)
local cftemplate = string.format("%s/source.%s", info.local_template_path,
scm)
if not e2lib.isfile(cftemplate) then
if e:getcount() > 1 then
return false, e
end
- local cf = e2lib.sourceconfig(name)
+ local cf = e2tool.sourceconfig(name)
rc = os.execute(string.format("%s %s", editor, cf))
return true, nil
end
if e:getcount() > 1 then
return false, e
end
- local cfdir = e2lib.resultdir(name)
- local cf = e2lib.resultconfig(name)
- local bs = e2lib.resultbuildscript(name)
+ local cfdir = e2tool.resultdir(name)
+ local cf = e2tool.resultconfig(name)
+ local bs = e2tool.resultbuildscript(name)
local cftemplate = string.format("%s/result", info.local_template_path)
local bstemplate = string.format("%s/build-script", info.local_template_path)
if not e2lib.isfile(cf) and not e2lib.isfile(bs) and
if e:getcount() > 1 then
return false, e
end
- local cf = e2lib.resultconfig(name)
+ local cf = e2tool.resultconfig(name)
os.execute(string.format("%s %s", editor, cf))
return true, nil
end
if e:getcount() > 1 then
return false, e
end
- local cf = e2lib.resultbuildscript(name)
+ local cf = e2tool.resultbuildscript(name)
os.execute(string.format("%s %s", editor, cf))
return true, nil
end
local res = info.results[r]
local rc, re
local e = new_error("installing build script")
- local location = e2lib.resultbuildscript(info.results[r].directory)
+ 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)
if not rc then
return false, e:cat(re)
end
local destdir = string.format("%s/project/%s",
- res.build_config.T, e2lib.resultdir(n))
+ res.build_config.T, e2tool.resultdir(n))
e2lib.mkdir(destdir, "-p")
-- copy files
local files = {
- e2lib.resultbuildscript(info.results[n].directory)
+ e2tool.resultbuildscript(info.results[n].directory)
}
for _,file in pairs(files) do
local server = info.root_server_name
local src = info.sources[s]
e2lib.log(3, string.format("source: %s", s))
local destdir = string.format("%s/project/%s",
- res.build_config.T, e2lib.sourcedir(s))
+ res.build_config.T, e2tool.sourcedir(s))
e2lib.mkdir(destdir, "-p")
local source_set = res.build_mode.source_set()
local files, re = scm.toresult(info, src.name, source_set,
r.envid = e2tool.envid(info, resultname)
hc:hash_line(r.envid)
if not r.pseudo_result then
- local location = e2lib.resultbuildscript(info.results[resultname].directory)
+ local location = e2tool.resultbuildscript(info.results[resultname].directory)
local hash, re = e2tool.hash_file(info,info.root_server_name,
location)
if not hash then
res.buildno = "0"
end
local build_script = string.format("%s/%s", info.root,
- e2lib.resultbuildscript(info.results[resultname].directory))
+ e2tool.resultbuildscript(info.results[resultname].directory))
if not e2lib.isfile(build_script) then
e:append("build-script does not exist: %s", build_script)
end
local function gather_result_paths(info, basedir, results)
results = results or {}
- for dir in e2lib.directory(info.root .. "/" .. e2lib.resultdir(basedir)) do
+ for dir in e2lib.directory(info.root .. "/" .. e2tool.resultdir(basedir)) do
local tmp
if basedir then
tmp = basedir .. "/" .. dir
else
tmp = dir
end
- if e2util.exists(e2lib.resultconfig(tmp)) then
+ if e2util.exists(e2tool.resultconfig(tmp)) then
table.insert(results, tmp)
else
--try subfolder
local function gather_source_paths(info, basedir, sources)
sources = sources or {}
- for dir in e2lib.directory(info.root .. "/" .. e2lib.sourcedir(basedir)) do
+ for dir in e2lib.directory(info.root .. "/" .. e2tool.sourcedir(basedir)) do
local tmp
if basedir then
tmp = basedir .. "/" .. dir
else
tmp = dir
end
- if e2util.exists(e2lib.sourceconfig(tmp)) then
+ if e2util.exists(e2tool.sourceconfig(tmp)) then
table.insert(sources, tmp)
else
--try subfolder
for _,src in ipairs(gather_source_paths(info)) do
local list, re
- local path = e2lib.sourceconfig(src)
+ local path = e2tool.sourceconfig(src)
local types = { "e2source", }
if not checkFilenameInvalidCharacters(src) then
for _,res in ipairs(gather_result_paths(info)) do
local list, re
- local path = e2lib.resultconfig(res)
+ local path = e2tool.resultconfig(res)
local types = { "e2result", }
if not checkFilenameInvalidCharacters(res) then
-- restore the previous umask value again
e2util.umask(info.host_umask);
end
+
+-- assemble a path from parts
+-- the returned string is created from the input parameters like
+-- "base[/str][/postfix]"
+local function generatePath(base, str, postfix)
+ if str then
+ base = base .. "/" .. str
+ end
+ if postfix then
+ base = base .. "/" .. postfix
+ end
+ return base
+end
+
+-- get directory for a result
+-- Returns the path to the resultdir and the optional postfix is appended
+-- with a slash (e.g. res/name/build-script)
+-- @param result name optional
+-- @param optional postfix for the direcory
+-- @return path of the result
+function e2tool.resultdir(name, postfix)
+ return generatePath("res",name,postfix)
+end
+
+-- get directory for a source
+-- Returns the path to the sourcedir and the optional postfix is appended
+-- with a slash (e.g. src/name/config)
+-- @param source name optional
+-- @param optional postfix for the direcory
+-- @return path of the source
+function e2tool.sourcedir(name, postfix)
+ return generatePath("src",name,postfix)
+end
+
+-- get path to the result config
+-- @param resultname
+-- @return path to the resultconfig
+function e2tool.resultconfig(name)
+ return e2tool.resultdir(name,"config")
+end
+
+-- get path to the result build-script
+-- @param resultname
+-- @return path to the result build-script
+function e2tool.resultbuildscript(name)
+ return e2tool.resultdir(name,"build-script")
+end
+
+--- get path to the source config
+-- @param sourcename
+-- @return path to the sourceconfig
+function e2tool.sourceconfig(name)
+ return e2tool.sourcedir(name,"config")
+end