Message ID | CAOj-5WCRbrpNsHMCox8k-sc3Dr604-pVTt5=iDjaXhf85Ha_Dg@mail.gmail.com |
---|---|
State | New |
Headers | show |
Series | fully fix kernel menuconfig shell composition fault in cml1.bbclass | expand |
TL;DR: Applying the Jaeyoon Jung patch (with fixups) to dunfell or thud does not fix the core problem but breaks even more (thud and dunfell use ' ), but the attached patches do. I'm testing with extra config: KCONFIG_CONFIG_COMMAND_prepend=' X="1 2" ' KCONFIG_CONFIG_COMMAND_prepend=" Y='a b' " and then: bitbake virtual/kernel -c menuconfig The result can then be examined by using ps to locate the make process, and then tr '\0' '\n' < /proc/$PID/cmdline and each line will show one of the "make" arguments, and it is easy to tell whether multi-word arguments have been properly preserved and whether any are missing. I've also tested by adding a false target to KCONFIG_CONFIG_COMMAND KCONFIG_CONFIG_COMMAND_prepend=' zox X="1 2" ' KCONFIG_CONFIG_COMMAND_prepend=" Y='a b' " and ensured that it properly fails with: Command failed. Press any key to continue... The biggest surprise was that without any patch, my extra KCONFIG_CONFIG_COMMAND debug lines causes menuconfig to make the kernel and skip menuconfig (because the command line was truncated), for both thud and dunfell. On thud and dunfell, a patch initially appears un-needed because (at least in my setup) thud is using single quotes for KCONFIG_CONFIG_COMMAND: menuconfig HOSTLDFLAGS='-L.../...' and so double quotes don't exist to terminate that string early. Of course, that means they would both be broken by the original patch, or if double quotes were used in a custom configuration. I've attached a patch suitable for applying to thud, and another for dunfell -- so that single or double quotes can be used. Sam
From a96f41f6d6f0d8308d74a74d736d5a35dc54f0fa Mon Sep 17 00:00:00 2001 From: Sam Liddicott <sam@liddicott.com> Date: Thu, 12 Sep 2024 17:18:37 +0100 Subject: use shlex.quote on KCONFIG_CONFIG_COMMAND for do_menuconfig Although KCONFIG_CONFIG_COMMAND is shell-ready, it needs escaping when composed as part of some shell which is then embedded into an outer "sh -c" in cml1.bbclass This patch uses shlex.quote to escape the entire shell fragment when it is composed in the inner "sh -c" Signed-off-by: Sam Liddicott <sam@liddicott.com> --- meta/classes-recipe/cml1.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/classes-recipe/cml1.bbclass b/meta/classes-recipe/cml1.bbclass index d319d66ab2..f6727c5c33 100644 --- a/meta/classes-recipe/cml1.bbclass +++ b/meta/classes-recipe/cml1.bbclass @@ -36,4 +36,5 @@ KCONFIG_CONFIG_ENABLE_MENUCONFIG ??= "true" KCONFIG_CONFIG_ROOTDIR ??= "${B}" python do_menuconfig() { import shutil + import shlex @@ -48,5 +49,5 @@ python do_menuconfig() { # ensure that environment variables are overwritten with this tasks 'd' values d.appendVar("OE_TERMINAL_EXPORTS", " PKG_CONFIG_DIR PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR") - oe_terminal("sh -c 'make %s; if [ \\$? -ne 0 ]; then echo \"Command failed.\"; printf \"Press any key to continue... \"; read r; fi'" % d.getVar('KCONFIG_CONFIG_COMMAND'), + oe_terminal('sh -c %s' % shlex.quote("make %s; if [ $? -ne 0 ]; then echo 'Command failed.'; printf 'Press any key to continue... '; read r; fi" % d.getVar('KCONFIG_CONFIG_COMMAND')), d.getVar('PN') + ' Configuration', d) -- 2.43.0