kas-container: track repo dir when using menu cmd

When using the kas menu command, we need to track the repository
location outside of the kas container as well. This is required to
prepare the environment for a later kas-container build, as the repo
path inside the container is different from the outside one. For that,
the location of KAS_REPO_DIR is passed via an env-var into the container.
There, this value is picked up by the menu plugin and written to the
.config.yaml file as `_source_host_dir`. When running kas-container build,
we check if the .config.yaml file contains this node and set the
KAS_REPO_DIR accordingly. The schema is extended accordingly.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
[Jan: rework _source_dir_host extraction to make it usable for menu as well]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Felix Moessbauer
2023-05-26 06:39:43 +02:00
committed by Jan Kiszka
parent e274886ab0
commit e9032bc278
6 changed files with 38 additions and 2 deletions

View File

@@ -42,6 +42,7 @@ __license__ = 'MIT'
__copyright__ = 'Copyright (c) Siemens AG, 2017-2021'
SOURCE_DIR_OVERRIDE_KEY = '_source_dir'
SOURCE_DIR_HOST_OVERRIDE_KEY = '_source_dir_host'
class LoadConfigException(KasUserError):

View File

@@ -77,7 +77,7 @@ from kas.context import create_global_context
from kas.config import CONFIG_YAML_FILE
from kas.repos import Repo
from kas.includehandler import load_config as load_config_yaml, \
SOURCE_DIR_OVERRIDE_KEY
SOURCE_DIR_OVERRIDE_KEY, SOURCE_DIR_HOST_OVERRIDE_KEY
from kas.plugins.build import Build
from kas.kasusererror import KasUserError
@@ -91,7 +91,9 @@ except ImportError:
__license__ = 'MIT'
__copyright__ = \
'Copyright (c) 2011-2019, Ulf Magnusson <ulfalizer@gmail.com>\n' \
'Copyright (c) Siemens AG, 2021'
'Copyright (c) Siemens AG, 2021-2023'
SOURCE_DIR_HOST_ENV_KEY = '_KAS_REPO_DIR_HOST'
class VariableTypeError(KasUserError):
@@ -219,6 +221,10 @@ class Menu:
'menu_configuration': menu_configuration,
SOURCE_DIR_OVERRIDE_KEY: top_repo_dir
}
if SOURCE_DIR_HOST_ENV_KEY in os.environ:
config[SOURCE_DIR_HOST_OVERRIDE_KEY] = \
os.environ[SOURCE_DIR_HOST_ENV_KEY]
if kas_build_system:
config['build_system'] = kas_build_system
if len(kas_targets) > 0:

View File

@@ -272,6 +272,9 @@
},
"_source_dir": {
"type": "string"
},
"_source_dir_host": {
"type": "string"
}
}
}