]> git.e2factory.org Git - e2factory.git/commitdiff
move result and source api from e2lib to e2tool library
authorGordon Hecker <gh@emlix.com>
Tue, 12 May 2009 14:00:07 +0000 (16:00 +0200)
committerGordon Hecker <gh@emlix.com>
Tue, 12 May 2009 14:00:07 +0000 (16:00 +0200)
Signed-off-by: Gordon Hecker <gh@emlix.com>
generic/e2lib.lua
local/cf.lua
local/e2build.lua
local/e2tool.lua

index 5cddca011bc3c2a73df0290321a3e91913195ed7..e792d76aa2232a5bd3609a7d61098fcf15fb49e2 100644 (file)
@@ -1852,60 +1852,6 @@ 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 d3a031d869461a14e5cbda853ee0a2bac076d9a1..9e828a6b72c1fdd2b0c167ec8cd826a959ad32af 100755 (executable)
@@ -86,8 +86,8 @@ local function newsource(info, ...)
   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
@@ -120,7 +120,7 @@ local function editsource(info, ...)
   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
@@ -135,9 +135,9 @@ local function newresult(info, ...)
   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
@@ -176,7 +176,7 @@ local function editresult(info, ...)
   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
@@ -191,7 +191,7 @@ local function editbuildscript(info, ...)
   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
index d8aaf08996449ff60a7d0df441db10ae15a2756c..0b75badda075da8999c04bb1c843c623c215008a 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 = 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
@@ -1011,11 +1011,11 @@ function e2build.collect_project(info, r, return_flags)
                        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
@@ -1066,7 +1066,7 @@ function e2build.collect_project(info, r, return_flags)
                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,
index d977009edd3d001e6ba00d2e0b647de3eddd5bb6..bc9de8263a916ee4da7e609fadb54eb47725c391 100644 (file)
@@ -1351,7 +1351,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 = 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
@@ -1700,7 +1700,7 @@ function e2tool.check_result(info, resultname)
                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
@@ -2307,14 +2307,14 @@ 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
@@ -2327,14 +2327,14 @@ end
 
 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
@@ -2364,7 +2364,7 @@ function e2tool.load_source_config(info)
 
   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
@@ -2419,7 +2419,7 @@ function e2tool.load_result_config(info)
 
   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
@@ -2488,3 +2488,57 @@ function e2tool.init_umask(info)
   -- 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