@@ -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
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(+)