* [PATCH] license: add 'any_incompatible' function
@ 2022-04-11 16:14 Christopher Larson
0 siblings, 0 replies; 8+ messages in thread
From: Christopher Larson @ 2022-04-11 16:14 UTC (permalink / raw)
To: openembedded-core; +Cc: Christopher Larson
This function returns True if any of the specified packages are skipped due to
incompatible license.
License exceptions are obeyed. The user may specify the package's license for
cross-recipe checks.
This allows for additions to packagegroups only for non-incompatible builds. For
example:
RDEPENDS_${PN} += "${@'dbench' if not any_incompatible(d, 'dbench', 'GPL-3.0-only') else ''}"
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
meta/classes/license.bbclass | 37 ++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 0c637e966e..db8c3f8584 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -320,6 +320,43 @@ def incompatible_license(d, dont_want_licenses, package=None):
return incompatible_pkg_license(d, dont_want_licenses, license)
+def any_incompatible(d, packages, licensestring=None):
+ """Return True if any of the packages are skipped due to incompatible license.
+
+ License exceptions are obeyed. The user may specify the package's license
+ for cross-recipe checks.
+
+ This allows for additions to packagegroups only for non-incompatible builds.
+ For example:
+
+ RDEPENDS_${PN} += "${@'dbench' if not any_incompatible(d, 'dbench', 'GPL-3.0-only') else ''}"
+ """
+ if not isinstance(packages, str):
+ packages = packages.split()
+
+ bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE") or "").split()
+ if not bad_licenses:
+ return False
+ bad_licenses = expand_wildcard_licenses(d, bad_licenses)
+
+ if licensestring is None:
+ licensestring = d.getVar("LICENSE:%s" % package) if package else None
+ if not licensestring:
+ licensestring = d.getVar("LICENSE")
+
+ exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
+ for pkg in packages:
+ remaining_bad_licenses = license.apply_pkg_license_exception(
+ pkg, bad_licenses, exceptions
+ )
+
+ incompatible_lic = incompatible_pkg_license(
+ d, remaining_bad_licenses, licensestring
+ )
+ if incompatible_lic:
+ return True
+ return False
+
def check_license_flags(d):
"""
This function checks if a recipe has any LICENSE_FLAGS that
--
2.35.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2] license: add 'any_incompatible' function
@ 2022-04-13 16:00 Christopher Larson
2022-04-13 16:00 ` [PATCH] " Christopher Larson
2022-04-13 17:44 ` [OE-core] [PATCH v2] " Richard Purdie
0 siblings, 2 replies; 8+ messages in thread
From: Christopher Larson @ 2022-04-13 16:00 UTC (permalink / raw)
To: openembedded-core; +Cc: Christopher Larson
This function returns True if any of the specified packages are skipped due to
incompatible license.
License exceptions are obeyed. The user may specify the package's license for
cross-recipe checks.
This allows for additions to packagegroups only for non-incompatible builds. For
example:
RDEPENDS_${PN} += "${@'dbench' if not any_incompatible(d, 'dbench', 'GPL-3.0-only') else ''}"
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
meta/classes/license.bbclass | 38 +++++++++++++++++++
.../packagegroups/packagegroup-base.bb | 2 +
2 files changed, 40 insertions(+)
v2 changes: fixed string packages logic, corrected reference to
apply_pkg_license_exception, and avoided use of ${@} in the function docstring
to avoid bitbake expanding it and recursing.
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 0c637e966e..41993b7227 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -320,6 +320,44 @@ def incompatible_license(d, dont_want_licenses, package=None):
return incompatible_pkg_license(d, dont_want_licenses, license)
+def any_incompatible(d, packages, licensestring=None):
+ """Return True if any of the packages are skipped due to incompatible license.
+
+ License exceptions are obeyed. The user may specify the package's license
+ for cross-recipe checks.
+
+ This allows for additions to packagegroups only for non-incompatible builds.
+
+ For example: 'dbench' if not any_incompatible(d, 'dbench', 'GPL-3.0-only') else ''
+ """
+ import oe.license
+
+ if isinstance(packages, str):
+ packages = packages.split()
+
+ bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE") or "").split()
+ if not bad_licenses:
+ return False
+ bad_licenses = expand_wildcard_licenses(d, bad_licenses)
+
+ if licensestring is None:
+ licensestring = d.getVar("LICENSE:%s" % package) if package else None
+ if not licensestring:
+ licensestring = d.getVar("LICENSE")
+
+ exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
+ for pkg in packages:
+ remaining_bad_licenses = oe.license.apply_pkg_license_exception(
+ pkg, bad_licenses, exceptions
+ )
+
+ incompatible_lic = incompatible_pkg_license(
+ d, remaining_bad_licenses, licensestring
+ )
+ if incompatible_lic:
+ return True
+ return False
+
def check_license_flags(d):
"""
This function checks if a recipe has any LICENSE_FLAGS that
diff --git a/meta/recipes-core/packagegroups/packagegroup-base.bb b/meta/recipes-core/packagegroups/packagegroup-base.bb
index 7489ef61b0..1c97d03c21 100644
--- a/meta/recipes-core/packagegroups/packagegroup-base.bb
+++ b/meta/recipes-core/packagegroups/packagegroup-base.bb
@@ -14,6 +14,8 @@ PACKAGES = ' \
packagegroup-distro-base \
packagegroup-machine-base \
\
+ ${@"dbench" if not any_incompatible(d, "dbench", "GPL-3.0-only") else ""} \
+ \
${@bb.utils.contains("MACHINE_FEATURES", "acpi", "packagegroup-base-acpi", "",d)} \
${@bb.utils.contains("MACHINE_FEATURES", "alsa", "packagegroup-base-alsa", "", d)} \
${@bb.utils.contains("MACHINE_FEATURES", "apm", "packagegroup-base-apm", "", d)} \
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] license: add 'any_incompatible' function
2022-04-13 16:00 [PATCH v2] license: add 'any_incompatible' function Christopher Larson
@ 2022-04-13 16:00 ` Christopher Larson
2022-04-13 17:44 ` [OE-core] [PATCH v2] " Richard Purdie
1 sibling, 0 replies; 8+ messages in thread
From: Christopher Larson @ 2022-04-13 16:00 UTC (permalink / raw)
To: openembedded-core; +Cc: Christopher Larson
This function returns True if any of the specified packages are skipped due to
incompatible license.
License exceptions are obeyed. The user may specify the package's license for
cross-recipe checks.
This allows for additions to packagegroups only for non-incompatible builds. For
example:
RDEPENDS_${PN} += "${@'dbench' if not any_incompatible(d, 'dbench', 'GPL-3.0-only') else ''}"
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
meta/classes/license.bbclass | 38 +++++++++++++++++++
.../packagegroups/packagegroup-base.bb | 2 +
2 files changed, 40 insertions(+)
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 0c637e966e..41993b7227 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -320,6 +320,44 @@ def incompatible_license(d, dont_want_licenses, package=None):
return incompatible_pkg_license(d, dont_want_licenses, license)
+def any_incompatible(d, packages, licensestring=None):
+ """Return True if any of the packages are skipped due to incompatible license.
+
+ License exceptions are obeyed. The user may specify the package's license
+ for cross-recipe checks.
+
+ This allows for additions to packagegroups only for non-incompatible builds.
+
+ For example: 'dbench' if not any_incompatible(d, 'dbench', 'GPL-3.0-only') else ''
+ """
+ import oe.license
+
+ if isinstance(packages, str):
+ packages = packages.split()
+
+ bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE") or "").split()
+ if not bad_licenses:
+ return False
+ bad_licenses = expand_wildcard_licenses(d, bad_licenses)
+
+ if licensestring is None:
+ licensestring = d.getVar("LICENSE:%s" % package) if package else None
+ if not licensestring:
+ licensestring = d.getVar("LICENSE")
+
+ exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
+ for pkg in packages:
+ remaining_bad_licenses = oe.license.apply_pkg_license_exception(
+ pkg, bad_licenses, exceptions
+ )
+
+ incompatible_lic = incompatible_pkg_license(
+ d, remaining_bad_licenses, licensestring
+ )
+ if incompatible_lic:
+ return True
+ return False
+
def check_license_flags(d):
"""
This function checks if a recipe has any LICENSE_FLAGS that
diff --git a/meta/recipes-core/packagegroups/packagegroup-base.bb b/meta/recipes-core/packagegroups/packagegroup-base.bb
index 7489ef61b0..1c97d03c21 100644
--- a/meta/recipes-core/packagegroups/packagegroup-base.bb
+++ b/meta/recipes-core/packagegroups/packagegroup-base.bb
@@ -14,6 +14,8 @@ PACKAGES = ' \
packagegroup-distro-base \
packagegroup-machine-base \
\
+ ${@"dbench" if not any_incompatible(d, "dbench", "GPL-3.0-only") else ""} \
+ \
${@bb.utils.contains("MACHINE_FEATURES", "acpi", "packagegroup-base-acpi", "",d)} \
${@bb.utils.contains("MACHINE_FEATURES", "alsa", "packagegroup-base-alsa", "", d)} \
${@bb.utils.contains("MACHINE_FEATURES", "apm", "packagegroup-base-apm", "", d)} \
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v2] license: add 'any_incompatible' function
2022-04-13 16:00 [PATCH v2] license: add 'any_incompatible' function Christopher Larson
2022-04-13 16:00 ` [PATCH] " Christopher Larson
@ 2022-04-13 17:44 ` Richard Purdie
2022-04-13 18:07 ` Christopher Larson
2022-04-13 20:35 ` Peter Kjellerstedt
1 sibling, 2 replies; 8+ messages in thread
From: Richard Purdie @ 2022-04-13 17:44 UTC (permalink / raw)
To: Christopher Larson, openembedded-core; +Cc: Christopher Larson
On Wed, 2022-04-13 at 16:00 +0000, Christopher Larson wrote:
> This function returns True if any of the specified packages are skipped due to
> incompatible license.
>
> License exceptions are obeyed. The user may specify the package's license for
> cross-recipe checks.
>
> This allows for additions to packagegroups only for non-incompatible builds. For
> example:
>
> RDEPENDS_${PN} += "${@'dbench' if not any_incompatible(d, 'dbench', 'GPL-3.0-only') else ''}"
>
> Signed-off-by: Christopher Larson <chris_larson@mentor.com>
> ---
> meta/classes/license.bbclass | 38 +++++++++++++++++++
> .../packagegroups/packagegroup-base.bb | 2 +
> 2 files changed, 40 insertions(+)
>
> v2 changes: fixed string packages logic, corrected reference to
> apply_pkg_license_exception, and avoided use of ${@} in the function docstring
> to avoid bitbake expanding it and recursing.
>
> diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
> index 0c637e966e..41993b7227 100644
> --- a/meta/classes/license.bbclass
> +++ b/meta/classes/license.bbclass
> @@ -320,6 +320,44 @@ def incompatible_license(d, dont_want_licenses, package=None):
>
> return incompatible_pkg_license(d, dont_want_licenses, license)
>
> +def any_incompatible(d, packages, licensestring=None):
> + """Return True if any of the packages are skipped due to incompatible license.
> +
> + License exceptions are obeyed. The user may specify the package's license
> + for cross-recipe checks.
> +
> + This allows for additions to packagegroups only for non-incompatible builds.
> +
> + For example: 'dbench' if not any_incompatible(d, 'dbench', 'GPL-3.0-only') else ''
> + """
> + import oe.license
> +
> + if isinstance(packages, str):
> + packages = packages.split()
> +
> + bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE") or "").split()
> + if not bad_licenses:
> + return False
> + bad_licenses = expand_wildcard_licenses(d, bad_licenses)
> +
> + if licensestring is None:
> + licensestring = d.getVar("LICENSE:%s" % package) if package else None
> + if not licensestring:
> + licensestring = d.getVar("LICENSE")
> +
> + exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
> + for pkg in packages:
> + remaining_bad_licenses = oe.license.apply_pkg_license_exception(
> + pkg, bad_licenses, exceptions
> + )
> +
> + incompatible_lic = incompatible_pkg_license(
> + d, remaining_bad_licenses, licensestring
> + )
> + if incompatible_lic:
> + return True
> + return False
> +
> def check_license_flags(d):
> """
> This function checks if a recipe has any LICENSE_FLAGS that
> diff --git a/meta/recipes-core/packagegroups/packagegroup-base.bb b/meta/recipes-core/packagegroups/packagegroup-base.bb
> index 7489ef61b0..1c97d03c21 100644
> --- a/meta/recipes-core/packagegroups/packagegroup-base.bb
> +++ b/meta/recipes-core/packagegroups/packagegroup-base.bb
> @@ -14,6 +14,8 @@ PACKAGES = ' \
> packagegroup-distro-base \
> packagegroup-machine-base \
> \
> + ${@"dbench" if not any_incompatible(d, "dbench", "GPL-3.0-only") else ""} \
> + \
> ${@bb.utils.contains("MACHINE_FEATURES", "acpi", "packagegroup-base-acpi", "",d)} \
> ${@bb.utils.contains("MACHINE_FEATURES", "alsa", "packagegroup-base-alsa", "", d)} \
> ${@bb.utils.contains("MACHINE_FEATURES", "apm", "packagegroup-base-apm", "", d)} \
I suspect you didn't mean to include this piece since dbench isn't in core?
Cheers,
Richard
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v2] license: add 'any_incompatible' function
2022-04-13 17:44 ` [OE-core] [PATCH v2] " Richard Purdie
@ 2022-04-13 18:07 ` Christopher Larson
2022-04-13 20:35 ` Peter Kjellerstedt
1 sibling, 0 replies; 8+ messages in thread
From: Christopher Larson @ 2022-04-13 18:07 UTC (permalink / raw)
To: openembedded-core, Richard Purdie; +Cc: Christopher Larson
[-- Attachment #1: Type: text/plain, Size: 4029 bytes --]
It’s just an example, but you’re right, I’ll change to a better one. Thanks!
--
Christopher Larson
chris_larson@mentor.com, chris.larson@siemens.com, kergoth@gmail.com
Principal Software Engineer, Embedded Linux Solutions, Siemens Digital Industries Software
On Apr 13, 2022, 10:44 AM -0700, Richard Purdie <richard.purdie@linuxfoundation.org>, wrote:
> On Wed, 2022-04-13 at 16:00 +0000, Christopher Larson wrote:
> > This function returns True if any of the specified packages are skipped due to
> > incompatible license.
> >
> > License exceptions are obeyed. The user may specify the package's license for
> > cross-recipe checks.
> >
> > This allows for additions to packagegroups only for non-incompatible builds. For
> > example:
> >
> > RDEPENDS_${PN} += "${@'dbench' if not any_incompatible(d, 'dbench', 'GPL-3.0-only') else ''}"
> >
> > Signed-off-by: Christopher Larson <chris_larson@mentor.com>
> > ---
> > meta/classes/license.bbclass | 38 +++++++++++++++++++
> > .../packagegroups/packagegroup-base.bb | 2 +
> > 2 files changed, 40 insertions(+)
> >
> > v2 changes: fixed string packages logic, corrected reference to
> > apply_pkg_license_exception, and avoided use of ${@} in the function docstring
> > to avoid bitbake expanding it and recursing.
> >
> > diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
> > index 0c637e966e..41993b7227 100644
> > --- a/meta/classes/license.bbclass
> > +++ b/meta/classes/license.bbclass
> > @@ -320,6 +320,44 @@ def incompatible_license(d, dont_want_licenses, package=None):
> >
> > return incompatible_pkg_license(d, dont_want_licenses, license)
> >
> > +def any_incompatible(d, packages, licensestring=None):
> > + """Return True if any of the packages are skipped due to incompatible license.
> > +
> > + License exceptions are obeyed. The user may specify the package's license
> > + for cross-recipe checks.
> > +
> > + This allows for additions to packagegroups only for non-incompatible builds.
> > +
> > + For example: 'dbench' if not any_incompatible(d, 'dbench', 'GPL-3.0-only') else ''
> > + """
> > + import oe.license
> > +
> > + if isinstance(packages, str):
> > + packages = packages.split()
> > +
> > + bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE") or "").split()
> > + if not bad_licenses:
> > + return False
> > + bad_licenses = expand_wildcard_licenses(d, bad_licenses)
> > +
> > + if licensestring is None:
> > + licensestring = d.getVar("LICENSE:%s" % package) if package else None
> > + if not licensestring:
> > + licensestring = d.getVar("LICENSE")
> > +
> > + exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
> > + for pkg in packages:
> > + remaining_bad_licenses = oe.license.apply_pkg_license_exception(
> > + pkg, bad_licenses, exceptions
> > + )
> > +
> > + incompatible_lic = incompatible_pkg_license(
> > + d, remaining_bad_licenses, licensestring
> > + )
> > + if incompatible_lic:
> > + return True
> > + return False
> > +
> > def check_license_flags(d):
> > """
> > This function checks if a recipe has any LICENSE_FLAGS that
> > diff --git a/meta/recipes-core/packagegroups/packagegroup-base.bb b/meta/recipes-core/packagegroups/packagegroup-base.bb
> > index 7489ef61b0..1c97d03c21 100644
> > --- a/meta/recipes-core/packagegroups/packagegroup-base.bb
> > +++ b/meta/recipes-core/packagegroups/packagegroup-base.bb
> > @@ -14,6 +14,8 @@ PACKAGES = ' \
> > packagegroup-distro-base \
> > packagegroup-machine-base \
> > \
> > + ${@"dbench" if not any_incompatible(d, "dbench", "GPL-3.0-only") else ""} \
> > + \
> > ${@bb.utils.contains("MACHINE_FEATURES", "acpi", "packagegroup-base-acpi", "",d)} \
> > ${@bb.utils.contains("MACHINE_FEATURES", "alsa", "packagegroup-base-alsa", "", d)} \
> > ${@bb.utils.contains("MACHINE_FEATURES", "apm", "packagegroup-base-apm", "", d)} \
>
> I suspect you didn't mean to include this piece since dbench isn't in core?
>
> Cheers,
>
> Richard
>
[-- Attachment #2: Type: text/html, Size: 5075 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [OE-core] [PATCH v2] license: add 'any_incompatible' function
2022-04-13 17:44 ` [OE-core] [PATCH v2] " Richard Purdie
2022-04-13 18:07 ` Christopher Larson
@ 2022-04-13 20:35 ` Peter Kjellerstedt
2022-04-13 20:40 ` Christopher Larson
2022-04-22 16:59 ` Christopher Larson
1 sibling, 2 replies; 8+ messages in thread
From: Peter Kjellerstedt @ 2022-04-13 20:35 UTC (permalink / raw)
To: Richard Purdie, Christopher Larson,
openembedded-core@lists.openembedded.org
Cc: Christopher Larson
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Richard Purdie
> Sent: den 13 april 2022 19:45
> To: Christopher Larson <kergoth@gmail.com>; openembedded-core@lists.openembedded.org
> Cc: Christopher Larson <chris_larson@mentor.com>
> Subject: Re: [OE-core] [PATCH v2] license: add 'any_incompatible' function
>
> On Wed, 2022-04-13 at 16:00 +0000, Christopher Larson wrote:
> > This function returns True if any of the specified packages are skipped due to
> > incompatible license.
> >
> > License exceptions are obeyed. The user may specify the package's license for
> > cross-recipe checks.
> >
> > This allows for additions to packagegroups only for non-incompatible builds. For
> > example:
> >
> > RDEPENDS_${PN} += "${@'dbench' if not any_incompatible(d, 'dbench', 'GPL-3.0-only') else ''}"
> >
> > Signed-off-by: Christopher Larson <chris_larson@mentor.com>
> > ---
> > meta/classes/license.bbclass | 38 +++++++++++++++++++
> > .../packagegroups/packagegroup-base.bb | 2 +
> > 2 files changed, 40 insertions(+)
> >
> > v2 changes: fixed string packages logic, corrected reference to
> > apply_pkg_license_exception, and avoided use of ${@} in the function docstring
> > to avoid bitbake expanding it and recursing.
> >
> > diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
> > index 0c637e966e..41993b7227 100644
> > --- a/meta/classes/license.bbclass
> > +++ b/meta/classes/license.bbclass
> > @@ -320,6 +320,44 @@ def incompatible_license(d, dont_want_licenses, package=None):
> >
> > return incompatible_pkg_license(d, dont_want_licenses, license)
> >
> > +def any_incompatible(d, packages, licensestring=None):
> > + """Return True if any of the packages are skipped due to incompatible license.
> > +
> > + License exceptions are obeyed. The user may specify the package's license
> > + for cross-recipe checks.
> > +
> > + This allows for additions to packagegroups only for non-incompatible builds.
> > +
> > + For example: 'dbench' if not any_incompatible(d, 'dbench', 'GPL-3.0-only') else ''
> > + """
> > + import oe.license
> > +
> > + if isinstance(packages, str):
> > + packages = packages.split()
> > +
> > + bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE") or "").split()
> > + if not bad_licenses:
> > + return False
> > + bad_licenses = expand_wildcard_licenses(d, bad_licenses)
> > +
> > + if licensestring is None:
> > + licensestring = d.getVar("LICENSE:%s" % package) if package else None
> > + if not licensestring:
> > + licensestring = d.getVar("LICENSE")
> > +
> > + exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
> > + for pkg in packages:
> > + remaining_bad_licenses = oe.license.apply_pkg_license_exception(
> > + pkg, bad_licenses, exceptions
> > + )
> > +
> > + incompatible_lic = incompatible_pkg_license(
> > + d, remaining_bad_licenses, licensestring
> > + )
> > + if incompatible_lic:
> > + return True
> > + return False
> > +
> > def check_license_flags(d):
> > """
> > This function checks if a recipe has any LICENSE_FLAGS that
> > diff --git a/meta/recipes-core/packagegroups/packagegroup-base.bb b/meta/recipes-core/packagegroups/packagegroup-base.bb
> > index 7489ef61b0..1c97d03c21 100644
> > --- a/meta/recipes-core/packagegroups/packagegroup-base.bb
> > +++ b/meta/recipes-core/packagegroups/packagegroup-base.bb
> > @@ -14,6 +14,8 @@ PACKAGES = ' \
> > packagegroup-distro-base \
> > packagegroup-machine-base \
> > \
> > + ${@"dbench" if not any_incompatible(d, "dbench", "GPL-3.0-only") else ""} \
This usage seems error prone at best. What if the license for dbench
is changed?
Also, the way I would prefer to do something like the above (assuming you
meant to include it as a dependency in RDEPENDS:${PN} rather than PACKAGES)
would be to instead unconditionally add it to RRECOMMENDS:${PN}. Then
the normal licensing support should skip the package if you have the
incompatible license globally configured, but since it is only a
recommendation, that should not be a problem.
However, one thing I just realized that isn't working is if you have a
recommendation on a package and then only configure incompatible licenses
per image. This is normally the preferred way to handle incompatible
licenses as you can determine per image if a package should be allowed to
be installed or not. But because the installation of the packages is
handled by the package manager, and the license compliance is handled
later by bitbake, there is currently nothing telling the package manager
to skip the installation of the unwanted package due to its license, and
instead there is an error because bitbake sees that it was installed. :(
> > + \
> > ${@bb.utils.contains("MACHINE_FEATURES", "acpi", "packagegroup-base-acpi", "",d)} \
> > ${@bb.utils.contains("MACHINE_FEATURES", "alsa", "packagegroup-base-alsa", "", d)} \
> > ${@bb.utils.contains("MACHINE_FEATURES", "apm", "packagegroup-base-apm", "", d)} \
>
> I suspect you didn't mean to include this piece since dbench isn't in
> core?
>
> Cheers,
>
> Richard
//Peter
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v2] license: add 'any_incompatible' function
2022-04-13 20:35 ` Peter Kjellerstedt
@ 2022-04-13 20:40 ` Christopher Larson
2022-04-22 16:59 ` Christopher Larson
1 sibling, 0 replies; 8+ messages in thread
From: Christopher Larson @ 2022-04-13 20:40 UTC (permalink / raw)
To: Peter Kjellerstedt
Cc: Richard Purdie, openembedded-core@lists.openembedded.org
[-- Attachment #1: Type: text/plain, Size: 5387 bytes --]
On Wed, Apr 13, 2022 at 1:35 PM Peter Kjellerstedt <
peter.kjellerstedt@axis.com> wrote:
> > -----Original Message-----
> > From: openembedded-core@lists.openembedded.org <
> openembedded-core@lists.openembedded.org> On Behalf Of Richard Purdie
> > Sent: den 13 april 2022 19:45
> > To: Christopher Larson <kergoth@gmail.com>;
> openembedded-core@lists.openembedded.org
> > Cc: Christopher Larson <chris_larson@mentor.com>
> > Subject: Re: [OE-core] [PATCH v2] license: add 'any_incompatible'
> function
> >
> > On Wed, 2022-04-13 at 16:00 +0000, Christopher Larson wrote:
> > > This function returns True if any of the specified packages are
> skipped due to
> > > incompatible license.
> > >
> > > License exceptions are obeyed. The user may specify the package's
> license for
> > > cross-recipe checks.
> > >
> > > This allows for additions to packagegroups only for non-incompatible
> builds. For
> > > example:
> > >
> > > RDEPENDS_${PN} += "${@'dbench' if not any_incompatible(d,
> 'dbench', 'GPL-3.0-only') else ''}"
> > >
> > > Signed-off-by: Christopher Larson <chris_larson@mentor.com>
> > > ---
> > > meta/classes/license.bbclass | 38 +++++++++++++++++++
> > > .../packagegroups/packagegroup-base.bb | 2 +
> > > 2 files changed, 40 insertions(+)
> > >
> > > v2 changes: fixed string packages logic, corrected reference to
> > > apply_pkg_license_exception, and avoided use of ${@} in the function
> docstring
> > > to avoid bitbake expanding it and recursing.
> > >
> > > diff --git a/meta/classes/license.bbclass
> b/meta/classes/license.bbclass
> > > index 0c637e966e..41993b7227 100644
> > > --- a/meta/classes/license.bbclass
> > > +++ b/meta/classes/license.bbclass
> > > @@ -320,6 +320,44 @@ def incompatible_license(d, dont_want_licenses,
> package=None):
> > >
> > > return incompatible_pkg_license(d, dont_want_licenses, license)
> > >
> > > +def any_incompatible(d, packages, licensestring=None):
> > > + """Return True if any of the packages are skipped due to
> incompatible license.
> > > +
> > > + License exceptions are obeyed. The user may specify the package's
> license
> > > + for cross-recipe checks.
> > > +
> > > + This allows for additions to packagegroups only for
> non-incompatible builds.
> > > +
> > > + For example: 'dbench' if not any_incompatible(d, 'dbench',
> 'GPL-3.0-only') else ''
> > > + """
> > > + import oe.license
> > > +
> > > + if isinstance(packages, str):
> > > + packages = packages.split()
> > > +
> > > + bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE") or "").split()
> > > + if not bad_licenses:
> > > + return False
> > > + bad_licenses = expand_wildcard_licenses(d, bad_licenses)
> > > +
> > > + if licensestring is None:
> > > + licensestring = d.getVar("LICENSE:%s" % package) if package
> else None
> > > + if not licensestring:
> > > + licensestring = d.getVar("LICENSE")
> > > +
> > > + exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or
> "").split()
> > > + for pkg in packages:
> > > + remaining_bad_licenses =
> oe.license.apply_pkg_license_exception(
> > > + pkg, bad_licenses, exceptions
> > > + )
> > > +
> > > + incompatible_lic = incompatible_pkg_license(
> > > + d, remaining_bad_licenses, licensestring
> > > + )
> > > + if incompatible_lic:
> > > + return True
> > > + return False
> > > +
> > > def check_license_flags(d):
> > > """
> > > This function checks if a recipe has any LICENSE_FLAGS that
> > > diff --git a/meta/recipes-core/packagegroups/packagegroup-base.bb
> b/meta/recipes-core/packagegroups/packagegroup-base.bb
> > > index 7489ef61b0..1c97d03c21 100644
> > > --- a/meta/recipes-core/packagegroups/packagegroup-base.bb
> > > +++ b/meta/recipes-core/packagegroups/packagegroup-base.bb
> > > @@ -14,6 +14,8 @@ PACKAGES = ' \
> > > packagegroup-distro-base \
> > > packagegroup-machine-base \
> > > \
> > > + ${@"dbench" if not any_incompatible(d, "dbench",
> "GPL-3.0-only") else ""} \
>
> This usage seems error prone at best. What if the license for dbench
> is changed?
>
It is, but we can't know other recipes licenses, so the options are
limited. It's also not the only similar thing we do along these lines. More
than once we've had to exclude something from a packagegroup based on the
current context and our knowledge that it's not buildable in this context,
such as knowing the required distro features of the recipe or its
unsupported architectures or COMPATIBLE_MACHINE.
I don't love it, but I don't see a lot of alternatives. RRECOMMENDS is an
interesting idea, but I don't believe it works as you'd hope today, and
would presumably require use of BAD_RECOMMENDATIONS for pickier images. I'm
certainly open to the alternatives on this, but in the meantime some
images/packagegroups just aren't buildable at all for incompatible_license
builds right now without risking layer-inclusion-based tweaks in meta-gplv2.
> I suspect you didn't mean to include this piece since dbench isn't in
> > core?
>
Indeed, v3 forthcoming. Thanks!
--
Christopher Larson
chris_larson@mentor.com, chris.larson@siemens.com, kergoth@gmail.com
Principal Software Engineer, Embedded Linux Solutions, Siemens Digital
Industries Software
[-- Attachment #2: Type: text/html, Size: 8069 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [OE-core] [PATCH v2] license: add 'any_incompatible' function
2022-04-13 20:35 ` Peter Kjellerstedt
2022-04-13 20:40 ` Christopher Larson
@ 2022-04-22 16:59 ` Christopher Larson
1 sibling, 0 replies; 8+ messages in thread
From: Christopher Larson @ 2022-04-22 16:59 UTC (permalink / raw)
To: Peter Kjellerstedt
Cc: Richard Purdie, openembedded-core@lists.openembedded.org
[-- Attachment #1: Type: text/plain, Size: 1258 bytes --]
On Wed, Apr 13, 2022 at 1:35 PM Peter Kjellerstedt <
peter.kjellerstedt@axis.com> wrote:
> > > + ${@"dbench" if not any_incompatible(d, "dbench",
> "GPL-3.0-only") else ""} \
>
> This usage seems error prone at best. What if the license for dbench
> is changed?
>
> Also, the way I would prefer to do something like the above (assuming you
> meant to include it as a dependency in RDEPENDS:${PN} rather than
> PACKAGES)
> would be to instead unconditionally add it to RRECOMMENDS:${PN}. Then
> the normal licensing support should skip the package if you have the
> incompatible license globally configured, but since it is only a
> recommendation, that should not be a problem.
The issue is, a missing RRECOMMENDS will currently abort the build. Bitbake
doesn't treat RRECOMMENDS as optional to build, only optional to install,
so this approach is not viable. I'm still submitting v3 of this to get the
job done for now. Thanks for your thoughts, though, I actually agree that
your idea is a better method, it just doesn't work with bitbake as it
stands today!
--
Christopher Larson
chris_larson@mentor.com, chris.larson@siemens.com, kergoth@gmail.com
Principal Software Engineer, Embedded Linux Solutions, Siemens Digital
Industries Software
[-- Attachment #2: Type: text/html, Size: 1840 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-04-22 19:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-13 16:00 [PATCH v2] license: add 'any_incompatible' function Christopher Larson
2022-04-13 16:00 ` [PATCH] " Christopher Larson
2022-04-13 17:44 ` [OE-core] [PATCH v2] " Richard Purdie
2022-04-13 18:07 ` Christopher Larson
2022-04-13 20:35 ` Peter Kjellerstedt
2022-04-13 20:40 ` Christopher Larson
2022-04-22 16:59 ` Christopher Larson
-- strict thread matches above, loose matches on Subject: below --
2022-04-11 16:14 [PATCH] " Christopher Larson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox