diff mbox series

baremetal-image.bbclass: avoid inheriting incompatible IMAGE_CLASSES

Message ID 20220901234206.419429-1-alejandro@enedino.org
State New
Headers show
Series baremetal-image.bbclass: avoid inheriting incompatible IMAGE_CLASSES | expand

Commit Message

Alejandro Enedino Hernandez Samaniego Sept. 1, 2022, 11:42 p.m. UTC
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 <alejandro@enedino.org>
---
 meta/classes-recipe/baremetal-image.bbclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Richard Purdie Sept. 2, 2022, 2:47 p.m. UTC | #1
On Thu, 2022-09-01 at 17:42 -0600, Alejandro Hernandez Samaniego wrote:
> 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 <alejandro@enedino.org>
> ---
>  meta/classes-recipe/baremetal-image.bbclass | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes-recipe/baremetal-image.bbclass b/meta/classes-recipe/baremetal-image.bbclass
> index d3377a92fa..2f07dec4ac 100644
> --- a/meta/classes-recipe/baremetal-image.bbclass
> +++ b/meta/classes-recipe/baremetal-image.bbclass
> @@ -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"

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

Cheers,

Richard
Alejandro Enedino Hernandez Samaniego Sept. 2, 2022, 2:53 p.m. UTC | #2
On Fri, Sep 2, 2022, 9:47 AM Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> On Thu, 2022-09-01 at 17:42 -0600, Alejandro Hernandez Samaniego wrote:
> > 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 <
> alejandro@enedino.org>
> > ---
> >  meta/classes-recipe/baremetal-image.bbclass | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/meta/classes-recipe/baremetal-image.bbclass
> b/meta/classes-recipe/baremetal-image.bbclass
> > index d3377a92fa..2f07dec4ac 100644
> > --- a/meta/classes-recipe/baremetal-image.bbclass
> > +++ b/meta/classes-recipe/baremetal-image.bbclass
> > @@ -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"
>
> 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?



> Cheers,
>
> Richard


>
>
Richard Purdie Sept. 2, 2022, 3:02 p.m. UTC | #3
On Fri, 2022-09-02 at 09:53 -0500, Alejandro Enedino Hernandez
Samaniego wrote:
> 
> 
> On Fri, Sep 2, 2022, 9:47 AM Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> > On Thu, 2022-09-01 at 17:42 -0600, Alejandro Hernandez Samaniego
> > wrote:
> > > 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
> > > <alejandro@enedino.org>
> > > ---
> > >   meta/classes-recipe/baremetal-image.bbclass | 9 ++++++++-
> > >   1 file changed, 8 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/meta/classes-recipe/baremetal-image.bbclass
> > > b/meta/classes-recipe/baremetal-image.bbclass
> > > index d3377a92fa..2f07dec4ac 100644
> > > --- a/meta/classes-recipe/baremetal-image.bbclass
> > > +++ b/meta/classes-recipe/baremetal-image.bbclass
> > > @@ -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"
> > 
> > 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?

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
diff mbox series

Patch

diff --git a/meta/classes-recipe/baremetal-image.bbclass b/meta/classes-recipe/baremetal-image.bbclass
index d3377a92fa..2f07dec4ac 100644
--- a/meta/classes-recipe/baremetal-image.bbclass
+++ b/meta/classes-recipe/baremetal-image.bbclass
@@ -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"