Skip to contentSkip to conversation

kernel.bbclass: fix parsing error with no module split in multilib

PATCH New [email protected] 1 participant 1 message Feb 4, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kernel.bbclass: fix parsing error with no module split in multilib

From: Chen Qi <[email protected]>

The problem could be reproduced with the following settings:
MACHINE = "qemux86-64"
KERNEL_SPLIT_MODULES = "0"
require conf/multilib.conf
MULTILIBS ?= "multilib:lib32" DEFAULTTUNE:virtclass-multilib-lib32 ?= "core2-32"

The error message is as below:
bb.data_smart.ExpansionError: Failure expanding variable KERNEL_VERSION_PKG_NAME, expression was ${@legitimize_package_name(d.getVar('KERNEL_VERSION'))} which triggered exception TypeError: expected string or bytes-like object The variable dependency chain for the failure is: KERNEL_VERSION_PKG_NAME -> RPROVIDES:kernel-modules

This is because multilib_virtclass_handler_global function in multilib_global.bbclass deletes KERNEL_VERSION. So we need to handle such situation.

The KERNEL_VERSION is defined as:
KERNEL_VERSION = "${@get_kernelversion_headers('${B}')}" So in a clean build directory, its initial value is "None". We should sync other settings to this value. If we use '', then what we'll get error like below with the above settings:

ERROR: Required build target 'core-image-minimal' has no buildable providers.
Missing or unbuildable dependency chain was: ['core-image-minimal', 'virtual/kernel', 'kernel-modules-none']

---
 meta/classes-recipe/kernel.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes-recipe/kernel.bbclass +2 -2
index a76aaee5ba..7c1cb0ec77 100644
@@ -44,9 +44,9 @@ INITRAMFS_MULTICONFIG ?= ""
 # number and cause kernel to be rebuilt. To avoid this, make
 # KERNEL_VERSION_NAME and KERNEL_VERSION_PKG_NAME depend on
 # LINUX_VERSION which is a constant.
-KERNEL_VERSION_NAME = "${@d.getVar('KERNEL_VERSION') or ""}"
+KERNEL_VERSION_NAME = "${@d.getVar('KERNEL_VERSION') or 'None'}"
 KERNEL_VERSION_NAME[vardepvalue] = "${LINUX_VERSION}"
-KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION'))}"
+KERNEL_VERSION_PKG_NAME = "${@legitimize_package_name(d.getVar('KERNEL_VERSION') or 'None')}"
 KERNEL_VERSION_PKG_NAME[vardepvalue] = "${LINUX_VERSION}"
 
 python __anonymous () {
Signature · 1 line
2.34.1