diff --git a/docs/format-changelog.rst b/docs/format-changelog.rst index 1a70a8a..19b9e09 100644 --- a/docs/format-changelog.rst +++ b/docs/format-changelog.rst @@ -48,3 +48,12 @@ Changed behavior - Using ``multiconfig:*`` targets adds appropriate ``BBMULTICONFIG`` entries to the ``local.conf`` automatically. + +Version 6 +--------- + +Added +~~~~~ + +- ``env`` key now allows to pass custom environment variables to the bitbake + build process. diff --git a/docs/userguide.rst b/docs/userguide.rst index ce9f89b..79b6228 100644 --- a/docs/userguide.rst +++ b/docs/userguide.rst @@ -294,6 +294,11 @@ Configuration reference ``core-image-minimal``. Space is used as a delimiter if multiple targets should be specified via the environment variable. +* ``env``: dict [optional] + Contains environment variable names with the default values. These + variables are made available to bitbake via ``BB_ENV_EXTRAWHITE`` and can + be overwritten by the variables of the environment in which kas is started. + * ``task``: string [optional] Contains the task to build by bitbake. Can be overwritten by the ``KAS_TASK`` environment variable and defaults to ``build``. diff --git a/kas/__version__.py b/kas/__version__.py index 998ff8a..3f3a66c 100644 --- a/kas/__version__.py +++ b/kas/__version__.py @@ -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 diff --git a/kas/config.py b/kas/config.py index 51005ba..510e424 100644 --- a/kas/config.py +++ b/kas/config.py @@ -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 diff --git a/kas/configschema.py b/kas/configschema.py index 36ac67c..2d1e2ab 100644 --- a/kas/configschema.py +++ b/kas/configschema.py @@ -78,6 +78,12 @@ CONFIGSCHEMA = { 'distro': { 'type': 'string', }, + 'env': { + 'type': 'object', + 'additionalProperties': { + 'type': 'string', + }, + }, 'target': { 'oneOf': [ { diff --git a/kas/libkas.py b/kas/libkas.py index 36c42dd..461b396 100644 --- a/kas/libkas.py +++ b/kas/libkas.py @@ -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})