]> git.e2factory.org Git - e2factory.git/commitdiff
remove "res/" string
authorrk@emlix.com <rainer.keller@emlix.com>
Wed, 29 Apr 2009 14:08:01 +0000 (16:08 +0200)
committerrk@emlix.com <rainer.keller@emlix.com>
Thu, 30 Apr 2009 06:06:17 +0000 (08:06 +0200)
remove "src/" string

generic/e2lib.lua
local/cf.lua
local/e2build.lua
local/e2tool.lua

index 6dfc6d9b79155be10accfc187208fd8be29b2d97..9d0bc920f2668b2657351d3827066f287db7f500 100644 (file)
@@ -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
index 965cdc70d1d567f4608bb1250fd408caa4d0798c..d3a031d869461a14e5cbda853ee0a2bac076d9a1 100755 (executable)
@@ -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
index a92d2b916e9afa6d419fbc2a9b01f1bd4058d741..bf59e0d13e4fb9c23148fd60fd8646fbd7cc9b5a 100644 (file)
@@ -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,
index e774ce673e11ccacaae60e276d0dc1df16a18eea..a456ad41029c2e58c3b38a15d7b8d62fab043886 100644 (file)
@@ -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