Skip to contentSkip to conversation

kernel.bbclass: run read_package_metadata only if packaging is enabled

PATCH In review Andrea Adami 5 participants 10 messages Jun 22, 2021 – Jun 23, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 kernel.bbclass: run read_package_metadata only if packaging is enabled

As exposed in the ML
https://lists.openembedded.org/g/openembedded-core/message/153000

up to commit 86142da in Gatesgarth it was possible to build a second mini-kernel w/out modules to be just deployed and collected by other recipes.

These kernels use special care to avoid packaging:

inherit nopackages

PACKAGES = ""
PROVIDES = ""

Now the change in kernel.bblass calls a packaging routine:
do_deploy[prefuncs] += "read_subpackage_metadata"

As a result the kernel build fails.

Fix this using bb.data.inherits_class() to verify the possible previous inherit of nopackages.bbclass.

---
 meta/classes/kernel.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/kernel.bbclass +2 -2
index 379bed44f2..06e6446a08 100644
@@ -771,8 +771,8 @@ kernel_do_deploy() {
 }
 
 # We deploy to filenames that include PKGV and PKGR, read the saved data to
-# ensure we get the right values for both
-do_deploy[prefuncs] += "read_subpackage_metadata"
+# ensure we get the right values for both. Do this only if packaging is enabled.
+do_deploy[prefuncs] += "${@ '' if bb.data.inherits_class('nopackages', d) else 'read_subpackage_metadata' }"
 
 addtask deploy after do_populate_sysroot do_packagedata
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/2 kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Now it unconditionally tries to create package kernel-devicetre even for legacy devices w/out DT.

---
 meta/classes/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel.bbclass +1 -1
index 06e6446a08..68369e3791 100644
@@ -779,4 +779,4 @@ addtask deploy after do_populate_sysroot do_packagedata
 EXPORT_FUNCTIONS do_deploy
 
 # Add using Device Tree support
-inherit kernel-devicetree
+inherit ${@ "" if d.getVar("KERNEL_DEVICETREE" == "") else "kernel-devicetree" }
Signature · 1 line
2.17.1
#2 lore raw

Re: [OE-core][PATCH 2/2] kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Quoted 25 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Andrea Adami
Sent: den 23 juni 2021 00:18
To: [email protected]
Subject: [OE-core][PATCH 2/2] kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Now it unconditionally tries to create package kernel-devicetre even for legacy devices w/out DT.

---
 meta/classes/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel.bbclass +0 -0
index 06e6446a08..68369e3791 100644
@@ -779,4 +779,4 @@ addtask deploy after do_populate_sysroot

do_packagedata
EXPORT_FUNCTIONS do_deploy

# Add using Device Tree support

meta/classes/kernel.bbclass addtask deploy after do_populate_sysroot do_packagedata · line 782

Quoted 2 lines
meta/classes/kernel.bbclass +1 -1
-inherit kernel-devicetree
+inherit ${@ "" if d.getVar("KERNEL_DEVICETREE" == "") else "kernel-devicetree" }

That doesn't look correct. Don't you mean something like this:

inherit ${@ "kernel-devicetree" if d.getVar("KERNEL_DEVICETREE") else "" }

Quoted 2 lines

--
2.17.1

//Peter

#3 lore raw

Re: [OE-core][PATCH 2/2] kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Quoted 25 lines · Peter Kjellerstedt
Quoted 25 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Andrea Adami
Sent: den 23 juni 2021 00:18
To: [email protected]
Subject: [OE-core][PATCH 2/2] kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Now it unconditionally tries to create package kernel-devicetre even for legacy devices w/out DT.

---
 meta/classes/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel.bbclass +0 -0
index 06e6446a08..68369e3791 100644
@@ -779,4 +779,4 @@ addtask deploy after do_populate_sysroot

do_packagedata
EXPORT_FUNCTIONS do_deploy

Quoted 8 lines

meta/classes/kernel.bbclass addtask deploy after do_populate_sysroot do_packagedata · line 782

Quoted 3 lines

# Add using Device Tree support

meta/classes/kernel.bbclass +1 -1
-inherit kernel-devicetree
+inherit ${@ "" if d.getVar("KERNEL_DEVICETREE" == "") else "kernel-devicetree" }

That doesn't look correct. Don't you mean something like this:

inherit ${@ "kernel-devicetree" if d.getVar("KERNEL_DEVICETREE") else "" }

As you prefer, I don't think bitbake has likely/unlikely optimization. I took the style-example from line 6 where it reads

KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else d.getVar("KERNEL_PACKAGE_NAME") }"

I am for any option providing a guard.

Cheers
A.A.

Quoted 5 lines
Quoted 2 lines

--
2.17.1

//Peter

#4 lore raw

Re: [OE-core][PATCH 2/2] kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Hello Andrea,

Quoted 37 lines · Andrea Adami
Quoted 25 lines · Peter Kjellerstedt
Quoted 25 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Andrea Adami
Sent: den 23 juni 2021 00:18
To: [email protected]
Subject: [OE-core][PATCH 2/2] kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Now it unconditionally tries to create package kernel-devicetre even for legacy devices w/out DT.

---
 meta/classes/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel.bbclass +0 -0
index 06e6446a08..68369e3791 100644
@@ -779,4 +779,4 @@ addtask deploy after do_populate_sysroot

do_packagedata
EXPORT_FUNCTIONS do_deploy

Quoted 8 lines

meta/classes/kernel.bbclass addtask deploy after do_populate_sysroot do_packagedata · line 782

Quoted 3 lines

# Add using Device Tree support

meta/classes/kernel.bbclass +1 -1
-inherit kernel-devicetree
+inherit ${@ "" if d.getVar("KERNEL_DEVICETREE" == "") else "kernel-devicetree" }

That doesn't look correct. Don't you mean something like this:

inherit ${@ "kernel-devicetree" if d.getVar("KERNEL_DEVICETREE") else "" }

Quoted 7 lines

As you prefer, I don't think bitbake has likely/unlikely optimization. I took the style-example from line 6 where it reads

KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else d.getVar("KERNEL_PACKAGE_NAME") }"

I am for any option providing a guard.

I guess you've missed the closing bracket in your statement, please take a look at the comparison operator.

As yet another option, maybe even something like this:
inherit ${@oe.utils.ifelse(d.getVar('KERNEL_DEVICETREE') == '', '', 'kernel-devicetree')}

However, I'm not sure what would happened if KERNEL_DEVICETREE is undefined, as in this case bitbake should return "None" according to the documentation.

Quoted 13 lines

Cheers
A.A.

Quoted 5 lines
Quoted 2 lines

--
2.17.1

//Peter

Signature · 2 lines
Regards,
Andrey.
#5 lore raw

Re: [OE-core][PATCH 2/2] kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Quoted 44 lines · Andrey Zhizhikin

Hello Andrea,

Quoted 40 lines · Andrea Adami
Quoted 25 lines · Peter Kjellerstedt
Quoted 25 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Andrea Adami
Sent: den 23 juni 2021 00:18
To: [email protected]
Subject: [OE-core][PATCH 2/2] kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Now it unconditionally tries to create package kernel-devicetre even for legacy devices w/out DT.

---
 meta/classes/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel.bbclass +0 -0
index 06e6446a08..68369e3791 100644
@@ -779,4 +779,4 @@ addtask deploy after do_populate_sysroot

do_packagedata
EXPORT_FUNCTIONS do_deploy

Quoted 8 lines

meta/classes/kernel.bbclass addtask deploy after do_populate_sysroot do_packagedata · line 782

Quoted 3 lines

# Add using Device Tree support

meta/classes/kernel.bbclass +1 -1
-inherit kernel-devicetree
+inherit ${@ "" if d.getVar("KERNEL_DEVICETREE" == "") else "kernel-devicetree" }

That doesn't look correct. Don't you mean something like this:

inherit ${@ "kernel-devicetree" if d.getVar("KERNEL_DEVICETREE") else "" }

As you prefer, I don't think bitbake has likely/unlikely optimization. I took the style-example from line 6 where it reads

Quoted 7 lines
Quoted 4 lines

KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else d.getVar("KERNEL_PACKAGE_NAME") }"

I am for any option providing a guard.

I guess you've missed the closing bracket in your statement, please take a look at the comparison operator.

The code as it is doesn't raise any parse error. There is opening bracket and closing bracket, what more?

We can discuss about the form, someone suggested anonymous python for both patches.

Thanks for reviewing
A.A.

Quoted 27 lines

As yet another option, maybe even something like this:
inherit ${@oe.utils.ifelse(d.getVar('KERNEL_DEVICETREE') == '', '', 'kernel-devicetree')}

However, I'm not sure what would happened if KERNEL_DEVICETREE is undefined, as in this case bitbake should return "None" according to the documentation.

Quoted 13 lines

Cheers
A.A.

Quoted 5 lines
Quoted 2 lines

--
2.17.1

//Peter

--
Regards,
Andrey.

#6 lore raw

Re: [OE-core][PATCH 2/2] kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Quoted 48 lines · Andrea Adami
Quoted 47 lines · Andrey Zhizhikin

Hello Andrea,

Quoted 43 lines · Andrea Adami
Quoted 25 lines · Peter Kjellerstedt
Quoted 25 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Andrea Adami
Sent: den 23 juni 2021 00:18
To: [email protected]
Subject: [OE-core][PATCH 2/2] kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Now it unconditionally tries to create package kernel-devicetre even for legacy devices w/out DT.

---
 meta/classes/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel.bbclass +0 -0
index 06e6446a08..68369e3791 100644
@@ -779,4 +779,4 @@ addtask deploy after do_populate_sysroot

do_packagedata
EXPORT_FUNCTIONS do_deploy

Quoted 8 lines

meta/classes/kernel.bbclass addtask deploy after do_populate_sysroot do_packagedata · line 782

Quoted 3 lines

# Add using Device Tree support

meta/classes/kernel.bbclass +1 -1
-inherit kernel-devicetree
+inherit ${@ "" if d.getVar("KERNEL_DEVICETREE" == "") else "kernel-devicetree" }

That doesn't look correct. Don't you mean something like this:

inherit ${@ "kernel-devicetree" if d.getVar("KERNEL_DEVICETREE") else "" }

As you prefer, I don't think bitbake has likely/unlikely optimization. I took the style-example from line 6 where it reads

KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else d.getVar("KERNEL_PACKAGE_NAME") }"

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I am for any option providing a guard.

I guess you've missed the closing bracket in your statement, please take a look at the comparison operator.

The code as it is doesn't raise any parse error. There is opening bracket and closing bracket, what more?

d.getVar("KERNEL_DEVICETREE" == "")
vs
d.getVar("KERNEL_DEVICETREE") == ""

Quoted 37 lines

We can discuss about the form, someone suggested anonymous python for both patches.

Thanks for reviewing
A.A.

Quoted 27 lines

As yet another option, maybe even something like this:
inherit ${@oe.utils.ifelse(d.getVar('KERNEL_DEVICETREE') == '', '', 'kernel-devicetree')}

However, I'm not sure what would happened if KERNEL_DEVICETREE is undefined, as in this case bitbake should return "None" according to the documentation.

Quoted 13 lines

Cheers
A.A.

Quoted 5 lines
Quoted 2 lines

--
2.17.1

//Peter

--
Regards,
Andrey.

#7 lore raw

Re: [OE-core][PATCH 2/2] kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Thank you, I'll send v2.
I am waiting RP comments about the other patch of the series for kernel.bbclass which exposed this one issue.

Martin, I tried to remove the patch from patchwork but all stops end 2020. Am I missing something? New links?
Thanks all
A.A.

Quoted 100 lines · Martin Jansa
Quoted 48 lines · Andrea Adami
Quoted 47 lines · Andrey Zhizhikin

Hello Andrea,

Quoted 43 lines · Andrea Adami
Quoted 25 lines · Peter Kjellerstedt
Quoted 25 lines

-----Original Message-----
From: [email protected] <openembedded- [email protected]> On Behalf Of Andrea Adami
Sent: den 23 juni 2021 00:18
To: [email protected]
Subject: [OE-core][PATCH 2/2] kernel.bbclass: inherit kernel_devicetree only if KERNEL_DEVICETREE is set

Now it unconditionally tries to create package kernel-devicetre even for legacy devices w/out DT.

---
 meta/classes/kernel.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel.bbclass +0 -0
index 06e6446a08..68369e3791 100644
@@ -779,4 +779,4 @@ addtask deploy after do_populate_sysroot

do_packagedata
EXPORT_FUNCTIONS do_deploy

Quoted 8 lines

meta/classes/kernel.bbclass addtask deploy after do_populate_sysroot do_packagedata · line 782

Quoted 3 lines

# Add using Device Tree support

meta/classes/kernel.bbclass +1 -1
-inherit kernel-devicetree
+inherit ${@ "" if d.getVar("KERNEL_DEVICETREE" == "") else "kernel-devicetree" }

That doesn't look correct. Don't you mean something like this:

inherit ${@ "kernel-devicetree" if d.getVar("KERNEL_DEVICETREE") else "" }

As you prefer, I don't think bitbake has likely/unlikely optimization. I took the style-example from line 6 where it reads

KERNEL_DEPLOYSUBDIR ??= "${@ "" if (d.getVar("KERNEL_PACKAGE_NAME") == "kernel") else d.getVar("KERNEL_PACKAGE_NAME") }"

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I am for any option providing a guard.

I guess you've missed the closing bracket in your statement, please take a look at the comparison operator.

The code as it is doesn't raise any parse error. There is opening bracket and closing bracket, what more?

d.getVar("KERNEL_DEVICETREE" == "")
vs
d.getVar("KERNEL_DEVICETREE") == ""

Quoted 37 lines

We can discuss about the form, someone suggested anonymous python for both patches.

Thanks for reviewing
A.A.

Quoted 27 lines

As yet another option, maybe even something like this:
inherit ${@oe.utils.ifelse(d.getVar('KERNEL_DEVICETREE') == '', '', 'kernel-devicetree')}

However, I'm not sure what would happened if KERNEL_DEVICETREE is undefined, as in this case bitbake should return "None" according to the documentation.

Quoted 13 lines

Cheers
A.A.

Quoted 5 lines
Quoted 2 lines

--
2.17.1

//Peter

--
Regards,
Andrey.

#8 lore raw
In reply to Andrea Adami
Quoted 41 lines · Andrea Adami

As exposed in the ML
https://lists.openembedded.org/g/openembedded-core/message/153000

up to commit 86142da in Gatesgarth it was possible to build a second mini-kernel w/out modules to be just deployed and collected by other recipes.

These kernels use special care to avoid packaging:

inherit nopackages

PACKAGES = ""
PROVIDES = ""

Now the change in kernel.bblass calls a packaging routine:
do_deploy[prefuncs] += "read_subpackage_metadata"

As a result the kernel build fails.

Fix this using bb.data.inherits_class() to verify the possible previous inherit of nopackages.bbclass.

---
 meta/classes/kernel.bbclass | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/kernel.bbclass +0 -0
index 379bed44f2..06e6446a08 100644
@@ -771,8 +771,8 @@ kernel_do_deploy() {
  }

 # We deploy to filenames that include PKGV and PKGR, read the saved data to

meta/classes/kernel.bbclass +2 -2
-# ensure we get the right values for both
-do_deploy[prefuncs] += "read_subpackage_metadata"
+# ensure we get the right values for both. Do this only if packaging is enabled.
+do_deploy[prefuncs] += "${@ '' if bb.data.inherits_class('nopackages', d) else 'read_subpackage_metadata' }"

Quoted 2 lines

 addtask deploy after do_populate_sysroot do_packagedata

I'm not convinced this is the right fix. Which values is that function finding and reading which cause problems? It sounds like there is a deeper issue here that should be fixed instead...

Is there a simple reproducer for this on master?

Cheers,

Richard

#9 lore raw
Quoted 43 lines · Richard Purdie
Quoted 41 lines · Andrea Adami

As exposed in the ML
https://lists.openembedded.org/g/openembedded-core/message/153000

up to commit 86142da in Gatesgarth it was possible to build a second mini-kernel w/out modules to be just deployed and collected by other recipes.

These kernels use special care to avoid packaging:

inherit nopackages

PACKAGES = ""
PROVIDES = ""

Now the change in kernel.bblass calls a packaging routine:
do_deploy[prefuncs] += "read_subpackage_metadata"

As a result the kernel build fails.

Fix this using bb.data.inherits_class() to verify the possible previous inherit of nopackages.bbclass.

---
 meta/classes/kernel.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/kernel.bbclass +2 -2
index 379bed44f2..06e6446a08 100644
@@ -771,8 +771,8 @@ kernel_do_deploy() {
 }
 
 
 # We deploy to filenames that include PKGV and PKGR, read the saved data to
-# ensure we get the right values for both
-do_deploy[prefuncs] += "read_subpackage_metadata"
+# ensure we get the right values for both. Do this only if packaging is enabled.
+do_deploy[prefuncs] += "${@ '' if bb.data.inherits_class('nopackages', d) else 'read_subpackage_metadata' }"
 
 
Quoted 9 lines
Quoted 2 lines

addtask deploy after do_populate_sysroot do_packagedata

I'm not convinced this is the right fix. Which values is that function finding and reading which cause problems? It sounds like there is a deeper issue here that should be fixed instead...

Is there a simple reproducer for this on master?

Well, yes.
It is linux-kexecboot from meta-handheld.
Pls see comments in message 153000.

The razor is
https://git.openembedded.org/openembedded-core/tree/meta/classes/packagedata.bbclass#n22

Cheers
A.A.