summaryrefslogtreecommitdiffstats
path: root/meta/classes/base.bbclass
diff options
context:
space:
mode:
authorSaul Wold <Saul.Wold@windriver.com>2022-02-23 17:26:59 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-03-02 18:43:25 +0000
commitd6449581c998a24145e527c571b3baf90a9f2518 (patch)
treef20a0fd2e91dd9fb294e5243f28b1533fc8ec21c /meta/classes/base.bbclass
parent9ead8e762e977d41b0107553b4827f9a7edc252f (diff)
downloadpoky-d6449581c998a24145e527c571b3baf90a9f2518.tar.gz
base/license: Rework INCOMPATIBLE_LICENSE variable handling
This re-writes the INCOMPATIBLE_LICENSE checking code to replace the WHITELIST_<lic> with INCOMPATIBLE_LICENSE_EXCEPTIONS = '<pkg>:<lic> <pkg>:<lic> ...' This initial change leaves most of the code structure in place, but the code in base.bbclass needs to be re-written to make the check more consistent around packages (PKGS) and not recipe names (PN). This also is taking into account the changes for SPDX licenses. The aim is to provide a mode consistent variable where the variable name is known and can easily be queried. (From OE-Core rev: 0d19c45ba6cf43518f380ca5afe9753a2eda0691) Signed-off-by: Saul Wold <saul.wold@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/base.bbclass')
-rw-r--r--meta/classes/base.bbclass67
1 files changed, 28 insertions, 39 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 55f654d37d..1d5db96afb 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -595,46 +595,35 @@ python () {
595 if check_license and bad_licenses: 595 if check_license and bad_licenses:
596 bad_licenses = expand_wildcard_licenses(d, bad_licenses) 596 bad_licenses = expand_wildcard_licenses(d, bad_licenses)
597 597
598 whitelist = [] 598 exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
599 for lic in bad_licenses: 599
600 spdx_license = return_spdx(d, lic) 600 pkgs = d.getVar('PACKAGES').split()
601 whitelist.extend((d.getVar("WHITELIST_" + lic) or "").split()) 601 skipped_pkgs = {}
602 if spdx_license: 602 unskipped_pkgs = []
603 whitelist.extend((d.getVar("WHITELIST_" + spdx_license) or "").split()) 603 for pkg in pkgs:
604 604 remaining_bad_licenses = oe.license.apply_pkg_license_exception(pkg, bad_licenses, exceptions)
605 if pn in whitelist: 605
606 ''' 606 incompatible_lic = incompatible_license(d, remaining_bad_licenses, pkg)
607 We need to track what we are whitelisting and why. If pn is 607 if incompatible_lic:
608 incompatible we need to be able to note that the image that 608 skipped_pkgs[pkg] = incompatible_lic
609 is created may infact contain incompatible licenses despite
610 INCOMPATIBLE_LICENSE being set.
611 '''
612 bb.note("Including %s as buildable despite it having an incompatible license because it has been whitelisted" % pn)
613 else:
614 pkgs = d.getVar('PACKAGES').split()
615 skipped_pkgs = {}
616 unskipped_pkgs = []
617 for pkg in pkgs:
618 incompatible_lic = incompatible_license(d, bad_licenses, pkg)
619 if incompatible_lic:
620 skipped_pkgs[pkg] = incompatible_lic
621 else:
622 unskipped_pkgs.append(pkg)
623 if unskipped_pkgs:
624 for pkg in skipped_pkgs:
625 bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg])))
626 d.setVar('_exclude_incompatible-' + pkg, ' '.join(skipped_pkgs[pkg]))
627 for pkg in unskipped_pkgs:
628 bb.debug(1, "Including the package %s" % pkg)
629 else: 609 else:
630 incompatible_lic = incompatible_license(d, bad_licenses) 610 unskipped_pkgs.append(pkg)
631 for pkg in skipped_pkgs: 611
632 incompatible_lic += skipped_pkgs[pkg] 612 if unskipped_pkgs:
633 incompatible_lic = sorted(list(set(incompatible_lic))) 613 for pkg in skipped_pkgs:
634 614 bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg])))
635 if incompatible_lic: 615 d.setVar('_exclude_incompatible-' + pkg, ' '.join(skipped_pkgs[pkg]))
636 bb.debug(1, "Skipping recipe %s because of incompatible license(s): %s" % (pn, ' '.join(incompatible_lic))) 616 for pkg in unskipped_pkgs:
637 raise bb.parse.SkipRecipe("it has incompatible license(s): %s" % ' '.join(incompatible_lic)) 617 bb.debug(1, "Including the package %s" % pkg)
618 else:
619 incompatible_lic = incompatible_license(d, bad_licenses)
620 for pkg in skipped_pkgs:
621 incompatible_lic += skipped_pkgs[pkg]
622 incompatible_lic = sorted(list(set(incompatible_lic)))
623
624 if incompatible_lic:
625 bb.debug(1, "Skipping recipe %s because of incompatible license(s): %s" % (pn, ' '.join(incompatible_lic)))
626 raise bb.parse.SkipRecipe("it has incompatible license(s): %s" % ' '.join(incompatible_lic))
638 627
639 needsrcrev = False 628 needsrcrev = False
640 srcuri = d.getVar('SRC_URI') 629 srcuri = d.getVar('SRC_URI')