diff mbox series

[v2,3/4] lib: package: Check incompatible licenses at packaging time

Message ID 20241023212013.995247-4-JPEWhacker@gmail.com
State New
Headers show
Series Incompatible Licenses in Dynamic Packages | expand

Commit Message

Joshua Watt Oct. 23, 2024, 9:15 p.m. UTC
Instead of checking for incompatible licenses in the anonymous python
and setting '_exclude_incompatible-', (re)check all the packages in
populate_packages(). This ensures that all packages are processed, even
dynamically generated ones.

The use of the '_exclude-incompatible-' variable set in base.bbclass has
been the mechanism used for per-packages licenses since its it was added
as a feature (although with different names for the variable throughout
history). However, since this misses dynamic packages, calling
oe.license.skip_incompatible_package_licenses() a second time on the
actual final package set is a better solution.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 meta/classes-global/base.bbclass | 1 -
 meta/lib/oe/package.py           | 6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)

Comments

Peter Kjellerstedt Oct. 24, 2024, 2:24 a.m. UTC | #1
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Joshua Watt
> Sent: den 23 oktober 2024 23:15
> To: openembedded-core@lists.openembedded.org
> Cc: Joshua Watt <JPEWhacker@gmail.com>
> Subject: [OE-core][PATCH v2 3/4] lib: package: Check incompatible licenses at packaging time
> 
> Instead of checking for incompatible licenses in the anonymous python
> and setting '_exclude_incompatible-', (re)check all the packages in
> populate_packages(). This ensures that all packages are processed, even
> dynamically generated ones.
> 
> The use of the '_exclude-incompatible-' variable set in base.bbclass has
> been the mechanism used for per-packages licenses since its it was added

Typo: its it -> it

> as a feature (although with different names for the variable throughout
> history). However, since this misses dynamic packages, calling
> oe.license.skip_incompatible_package_licenses() a second time on the
> actual final package set is a better solution.
> 
> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
> ---
>  meta/classes-global/base.bbclass | 1 -
>  meta/lib/oe/package.py           | 6 +++---
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass
> index 5b8663f454d..b81e61fdb72 100644
> --- a/meta/classes-global/base.bbclass
> +++ b/meta/classes-global/base.bbclass
> @@ -581,7 +581,6 @@ python () {
>              if unskipped_pkgs:
>                  for pkg in skipped_pkgs:
>                      bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg])))
> -                    d.setVar('_exclude_incompatible-' + pkg, ' '.join(skipped_pkgs[pkg]))
>                  for pkg in unskipped_pkgs:
>                      bb.debug(1, "Including the package %s" % pkg)
>              else:
> diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
> index c213a9a3ca6..480408e41e3 100644
> --- a/meta/lib/oe/package.py
> +++ b/meta/lib/oe/package.py
> @@ -1447,10 +1447,10 @@ def populate_packages(d):
> 
>      # Handle excluding packages with incompatible licenses
>      package_list = []
> +    skipped_pkgs = oe.license.skip_incompatible_package_licenses(d, pkgs):
>      for pkg in packages:
> -        licenses = d.getVar('_exclude_incompatible-' + pkg)
> -        if licenses:
> -            msg = "Excluding %s from packaging as it has incompatible license(s): %s" % (pkg, licenses)
> +        if pkg in skipped_pkgs:
> +            msg = "Excluding %s from packaging as it has incompatible license(s): %s" % (pkg, skipped_pkgs[pkg])
>              oe.qa.handle_error("incompatible-license", msg, d)
>          else:
>              package_list.append(pkg)
> --
> 2.46.2

There is still a reference to _exclude_incompatible in package.bbclass. 
Not sure what to do about it (it has to do with variable dependencies 
to trigger do_package to re-run for recipes that are affected by changes 
to INCOMPATIBLE_LICENSE). 

//Peter
Peter Kjellerstedt Oct. 24, 2024, 10:02 a.m. UTC | #2
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Joshua Watt
> Sent: den 23 oktober 2024 23:15
> To: openembedded-core@lists.openembedded.org
> Cc: Joshua Watt <JPEWhacker@gmail.com>
> Subject: [OE-core][PATCH v2 3/4] lib: package: Check incompatible licenses at packaging time
> 
> Instead of checking for incompatible licenses in the anonymous python
> and setting '_exclude_incompatible-', (re)check all the packages in
> populate_packages(). This ensures that all packages are processed, even
> dynamically generated ones.
> 
> The use of the '_exclude-incompatible-' variable set in base.bbclass has
> been the mechanism used for per-packages licenses since its it was added
> as a feature (although with different names for the variable throughout
> history). However, since this misses dynamic packages, calling
> oe.license.skip_incompatible_package_licenses() a second time on the
> actual final package set is a better solution.
> 
> Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
> ---
>  meta/classes-global/base.bbclass | 1 -
>  meta/lib/oe/package.py           | 6 +++---
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass
> index 5b8663f454d..b81e61fdb72 100644
> --- a/meta/classes-global/base.bbclass
> +++ b/meta/classes-global/base.bbclass
> @@ -581,7 +581,6 @@ python () {
>              if unskipped_pkgs:
>                  for pkg in skipped_pkgs:
>                      bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg])))
> -                    d.setVar('_exclude_incompatible-' + pkg, ' '.join(skipped_pkgs[pkg]))
>                  for pkg in unskipped_pkgs:
>                      bb.debug(1, "Including the package %s" % pkg)
>              else:
> diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
> index c213a9a3ca6..480408e41e3 100644
> --- a/meta/lib/oe/package.py
> +++ b/meta/lib/oe/package.py
> @@ -1447,10 +1447,10 @@ def populate_packages(d):
> 
>      # Handle excluding packages with incompatible licenses
>      package_list = []
> +    skipped_pkgs = oe.license.skip_incompatible_package_licenses(d, pkgs):

Umm, how well did you test this? ;)
The Python interpreter is not too happy about the trailing colon on the line above...

>      for pkg in packages:
> -        licenses = d.getVar('_exclude_incompatible-' + pkg)
> -        if licenses:
> -            msg = "Excluding %s from packaging as it has incompatible license(s): %s" % (pkg, licenses)
> +        if pkg in skipped_pkgs:
> +            msg = "Excluding %s from packaging as it has incompatible license(s): %s" % (pkg, skipped_pkgs[pkg])
>              oe.qa.handle_error("incompatible-license", msg, d)
>          else:
>              package_list.append(pkg)
> --
> 2.46.2

//Peter
Joshua Watt Oct. 24, 2024, 3:57 p.m. UTC | #3
On Thu, Oct 24, 2024 at 4:03 AM Peter Kjellerstedt
<peter.kjellerstedt@axis.com> wrote:
>
> > -----Original Message-----
> > From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Joshua Watt
> > Sent: den 23 oktober 2024 23:15
> > To: openembedded-core@lists.openembedded.org
> > Cc: Joshua Watt <JPEWhacker@gmail.com>
> > Subject: [OE-core][PATCH v2 3/4] lib: package: Check incompatible licenses at packaging time
> >
> > Instead of checking for incompatible licenses in the anonymous python
> > and setting '_exclude_incompatible-', (re)check all the packages in
> > populate_packages(). This ensures that all packages are processed, even
> > dynamically generated ones.
> >
> > The use of the '_exclude-incompatible-' variable set in base.bbclass has
> > been the mechanism used for per-packages licenses since its it was added
> > as a feature (although with different names for the variable throughout
> > history). However, since this misses dynamic packages, calling
> > oe.license.skip_incompatible_package_licenses() a second time on the
> > actual final package set is a better solution.
> >
> > Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
> > ---
> >  meta/classes-global/base.bbclass | 1 -
> >  meta/lib/oe/package.py           | 6 +++---
> >  2 files changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass
> > index 5b8663f454d..b81e61fdb72 100644
> > --- a/meta/classes-global/base.bbclass
> > +++ b/meta/classes-global/base.bbclass
> > @@ -581,7 +581,6 @@ python () {
> >              if unskipped_pkgs:
> >                  for pkg in skipped_pkgs:
> >                      bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg])))
> > -                    d.setVar('_exclude_incompatible-' + pkg, ' '.join(skipped_pkgs[pkg]))
> >                  for pkg in unskipped_pkgs:
> >                      bb.debug(1, "Including the package %s" % pkg)
> >              else:
> > diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
> > index c213a9a3ca6..480408e41e3 100644
> > --- a/meta/lib/oe/package.py
> > +++ b/meta/lib/oe/package.py
> > @@ -1447,10 +1447,10 @@ def populate_packages(d):
> >
> >      # Handle excluding packages with incompatible licenses
> >      package_list = []
> > +    skipped_pkgs = oe.license.skip_incompatible_package_licenses(d, pkgs):
>
> Umm, how well did you test this? ;)
> The Python interpreter is not too happy about the trailing colon on the line above...

Yep, because I found that, fixed it, and forgot to squash the fix in
before I submitted

I'll send a V3

>
> >      for pkg in packages:
> > -        licenses = d.getVar('_exclude_incompatible-' + pkg)
> > -        if licenses:
> > -            msg = "Excluding %s from packaging as it has incompatible license(s): %s" % (pkg, licenses)
> > +        if pkg in skipped_pkgs:
> > +            msg = "Excluding %s from packaging as it has incompatible license(s): %s" % (pkg, skipped_pkgs[pkg])
> >              oe.qa.handle_error("incompatible-license", msg, d)
> >          else:
> >              package_list.append(pkg)
> > --
> > 2.46.2
>
> //Peter
>
diff mbox series

Patch

diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass
index 5b8663f454d..b81e61fdb72 100644
--- a/meta/classes-global/base.bbclass
+++ b/meta/classes-global/base.bbclass
@@ -581,7 +581,6 @@  python () {
             if unskipped_pkgs:
                 for pkg in skipped_pkgs:
                     bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg])))
-                    d.setVar('_exclude_incompatible-' + pkg, ' '.join(skipped_pkgs[pkg]))
                 for pkg in unskipped_pkgs:
                     bb.debug(1, "Including the package %s" % pkg)
             else:
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index c213a9a3ca6..480408e41e3 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -1447,10 +1447,10 @@  def populate_packages(d):
 
     # Handle excluding packages with incompatible licenses
     package_list = []
+    skipped_pkgs = oe.license.skip_incompatible_package_licenses(d, pkgs):
     for pkg in packages:
-        licenses = d.getVar('_exclude_incompatible-' + pkg)
-        if licenses:
-            msg = "Excluding %s from packaging as it has incompatible license(s): %s" % (pkg, licenses)
+        if pkg in skipped_pkgs:
+            msg = "Excluding %s from packaging as it has incompatible license(s): %s" % (pkg, skipped_pkgs[pkg])
             oe.qa.handle_error("incompatible-license", msg, d)
         else:
             package_list.append(pkg)