diff mbox series

[3/3] package.bbclass: extend package variables for multilib variants

Message ID 20260429143104.684760-4-jaeyoon.jung@lge.com
State Changes Requested
Headers show
Series Fix multilib package variable propagation | expand

Commit Message

From: Jaeyoon Jung <jaeyoon.jung@lge.com>

Ensure PACKAGEVARS are extended for multilib variants during
do_split_packages so that per-package metadata is correctly
renamed when BBEXTENDVARIANT is in use.

Signed-off-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
---
 meta/classes-global/package.bbclass | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Richard Purdie April 30, 2026, 1:54 p.m. UTC | #1
On Wed, 2026-04-29 at 23:31 +0900, Jaeyoon Jung (LGE) via lists.openembedded.org wrote:
> From: Jaeyoon Jung <jaeyoon.jung@lge.com>
> 
> Ensure PACKAGEVARS are extended for multilib variants during
> do_split_packages so that per-package metadata is correctly
> renamed when BBEXTENDVARIANT is in use.
> 
> Signed-off-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
> ---
>  meta/classes-global/package.bbclass | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass
> index 67148fc1ac..d981424290 100644
> --- a/meta/classes-global/package.bbclass
> +++ b/meta/classes-global/package.bbclass
> @@ -169,6 +169,7 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst
>  
>      for o in sorted(objs):
>          import re, stat
> +        import oe.package
>          if match_path:
>              m = re.match(file_regex, o)
>          else:
> @@ -225,6 +226,16 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst
>              hook(f, pkg, file_regex, output_pattern, m.group(1))
>  
>      d.setVar('PACKAGES', ' '.join(packages))
> +
> +    variant = d.getVar("BBEXTENDVARIANT")
> +    prefixes = (d.getVar("MULTILIB_VARIANTS") or "").split()
> +
> +    if variant and prefixes:
> +        import oe.classextend
> +        # Extend package variables for the given variant if unset
> +        clsextend = oe.classextend.ClassExtender(variant, prefixes, d)
> +        clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split())
> +
>      return list(split_packages)

Firstly, this puts multilib code into generic code, which we've tried
very hard to avoid.

Secondly, this processes all of PACKAGES again.
rename_package_variables is designed to only be called once. Calling it
a second time isn't a good idea. We really should only process the new
split_packages?

Cheers,

Richard
> From: Richard Purdie <richard.purdie@linuxfoundation.org>
> Sent: Thursday, April 30, 2026 22:54
> To: 정재윤/Task Leader/SW Platform(연)선행Platform개발실 Lightweight System Task <jaeyoon.jung@lge.com>; openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org>
> Subject: Re: [OE-core] [PATCH 3/3] package.bbclass: extend package variables for multilib variants
>  
> On Wed, 2026-04-29 at 23:31 +0900, Jaeyoon Jung (LGE) via lists.openembedded.org wrote:
> > From: Jaeyoon Jung <jaeyoon.jung@lge.com>
> >
> > Ensure PACKAGEVARS are extended for multilib variants during
> > do_split_packages so that per-package metadata is correctly
> > renamed when BBEXTENDVARIANT is in use.
> >
> > Signed-off-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
> > ---
> >  meta/classes-global/package.bbclass | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass
> > index 67148fc1ac..d981424290 100644
> > --- a/meta/classes-global/package.bbclass
> > +++ b/meta/classes-global/package.bbclass
> > @@ -169,6 +169,7 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst
> >  
> >      for o in sorted(objs):
> >          import re, stat
> > +        import oe.package
> >          if match_path:
> >              m = re.match(file_regex, o)
> >          else:
> > @@ -225,6 +226,16 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst
> >              hook(f, pkg, file_regex, output_pattern, m.group(1))
> >  
> >      d.setVar('PACKAGES', ' '.join(packages))
> > +
> > +    variant = d.getVar("BBEXTENDVARIANT")
> > +    prefixes = (d.getVar("MULTILIB_VARIANTS") or "").split()
> > +
> > +    if variant and prefixes:
> > +        import oe.classextend
> > +        # Extend package variables for the given variant if unset
> > +        clsextend = oe.classextend.ClassExtender(variant, prefixes, d)
> > +        clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split())
> > +
> >      return list(split_packages)
>
> Firstly, this puts multilib code into generic code, which we've tried
> very hard to avoid.
>
> Secondly, this processes all of PACKAGES again.
> rename_package_variables is designed to only be called once. Calling it
> a second time isn't a good idea. We really should only process the new
> split_packages?
>

On your second point, I agree that the new split_packages are the only
things to be processed here. I see two possible approaches:
1) Introduce a new variant of rename_package_variables in ClassExtender
that takes an explicit list of packages to process, or
2) Extend rename_package_variables to accept a package list, and update
its existing callers (multilib.bbclass and nativesdk.bbclass) to pass
PACKAGES explicitly.

On your first point, I’m wondering whether doing this unconditionally in
do_split_packages would be a preferable approach — keeping it generic
rather than limiting it to the multilib case. Alternatively, if you even
want to avoid anything multilib-specific in public code like
do_split_packages, then it should be handled within multilib.bbclass.
But I don't see how to achieve that. It seems to be tricky to do it
after dynamic packages are processed and before entering
oe.package.populate_packages.


Best regards,
---
Jaeyoon Jung
Software Platform Lab. / Corporate R&D / LG Electronics Inc.
diff mbox series

Patch

diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass
index 67148fc1ac..d981424290 100644
--- a/meta/classes-global/package.bbclass
+++ b/meta/classes-global/package.bbclass
@@ -169,6 +169,7 @@  def do_split_packages(d, root, file_regex, output_pattern, description, postinst
 
     for o in sorted(objs):
         import re, stat
+        import oe.package
         if match_path:
             m = re.match(file_regex, o)
         else:
@@ -225,6 +226,16 @@  def do_split_packages(d, root, file_regex, output_pattern, description, postinst
             hook(f, pkg, file_regex, output_pattern, m.group(1))
 
     d.setVar('PACKAGES', ' '.join(packages))
+
+    variant = d.getVar("BBEXTENDVARIANT")
+    prefixes = (d.getVar("MULTILIB_VARIANTS") or "").split()
+
+    if variant and prefixes:
+        import oe.classextend
+        # Extend package variables for the given variant if unset
+        clsextend = oe.classextend.ClassExtender(variant, prefixes, d)
+        clsextend.rename_package_variables((d.getVar("PACKAGEVARS") or "").split())
+
     return list(split_packages)
 
 PACKAGE_DEPENDS += "file-native"