diff mbox series

kernel.bbclass: fix parsing error with KERNEL_SPLIT_MODULES = '0' and multilib enabled

Message ID 20240204052826.1282577-1-Qi.Chen@windriver.com
State New
Headers show
Series kernel.bbclass: fix parsing error with KERNEL_SPLIT_MODULES = '0' and multilib enabled | expand

Commit Message

ChenQi Feb. 4, 2024, 5:28 a.m. UTC
From: Chen Qi <Qi.Chen@windriver.com>

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']

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/classes-recipe/kernel.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Richard Purdie Feb. 4, 2024, 10:20 a.m. UTC | #1
On Sun, 2024-02-04 at 13:28 +0800, Chen Qi via lists.openembedded.org
wrote:
> From: Chen Qi <Qi.Chen@windriver.com>
> 
> 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']
> 
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>  meta/classes-recipe/kernel.bbclass | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
> index a76aaee5ba..7c1cb0ec77 100644
> --- a/meta/classes-recipe/kernel.bbclass
> +++ b/meta/classes-recipe/kernel.bbclass
> @@ -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 () {

I'd prefer not to have "None" floating around as a string value since
that will likely cause other problems, perhaps not now but in the
future.

Also, the kernel should have a version by the time packaging runs yet
this seems to be avoiding that.

The code in multilib_global only operates on a copy of the datastore
for local expansions and the idea is that it would leave
${KERNEL_VERSION} placeholders. Clearly this doesn't work for the avoid
anonymous python pieces.

I wonder what happens if we also delete the above two variables there?

Cheers,

Richard
ChenQi Feb. 5, 2024, 7:18 a.m. UTC | #2
On 2/4/24 18:20, Richard Purdie wrote:
> On Sun, 2024-02-04 at 13:28 +0800, Chen Qi via lists.openembedded.org
> wrote:
>> From: Chen Qi <Qi.Chen@windriver.com>
>>
>> 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']
>>
>> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
>> ---
>>   meta/classes-recipe/kernel.bbclass | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
>> index a76aaee5ba..7c1cb0ec77 100644
>> --- a/meta/classes-recipe/kernel.bbclass
>> +++ b/meta/classes-recipe/kernel.bbclass
>> @@ -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 () {
> I'd prefer not to have "None" floating around as a string value since
> that will likely cause other problems, perhaps not now but in the
> future.
>
> Also, the kernel should have a version by the time packaging runs yet
> this seems to be avoiding that.
>
> The code in multilib_global only operates on a copy of the datastore
> for local expansions and the idea is that it would leave
> ${KERNEL_VERSION} placeholders. Clearly this doesn't work for the avoid
> anonymous python pieces.
>
> I wonder what happens if we also delete the above two variables there?

It works. Thanks. I'll send out V2.

Regards,

Qi

>
> Cheers,
>
> Richard
>
>
>
>
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index a76aaee5ba..7c1cb0ec77 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -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 () {