Skip to contentSkip to conversation

baremetal-image.bbclass: avoid inheriting incompatible IMAGE_CLASSES

PATCH In review Alejandro Enedino Hernandez Samaniego 2 participants 4 messages Sep 1, 2022 – Sep 2, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 baremetal-image.bbclass: avoid inheriting incompatible IMAGE_CLASSES

There could be IMAGE_CLASSES designed to work on images which arent necessarily compatible with baremetal-images, one example is the license_image class which relies on the package managers functionality during do_rootfs, for baremetal images no rootfs is created hence the package manager shouldnt be invoked, we need to avoid inheriting such class to fix this behavior.

inherit BAREMETAL_IMAGE_CLASSES for baremetal images but set the default to IMAGE_CLASSES, whilst removing undesired classes in an intermediate step to avoid incompatibilities.

---
 meta/classes-recipe/baremetal-image.bbclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
meta/classes-recipe/baremetal-image.bbclass +8 -1
index d3377a92fa..2f07dec4ac 100644
@@ -18,8 +18,15 @@
 ## Emulate image.bbclass
 # Handle inherits of any of the image classes we need
 IMAGE_CLASSES ??= ""
-IMGCLASSES = " ${IMAGE_CLASSES}"
+BAREMETAL_IMAGE_CLASSES ?= " ${IMAGE_CLASSES}"
+
+# The license_image class relies on package managers used on do_rootfs
+# these dont exist for baremetal images since no rootfs is created.
+BAREMETAL_IMAGE_CLASSES:remove = "license_image"
+
+IMGCLASSES = " ${BAREMETAL_IMAGE_CLASSES}"
 inherit ${IMGCLASSES}
+
 # Set defaults to satisfy IMAGE_FEATURES check
 IMAGE_FEATURES ?= ""
 IMAGE_FEATURES[type] = "list"
Signature · 1 line
2.25.1
#1 lore raw
Quoted 27 lines · Alejandro Hernandez Samaniego

There could be IMAGE_CLASSES designed to work on images which arent necessarily compatible with baremetal-images, one example is the license_image class which relies on the package managers functionality during do_rootfs, for baremetal images no rootfs is created hence the package manager shouldnt be invoked, we need to avoid inheriting such class to fix this behavior.

inherit BAREMETAL_IMAGE_CLASSES for baremetal images but set the default to IMAGE_CLASSES, whilst removing undesired classes in an intermediate step to avoid incompatibilities.

---
 meta/classes-recipe/baremetal-image.bbclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
meta/classes-recipe/baremetal-image.bbclass +2 -1
index d3377a92fa..2f07dec4ac 100644
@@ -18,8 +18,15 @@
 ## Emulate image.bbclass
 # Handle inherits of any of the image classes we need
 IMAGE_CLASSES ??= ""
-IMGCLASSES = " ${IMAGE_CLASSES}"
+BAREMETAL_IMAGE_CLASSES ?= " ${IMAGE_CLASSES}"
+

meta/classes-recipe/baremetal-image.bbclass line 32

Quoted 10 lines
meta/classes-recipe/baremetal-image.bbclass +6 -0
+# The license_image class relies on package managers used on do_rootfs
+# these dont exist for baremetal images since no rootfs is created.
+BAREMETAL_IMAGE_CLASSES:remove = "license_image"
+
+IMGCLASSES = " ${BAREMETAL_IMAGE_CLASSES}"
 inherit ${IMGCLASSES}
+
 # Set defaults to satisfy IMAGE_FEATURES check
 IMAGE_FEATURES ?= ""
 IMAGE_FEATURES[type] = "list"

This is going to become a usability nightmare. Can we patch license_image to just silently do nothing for baremetal?

Cheers,

Richard

#2 lore raw
Quoted 35 lines · Richard Purdie
Quoted 7 lines · Alejandro Hernandez Samaniego

There could be IMAGE_CLASSES designed to work on images which arent necessarily compatible with baremetal-images, one example is the license_image class which relies on the package managers functionality during do_rootfs, for baremetal images no rootfs is created hence the package manager shouldnt be invoked, we need to avoid inheriting such class to fix this behavior.

Quoted 5 lines

inherit BAREMETAL_IMAGE_CLASSES for baremetal images but set the default to IMAGE_CLASSES, whilst removing undesired classes in an intermediate step to avoid incompatibilities.

Signed-off-by Alejandro Enedino Hernandez Samaniego <

[email protected]>

Review

Quoted 5 lines
---
 meta/classes-recipe/baremetal-image.bbclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/meta/classes-recipe/baremetal-image.bbclass

Quoted 15 lines

index d3377a92fa..2f07dec4ac 100644

meta/classes-recipe/baremetal-image.bbclass +7 -1
@@ -18,8 +18,15 @@
 ## Emulate image.bbclass
 # Handle inherits of any of the image classes we need
 IMAGE_CLASSES ??= ""
-IMGCLASSES = " ${IMAGE_CLASSES}"
+BAREMETAL_IMAGE_CLASSES ?= " ${IMAGE_CLASSES}"
+
+# The license_image class relies on package managers used on do_rootfs
+# these dont exist for baremetal images since no rootfs is created.
+BAREMETAL_IMAGE_CLASSES:remove = "license_image"
+
+IMGCLASSES = " ${BAREMETAL_IMAGE_CLASSES}"
Quoted 9 lines

meta/classes-recipe/baremetal-image.bbclass line 32

Quoted 5 lines
meta/classes-recipe/baremetal-image.bbclass +1 -0
 inherit ${IMGCLASSES}
+
 # Set defaults to satisfy IMAGE_FEATURES check
 IMAGE_FEATURES ?= ""
 IMAGE_FEATURES[type] = "list"

This is going to become a usability nightmare. Can we patch license_image to just silently do nothing for baremetal?

I think we can, but we'd have to do that on every class that is incompatible (I don't expect many to be, but I tried to generate a more generic solution and use BAREMETAL_, IMAGE_CLASSES as a gate), with that in mind, Is that still better than this?

Quoted 7 lines

Cheers,

Richard

#3 lore raw
Quoted 57 lines · Alejandro Enedino Hernandez Samaniego
Quoted 44 lines · Richard Purdie
Quoted 42 lines · Alejandro Hernandez Samaniego

There could be IMAGE_CLASSES designed to work on images which arent
necessarily compatible with baremetal-images, one example is the license_image class which relies on the package managers functionality
during do_rootfs, for baremetal images no rootfs is created hence the
package manager shouldnt be invoked, we need to avoid inheriting such
class to fix this behavior.

inherit BAREMETAL_IMAGE_CLASSES for baremetal images but set the default
to IMAGE_CLASSES, whilst removing undesired classes in an intermediate
step to avoid incompatibilities.

Signed-off-by: Alejandro Enedino Hernandez Samaniego <[email protected]>
---
  meta/classes-recipe/baremetal-image.bbclass | 9 ++++++++-

  1 file changed, 8 insertions(+), 1 deletion(-)
meta/classes-recipe/baremetal-image.bbclass +0 -0
index d3377a92fa..2f07dec4ac 100644
@@ -18,8 +18,15 @@
   ## Emulate image.bbclass
   # Handle inherits of any of the image classes we need

  IMAGE_CLASSES ??= ""

meta/classes-recipe/baremetal-image.bbclass +3 -1
-IMGCLASSES = " ${IMAGE_CLASSES}"
+BAREMETAL_IMAGE_CLASSES ?= " ${IMAGE_CLASSES}"
+
+# The license_image class relies on package managers used on

do_rootfs
+# these dont exist for baremetal images since no rootfs is created.

meta/classes-recipe/baremetal-image.bbclass +3 -0
+BAREMETAL_IMAGE_CLASSES:remove = "license_image"
+
+IMGCLASSES = " ${BAREMETAL_IMAGE_CLASSES}"
Quoted 8 lines
Quoted 5 lines

  inherit ${IMGCLASSES}
+
  # Set defaults to satisfy IMAGE_FEATURES check
  IMAGE_FEATURES ?= ""
  IMAGE_FEATURES[type] = "list"

This is going to become a usability nightmare. Can we patch license_image to just silently do nothing for baremetal?

Quoted 4 lines

I think we can, but we'd have to do that on every class that is incompatible (I don't expect many to be, but I tried to generate a more generic solution and use BAREMETAL_, IMAGE_CLASSES as a gate), with that in mind, Is that still better than this?

I think we do need to fixes the classes which don't work. The alternative is users having two lists of image classes which defeats much of what the variable was trying to do. We may as well just give up on IMAGE_CLASSES for baremetal and require it's own list which will be a pain for users.

Cheers,

Richard