packagegroup: Properly track the enabling of complementary packages

Message ID 20220324114114.1665034-1-alban.bedel@aerq.com
State New
Headers show
Series packagegroup: Properly track the enabling of complementary packages | expand

Commit Message

Bedel, Alban March 24, 2022, 11:41 a.m. UTC
The set of packages included in a packagegroup depend on the
PACKAGEGROUP_DISABLE_COMPLEMENTARY variable and, if that variable is
not set to '1', on DISTRO_FEATURES. As this magic happen in a python
function it can't be detected by the dependency system. We have to add
these variables to the PACKAGEVARS list to have them added to the
do_package vardeps list.

Signed-off-by: Alban Bedel <alban.bedel@aerq.com>
---
 meta/classes/packagegroup.bbclass | 2 ++
 1 file changed, 2 insertions(+)

Comments

Richard Purdie March 24, 2022, 12:15 p.m. UTC | #1
On Thu, 2022-03-24 at 12:41 +0100, Alban Bedel via lists.openembedded.org wrote:
> The set of packages included in a packagegroup depend on the
> PACKAGEGROUP_DISABLE_COMPLEMENTARY variable and, if that variable is
> not set to '1', on DISTRO_FEATURES. As this magic happen in a python
> function it can't be detected by the dependency system. We have to add
> these variables to the PACKAGEVARS list to have them added to the
> do_package vardeps list.
> 
> Signed-off-by: Alban Bedel <alban.bedel@aerq.com>
> ---
>  meta/classes/packagegroup.bbclass | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/meta/classes/packagegroup.bbclass b/meta/classes/packagegroup.bbclass
> index 557b1b6382ba..cffdaadbde0e 100644
> --- a/meta/classes/packagegroup.bbclass
> +++ b/meta/classes/packagegroup.bbclass
> @@ -31,9 +31,11 @@ python () {
>          packages = [pkg + suffix for pkg in packages
>                      for suffix in types]
>          d.setVar('PACKAGES', ' '.join(packages))
> +        d.appendVar('PACKAGEVARS', ' DISTRO_FEATURES')
>      for pkg in packages:
>          d.setVar('ALLOW_EMPTY:%s' % pkg, '1')
>  }
> +PACKAGEVARS += 'PACKAGEGROUP_DISABLE_COMPLEMENTARY'
>  

That is a hugely heavy hammer to apply to the problem. We go to quite some
lengths to try and ensure changing DISTRO_FEATURES doesn't cause things to
rebuild unless they need to (e.g. by using contains()).

PACKAGEVARS is also the wrong thing for use here as it is for variables which
have per package versions (like ALLOW_EMPTY). Put another way,
PACKAGEGROUP_DISABLE_COMPLEMENTARY:${PN}-dbg makes no sense.

PACKAGES[vardeps] += "PACKAGEGROUP_DISABLE_COMPLEMENTARY"

would be the correct way to handle the first part of this. For the distro
features piece, something like this:

PACKAGES += "${@bb.utils.contains('DISTRO_FEATURES', 'ptest', '', '', d)}"

might cause the dependencies to work correctly.

Cheers,

Richard

Patch

diff --git a/meta/classes/packagegroup.bbclass b/meta/classes/packagegroup.bbclass
index 557b1b6382ba..cffdaadbde0e 100644
--- a/meta/classes/packagegroup.bbclass
+++ b/meta/classes/packagegroup.bbclass
@@ -31,9 +31,11 @@  python () {
         packages = [pkg + suffix for pkg in packages
                     for suffix in types]
         d.setVar('PACKAGES', ' '.join(packages))
+        d.appendVar('PACKAGEVARS', ' DISTRO_FEATURES')
     for pkg in packages:
         d.setVar('ALLOW_EMPTY:%s' % pkg, '1')
 }
+PACKAGEVARS += 'PACKAGEGROUP_DISABLE_COMPLEMENTARY'
 
 # We don't want to look at shared library dependencies for the
 # dbg packages