u-boot-dey: support Trustfence config options with spaces

The standard string split() function does not support splitting a string
by spaces but preserving quoted strings, so it does not work for build
options disabling functionality, as they have this format:

"# CONFIG_OPTION is not set"

On the other hand, the "shlex" module provides a split function that
allows splitting strings by spaces and, at the same time, preserves
quoted strings.

In Trustfence, we need this functionality to disable default options that
would allow the booting of non-authenticated images.

https://onedigi.atlassian.net/browse/DEL-8704

Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
Javier Viguera 2024-03-12 18:02:37 +01:00
parent f67d59d7b8
commit 1d0631ef96
1 changed files with 5 additions and 1 deletions

View File

@ -49,9 +49,13 @@ python __anonymous() {
do_configure[prefuncs] += "${@oe.utils.ifelse(d.getVar('UBOOT_TF_CONF'), 'trustfence_config', '')}"
python trustfence_config() {
import shlex
config_path = d.expand('${WORKDIR}/uboot-trustfence.cfg')
with open(config_path, 'w') as f:
for cfg in d.getVar('UBOOT_TF_CONF').split():
for cfg in shlex.split(d.getVar('UBOOT_TF_CONF'), posix=False):
# strip quotes for "is not set" options
if 'is not set' in cfg:
cfg = cfg.strip('"\'')
f.write('%s\n' % cfg)
d.appendVar('SRC_URI', ' file://%s' % config_path)
}