From: rk@emlix.com Date: Wed, 29 Apr 2009 14:08:01 +0000 (+0200) Subject: remove "res/" string X-Git-Tag: e2factory-2.3.1pre1~36 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=34cccac403ae11badf393b2131440056c32d2af7;p=e2factory.git remove "res/" string remove "src/" string --- diff --git a/generic/e2lib.lua b/generic/e2lib.lua index 6dfc6d9..9d0bc92 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -1797,6 +1797,60 @@ function e2lib.chdir(path) 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 diff --git a/local/cf.lua b/local/cf.lua index 965cdc7..d3a031d 100755 --- a/local/cf.lua +++ b/local/cf.lua @@ -86,8 +86,8 @@ local function newsource(info, ...) if e:getcount() > 1 then return false, e end - local cfdir = string.format("src/%s", name) - local cf = string.format("src/%s/config", name) + local cfdir = e2lib.sourcedir(name) + local cf = e2lib.sourceconfig(name) local cftemplate = string.format("%s/source.%s", info.local_template_path, scm) if not e2lib.isfile(cftemplate) then @@ -120,7 +120,7 @@ local function editsource(info, ...) if e:getcount() > 1 then return false, e end - local cf = string.format("src/%s/config", name) + local cf = e2lib.sourceconfig(name) rc = os.execute(string.format("%s %s", editor, cf)) return true, nil end @@ -135,9 +135,9 @@ local function newresult(info, ...) if e:getcount() > 1 then return false, e end - local cfdir = string.format("res/%s", name) - local cf = string.format("res/%s/config", name) - local bs = string.format("res/%s/build-script", name) + local cfdir = e2lib.resultdir(name) + local cf = e2lib.resultconfig(name) + local bs = e2lib.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 @@ -176,7 +176,7 @@ local function editresult(info, ...) if e:getcount() > 1 then return false, e end - local cf = string.format("res/%s/config", name) + local cf = e2lib.resultconfig(name) os.execute(string.format("%s %s", editor, cf)) return true, nil end @@ -191,7 +191,7 @@ local function editbuildscript(info, ...) if e:getcount() > 1 then return false, e end - local cf = string.format("res/%s/build-script", name) + local cf = e2lib.resultbuildscript(name) os.execute(string.format("%s %s", editor, cf)) return true, nil end diff --git a/local/e2build.lua b/local/e2build.lua index a92d2b9..bf59e0d 100644 --- a/local/e2build.lua +++ b/local/e2build.lua @@ -447,7 +447,7 @@ function e2build.sources(info, r, return_flags) local res = info.results[r] local rc, re local e = new_error("installing build script") - local location = string.format("res/%s/build-script", r) + local location = e2lib.resultbuildscript(r) 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 @@ -1010,12 +1010,12 @@ function e2build.collect_project(info, r, return_flags) if not rc then return false, e:cat(re) end - local destdir = string.format("%s/project/res/%s", - res.build_config.T, n) + local destdir = string.format("%s/project/%s", + res.build_config.T, e2lib.resultdir(n)) e2lib.mkdir(destdir, "-p") -- copy files local files = { - string.format("res/%s/build-script", n), + e2lib.resultbuildscript(n), } for _,file in pairs(files) do local server = info.root_server_name @@ -1065,8 +1065,8 @@ function e2build.collect_project(info, r, return_flags) for _,s in ipairs(info.results[r].collect_project_sources) do local src = info.sources[s] e2lib.log(3, string.format("source: %s", s)) - local destdir = string.format("%s/project/src/%s", - res.build_config.T, s) + local destdir = string.format("%s/project/%s", + res.build_config.T, e2lib.sourcedir(s)) e2lib.mkdir(destdir, "-p") local source_set = res.build_mode.source_set() local files, re = scm.toresult(info, src.name, source_set, diff --git a/local/e2tool.lua b/local/e2tool.lua index e774ce6..a456ad4 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -1350,8 +1350,7 @@ function e2tool.pbuildid(info, resultname) r.envid = e2tool.envid(info, resultname) hc:hash_line(r.envid) if not r.pseudo_result then - local location = string.format("res/%s/build-script", - resultname) + local location = e2lib.resultbuildscript(resultname) local hash, re = e2tool.hash_file(info,info.root_server_name, location) if not hash then @@ -1699,8 +1698,8 @@ function e2tool.check_result(info, resultname) res.bn = {} res.buildno = "0" end - local build_script = string.format("%s/res/%s/build-script", info.root, - resultname) + local build_script = string.format("%s/%s", info.root, + e2lib.resultbuildscript(resultname)) if not e2lib.isfile(build_script) then e:append("build-script does not exist") end @@ -2310,7 +2309,7 @@ function e2tool.load_source_config(info) info.sources = {} for src in e2lib.directory(info.root .. "/src") do local list, re - local path = string.format("src/%s/config", src) + local path = e2lib.sourceconfig(src) local types = { "e2source", } list, re = e2tool.load_user_config2(info, path, types) if not list then @@ -2346,9 +2345,9 @@ end function e2tool.load_result_config(info) local e = new_error("error loading result configuration") info.results = {} - for res in e2lib.directory(info.root .. "/res") do + for res in e2lib.directory(info.root .. "/" .. e2lib.resultdir()) do local list, re - local path = string.format("res/%s/config", res) + local path = e2lib.resultconfig(res) local types = { "e2result", } list, re = e2tool.load_user_config2(info, path, types) if not list then