From: Christopher Larson <kergoth@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Christopher Larson <chris_larson@mentor.com>
Subject: [PATCH v2] license: add 'any_incompatible' function
Date: Wed, 13 Apr 2022 16:00:32 +0000 [thread overview]
Message-ID: <20220413160033.8456-1-kergoth@gmail.com> (raw)
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
next reply other threads:[~2022-04-14 16:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-13 16:00 Christopher Larson [this message]
2022-04-13 16:00 ` [PATCH] license: add 'any_incompatible' function 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220413160033.8456-1-kergoth@gmail.com \
--to=kergoth@gmail.com \
--cc=chris_larson@mentor.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox