From fbc6ac3f9e5d52151b953949bf9b359b8efe10cc Mon Sep 17 00:00:00 2001 From: Gordon Hecker Date: Thu, 29 Apr 2010 10:23:15 +0200 Subject: [PATCH] results: allow assigning environment to results in result configuration This is done by assigning a dictionary to the 'env' attribute of a result configuration. The environment configured this way is merged into the environment and overrides variables from the project wide configuration files. BuildId is handled by merging these variables into the result specific environment before BuildId calculation. Signed-off-by: Gordon Hecker --- doc/manual/results.text | 4 ++++ local/e2tool.lua | 21 +++++++++++++++++++++ templates/local/result | 2 ++ 3 files changed, 27 insertions(+) diff --git a/doc/manual/results.text b/doc/manual/results.text index 43b99a9..d60e917 100644 --- a/doc/manual/results.text +++ b/doc/manual/results.text @@ -9,6 +9,7 @@ following keys: * sources list of sources * chroot list of chroot groups * depends list of dependencies +* env dictionary of environment variables To use the `collect_project` feature the following keys must be used in addition: @@ -47,6 +48,9 @@ Example configuration: depends = { "toolchain", }, + env = { + key = "val", + }, } Example (using the `collect_project` flag) diff --git a/local/e2tool.lua b/local/e2tool.lua index 4207f96..c475cf0 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -1925,6 +1925,27 @@ function check_result(info, resultname) end end end + if res.env and type(res.env) ~= "table" then + e:append("result has invalid `env' attribute") + else + if not res.env then + e2lib.warnf("WDEFAULT", + "result has no `env' attribute. ".. + "Defaulting to empty dictionary") + res.env = {} + end + for k,v in pairs(res.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 + res._env:set(k, v) + end + end + end if not res.buildno then res.bn = {} res.buildno = "0" diff --git a/templates/local/result b/templates/local/result index 01dc2ba..0750b0b 100644 --- a/templates/local/result +++ b/templates/local/result @@ -7,6 +7,8 @@ e2result { depends = { }, -- a list of chroot groups chroot = { }, + -- an environment dictionary + env = { }, -- use the collect_project feature for this result? collect_project = false, -- collect_project_default_result = "", -- 2.39.5