implementation of environment variable passthrough

With this its possible to create custom environment variables within the kas
configuration file, that are passed through to the build environment:

    env:
      VARIABLE_NAME: "default variable value"

Those variables can be overwritten by variables of the environment kas is
started in:

    $ VARIABLE_NAME="overwritten variable value" kas shell ...

Those variables are also added to the 'BB_ENV_EXTRAWHITE' variable list to make
them available to bitbake.

This is useful for instance storing sensitive information, that should not be
part of the configuration files or bitbake recipes.

Signed-off-by: Claudius Heine <ch@denx.de>
This commit is contained in:
Claudius Heine
2017-11-23 14:15:51 +01:00
committed by Daniel Wagner
parent cd076101f4
commit 95015045db
6 changed files with 35 additions and 1 deletions

View File

@@ -28,5 +28,5 @@ __copyright__ = 'Copyright (c) Siemens AG, 2017'
__version__ = '0.14.0'
# Please update docs/format-changelog.rst when changing the file version.
__file_version__ = 5
__file_version__ = 6
__compatible_file_version__ = 1

View File

@@ -277,6 +277,14 @@ class Config:
return os.environ.get('KAS_DISTRO',
self._config.get('distro', 'poky'))
def get_environment(self):
"""
Returns the configured environment variables from the configuration
file, with possible overwritten values from the environment.
"""
env = self._config.get('env', {})
return {var: os.environ.get(var, env[var]) for var in env}
def get_multiconfig(self):
"""
Returns the multiconfig array as bitbake string

View File

@@ -78,6 +78,12 @@ CONFIGSCHEMA = {
'distro': {
'type': 'string',
},
'env': {
'type': 'object',
'additionalProperties': {
'type': 'string',
},
},
'target': {
'oneOf': [
{

View File

@@ -306,7 +306,13 @@ def get_build_environ(config, build_dir):
except ValueError:
pass
conf_env = config.get_environment()
env_vars = ['SSTATE_DIR', 'DL_DIR', 'TMPDIR']
env_vars.extend(conf_env)
env.update(conf_env)
if 'BB_ENV_EXTRAWHITE' in env:
extra_white = env['BB_ENV_EXTRAWHITE'] + ' '.join(env_vars)
env.update({'BB_ENV_EXTRAWHITE': extra_white})