]> git.e2factory.org Git - e2factory.git/commitdiff
sources: allow assigning environment to sources
authorGordon Hecker <gh@emlix.com>
Tue, 27 Apr 2010 12:56:44 +0000 (14:56 +0200)
committerGordon Hecker <gh@emlix.com>
Thu, 29 Apr 2010 13:30:55 +0000 (15:30 +0200)
This is done by assigning a dictionary to the 'env' attribute
of a source configuration.
The environment configured this way is merged into the environment
of any result that uses the particular source.

BuildId is handled by including the dictionary into the sourceid
calculation.

Signed-off-by: Gordon Hecker <gh@emlix.com>
doc/manual/sources.text
local/cvs.lua
local/e2tool.lua
local/files.lua
local/git.lua
local/svn.lua
templates/local/source.cvs
templates/local/source.files
templates/local/source.git
templates/local/source.svn

index b6687d531adb7a6e924e5273f62aea445aa7ce6d..eee5f679d1a5fc8f05defde3b6511a3a34b836be 100644 (file)
@@ -10,6 +10,8 @@ generic configuration:
 *   type: string
 *   server: string
 *   licences: (old: licence) table of strings
+*   env: dictionary, merged into result specific env for results that use
+         this source
 
 files source (type = files, default)
 
index 08964dc986a1248435cd1a7d869c4136f3123b3b..c43b2247399102c659d0c754688cc84149ede25a 100644 (file)
@@ -322,6 +322,7 @@ function cvs.sourceid(info, sourcename, source_set)
        local hc = hash.hash_start()
        hash.hash_line(hc, src.name)
        hash.hash_line(hc, src.type)
+       hash.hash_line(hc, src._env:id())       
        for _,l in ipairs(src.licences) do
                hash.hash_line(hc, l)
                local licenceid, re = e2tool.licenceid(info, l)
index 5772efd5e1f0b681f613d8e795aef8d1704f8b51..4207f9613f6bc6e51b22e77b69fcdc3b30c7fa73 100644 (file)
@@ -1657,6 +1657,9 @@ function env_by_result(info, resultname)
        local res = info.results[resultname]
        local env = environment.new()
        env:merge(info.global_env, false)
+       for _, s in ipairs(res.sources) do
+               env:merge(info.sources[s]._env, true)
+       end
        env:merge(res._env, true)
        return env
 end
index 1b372f5a32b32c55d366cc89afca9bd3b4514be2..54886a52c38b974cbef358b43e7339db95c0c679 100644 (file)
@@ -324,6 +324,7 @@ function files.sourceid(info, sourcename, sourceset)
        local hc = hash.hash_start()
        hash.hash_line(hc, src.name)
        hash.hash_line(hc, src.type)
+       hash.hash_line(hc, src._env:id())       
        for _,l in ipairs(src.licences) do
                hash.hash_line(hc, l)
                local licenceid, re = e2tool.licenceid(info, l)
index 3ab47582699b5508067a3c63c4542f6f7f4ba9c5..bf9019c91dc1b8cfb83bcadc749d3f134c3f2c19 100644 (file)
@@ -188,6 +188,25 @@ function generic_validate_source(info, sourcename)
   if not src.type then
     e:append("source has no `type' attribute")
   end
+  if src.env and type(src.env) ~= "table" then
+    e:append("source has invalid `env' attribute")
+  else
+    if not src.env then
+      e2lib.warnf("WDEFAULT",
+           "source has no `env' attribute. Defaulting to empty dictionary")
+      src.env = {}
+    end
+    src._env = environment.new()
+    for k,v in pairs(src.env) do
+      if type(k) ~= "string" then
+        e:append("in `env' dictionary: key is not a string: %s", tostring(k))
+      elseif type(v) ~= "string" then
+        e:append("in `env' dictionary: value is not a string: %s", tostring(v))
+      else
+        src._env:set(k, v)
+      end
+    end
+  end
   if e:getcount() > 1 then
     return false, e
   end
@@ -613,6 +632,7 @@ function git.sourceid(info, sourcename, sourceset)
        local hc = hash.hash_start()
        hash.hash_line(hc, src.name)
        hash.hash_line(hc, src.type)
+       hash.hash_line(hc, src._env:id())
        for _,l in ipairs(src.licences) do
                hash.hash_line(hc, l)
                local licenceid, re = e2tool.licenceid(info, l)
index 9f5fa2f341875db8eac4fab002d2c9b2d725b190..47728511080cd8fd5c18826976cc7cc26d04591a 100644 (file)
@@ -219,6 +219,7 @@ function svn.sourceid(info, sourcename, source_set) --OK
        local hc = hash.hash_start()
        hash.hash_line(hc, src.name)
        hash.hash_line(hc, src.type)
+       hash.hash_line(hc, src._env:id())       
        for _,l in pairs(src.licences) do
                hash.hash_line(hc, l)
        end
index a5507b439e4f96a74ea82b466d780517d397d21f..ebb1dddee1a6e47828ca1831c11171d4221db53d 100644 (file)
@@ -7,6 +7,10 @@ e2source {
        name = "name",
        -- the source type
        type = "cvs",
+       -- environment
+       env = {
+               key = "value",
+       },
        -- a list of licences from proj/licences
        licences={ },
        -- cvs specific attributes
index b9421828d2518d4fa891014636f3a6c4d52c8570..846cfa1b76830aadcc190965ae8f19cec4515443 100644 (file)
@@ -7,6 +7,10 @@ e2source {
   name = "name",
   -- the source type
   type = "files",
+  -- environment
+  env = {
+    key = "value",
+  },
   -- a list of licences from proj/licences
   licences = { },
   -- the server. Files can specify their own one or inherit this one.
index 7c61ab479327e76ab334cd923574f6d3318f76e1..87012523ca6714a6937b234ed76fd304e4df3d4a 100644 (file)
@@ -7,6 +7,10 @@ e2source {
        name = "name",
        -- the source type
        type = "git",
+       -- environment
+       env = {
+               key = "value",
+       },
        -- a list of licences from proj/licences
        licences = { },
        -- git specific attributes
index 00853d06d2892cc5efe341f1de27d2c4fed7608a..a8f334d271c411f13676cc95aac6f4c319f10589 100644 (file)
@@ -7,6 +7,10 @@ e2source {
        name = "name",
        -- the source type
        type = "svn",
+       -- environment
+       env = {
+               key = "value",
+       },
        -- a list of licences from proj/licences
        licences={ },
        -- svn specific attributes