]> git.e2factory.org Git - e2factory.git/commitdiff
adding support for subdirectories in src/ and res/
authorrk@emlix.com <rainer.keller@emlix.com>
Thu, 30 Apr 2009 10:29:18 +0000 (12:29 +0200)
committerrk@emlix.com <rainer.keller@emlix.com>
Mon, 4 May 2009 05:33:03 +0000 (07:33 +0200)
doc/man/e2config.5
doc/manual/results.text
local/e2build.lua
local/e2tool.lua

index 1dfc24dc7c37329c0ea84e8db3007527d911536a..77de84103fce1be1a40f0ae674daca51c001c61c 100644 (file)
@@ -37,12 +37,23 @@ sub-directories:
 |   |   |-- config            result configuration file
 |   |   |-- build-script      build instructions executed in chroot
 |   |   o-- <local file>      project-local files (related to result)
+    |-- <subfolder>           results can be grouped in subfolders
+|   |   o-- <result>          
+|   |   |   |-- config         
+|   |   |   |-- build-script   
+|   |   |   o-- <local file>   
+    |   :
 |   :
 |
 o-- src                       source descriptions for each source
     |-- <source>              one directory for each source
     |   |-- config            source configuration
     |   o-- <local file>      project-local files (related to source)
+    |-- <subfolder>           sources can be groupd in subfolders
+    |   o-- <source>           
+    |   |   |-- config       
+    |   |   o-- <local file> 
+    |   :
     :
 .fi
 
@@ -291,6 +302,11 @@ patches referenced by configuration entries in the "src" directory
 which are to be copied into the build environment.  Only the sources
 given in this property will be copied/extracted.
 
+It is possible to group sources in subfolders. When a folder for a source does
+NOT contain a config file e2 factory tries to search its subfolders for further
+sources. To name sources in subfolders you have to add the foldername to the source name
+separated with a dot (e.g. xorg.libXau). This occurrs when specify sources in the result config.
+
 The properties may omit the "{ ... }" braces, if only a single entry is
 used. Note that you can specify multiple sources for any single result.
 
index 9a55da5e0e68bbd3f7da702bd3fbe7a9b39b0d29..43b99a9264628faaea5bb66f7190e7f411c90c23 100644 (file)
@@ -20,6 +20,11 @@ in addition:
 In addition creating a `build-script` is required. The build script must
 be stored in `./res/<name>/build-script` and runs in the build environment.
 
+It is possible to group the results in subfolders. When a folder for a result does
+NOT contain a config file e2 factory tries to search its subfolders for further
+results. To name results in subfolders you have to add the foldername to the result name
+separated with a dot (e.g. xorg.libXau). This occurrs when specify dependencies oder sources.
+
 The `collect_project` flag provides a tree holding everything to rebuild
 the result configured in `collect_project_default_result` in $E2_TMPDIR/project.
 The user must write a build-script to package that tree to a file in 
index bf59e0d13e4fb9c23148fd60fd8646fbd7cc9b5a..32f92bea55d59bc44d214a7a3d646448279ecd30 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(r)
+    local location = e2lib.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
index 5974ee35a823c51a2b350d0d306eb23ae5e06b07..6b51a64bddd5a644c79ab802ed995e0cddcedb1c 100644 (file)
@@ -134,6 +134,7 @@ local config_syntax_compat = {
 -- @field url string: server url
 -- @field cachable bool: cachable flag
 -- @field cache bool: cache enable flag
+-- @field directory string: dirname where the config and build-script reside
 
 --- table of chroot configuration
 -- @name chroot
@@ -1350,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(resultname)
+               local location = e2lib.resultbuildscript(info.results[resultname].directory)
                local hash, re = e2tool.hash_file(info,info.root_server_name, 
                                                                location)
                if not hash then
@@ -1699,7 +1700,7 @@ function e2tool.check_result(info, resultname)
                res.buildno = "0"
        end
        local build_script = string.format("%s/%s", info.root,
-                                                               e2lib.resultbuildscript(resultname))
+                                                               e2lib.resultbuildscript(info.results[resultname].directory))
        if not e2lib.isfile(build_script) then
                e:append("build-script does not exist: %s", build_script)
        end
@@ -2304,37 +2305,107 @@ function e2tool.check_chroot_config(info)
   return true
 end
 
+local function gather_result_paths(info, basedir, results)
+  results = results or {}
+  for dir in e2lib.directory(info.root .. "/" .. e2lib.resultdir(basedir)) do
+    local tmp
+    if basedir then
+      tmp = basedir .. "/" .. dir
+    else
+      tmp = dir
+    end
+    if e2util.exists(e2lib.resultconfig(tmp)) then
+      table.insert(results, tmp)
+    else
+      --try subfolder
+      gather_result_paths(info,tmp, results)
+    end
+  end
+  return results
+end
+
+
+local function gather_source_paths(info, basedir, sources)
+  sources = sources or {}
+  for dir in e2lib.directory(info.root .. "/" .. e2lib.sourcedir(basedir)) do
+    local tmp
+    if basedir then
+      tmp = basedir .. "/" .. dir
+    else
+      tmp = dir
+    end
+    if e2util.exists(e2lib.sourceconfig(tmp)) then
+      table.insert(sources, tmp)
+    else
+      --try subfolder
+      gather_source_paths(info,tmp, sources)
+    end
+  end
+  return sources
+end
+
+-- checks for valid characters in str
+local function checkFilenameInvalidCharacters(str)
+  if not str:match("^[-_0-9a-zA-Z/]+$") then
+    return false
+  else
+    return true
+  end
+end
+
+-- replaces all slashed in str with dots
+local function slashToDot(str)
+  return string.gsub(str,"/",".",100)
+end
+
 function e2tool.load_source_config(info)
   local e = new_error("error loading source configuration")
   info.sources = {}
-  for src in e2lib.directory(info.root .. "/src") do
+
+  for _,src in ipairs(gather_source_paths(info)) do
     local list, re
     local path = e2lib.sourceconfig(src)
     local types = { "e2source", }
+
+    if not checkFilenameInvalidCharacters(src) then
+        e:append("invalid source file name: %s")
+        e:append("only digits, alphabetic characters, and `-', `_' and `/' "..
+               "are allowed")
+        return false, e
+    end
+
     list, re = e2tool.load_user_config2(info, path, types)
     if not list then
       return false, e:cat(re)
     end
+
+
     for _,item in ipairs(list) do
       local name = item.data.name
+
       if not name and #list == 1 then
        e2lib.warnf("WDEFAULT", "`name' attribute missing in source config.")
        e2lib.warnf("WDEFAULT", " Defaulting to directory name")
-        item.data.name = src
-        name = src
+        item.data.directory = src
+        item.data.name = slashToDot(src)
+        name = slashToDot(src)
       end
+
       if not name then
        return false, e:append("`name' attribute missing in source config")
       end
-      if not name:match("^[-._0-9a-zA-Z]+$") then
+
+      if not name:match("^[-_0-9a-zA-Z.]+$") then
         e:append("invalid source name: %s")
         e:append("only digits, alphabetic characters, and `-', `_' and `.' "..
                "are allowed")
         return false, e
       end
+
       if info.sources[name] then
         return false, e:append("duplicate source: %s", name)
       end
+
       item.data.configfile = item.filename
       info.sources[name] = item.data
     end
@@ -2345,10 +2416,19 @@ end
 function e2tool.load_result_config(info)
   local e = new_error("error loading result configuration")
   info.results = {}
-  for res in e2lib.directory(info.root .. "/" .. e2lib.resultdir()) do
+
+  for _,res in ipairs(gather_result_paths(info)) do
     local list, re
     local path = e2lib.resultconfig(res)
     local types = { "e2result", }
+
+    if not checkFilenameInvalidCharacters(res) then
+        e:append("invalid result file name: %s")
+        e:append("only digits, alphabetic characters, and `-', `_' and `/' "..
+               "are allowed")
+        return false, e
+    end
+
     list, re = e2tool.load_user_config2(info, path, types)
     if not list then
       return false, e:cat(re)
@@ -2358,21 +2438,27 @@ function e2tool.load_result_config(info)
     end
     for _,item in ipairs(list) do
       local name = item.data.name
+      item.data.directory = res
+
       if name and name ~= res then
         e:append("`name' attribute does not match configuration path")
        return false, e
       end
-      item.data.name = res
-      name = res
-      if not name:match("^[-._0-9a-zA-Z]+$") then
+
+      item.data.name = slashToDot(res)
+      name = slashToDot(res)
+
+      if not name:match("^[-_0-9a-zA-Z.]+$") then
         e:append("invalid result name: %s",name)
         e:append("only digits, alphabetic characters, and `-', `_' and `.' "..
                "are allowed")
         return false, e
       end
+
       if info.results[name] then
         return false, e:append("duplicate result: %s", name)
       end
+
       item.data.configfile = item.filename
       info.results[name] = item.data
     end