From 1d0631ef96920e0a79b33c7225496b5fbe9bea9c Mon Sep 17 00:00:00 2001 From: Javier Viguera Date: Tue, 12 Mar 2024 18:02:37 +0100 Subject: [PATCH] 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 --- meta-digi-arm/recipes-bsp/u-boot/u-boot-dey.inc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey.inc b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey.inc index 6d39f2e6e..c36d8f3da 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey.inc +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey.inc @@ -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) }