summaryrefslogtreecommitdiffstats
path: root/meta/classes/license_image.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/license_image.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/license_image.bbclass')
-rw-r--r--meta/classes/license_image.bbclass33
1 files changed, 14 insertions, 19 deletions
diff --git a/meta/classes/license_image.bbclass b/meta/classes/license_image.bbclass
index bf70bee99b..0a5ea0a2fb 100644
--- a/meta/classes/license_image.bbclass
+++ b/meta/classes/license_image.bbclass
@@ -54,28 +54,23 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs=True):
54 bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE") or "").split() 54 bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE") or "").split()
55 bad_licenses = expand_wildcard_licenses(d, bad_licenses) 55 bad_licenses = expand_wildcard_licenses(d, bad_licenses)
56 56
57 whitelist = [] 57 exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
58 for lic in bad_licenses:
59 whitelist.extend((d.getVar("WHITELIST_" + lic) or "").split())
60
61 with open(license_manifest, "w") as license_file: 58 with open(license_manifest, "w") as license_file:
62 for pkg in sorted(pkg_dic): 59 for pkg in sorted(pkg_dic):
63 if bad_licenses and pkg not in whitelist: 60 remaining_bad_licenses = oe.license.apply_pkg_license_exception(pkg, bad_licenses, exceptions)
64 try: 61 incompatible_licenses = incompatible_pkg_license(d, remaining_bad_licenses, pkg_dic[pkg]["LICENSE"])
65 licenses = incompatible_pkg_license(d, bad_licenses, pkg_dic[pkg]["LICENSE"]) 62 if incompatible_licenses:
66 if licenses: 63 bb.fatal("Package %s cannot be installed into the image because it has incompatible license(s): %s" %(pkg, ' '.join(incompatible_licenses)))
67 bb.fatal("Package %s cannot be installed into the image because it has incompatible license(s): %s" %(pkg, ' '.join(licenses)))
68 (pkg_dic[pkg]["LICENSE"], pkg_dic[pkg]["LICENSES"]) = \
69 oe.license.manifest_licenses(pkg_dic[pkg]["LICENSE"],
70 bad_licenses, canonical_license, d)
71 except oe.license.LicenseError as exc:
72 bb.fatal('%s: %s' % (d.getVar('P'), exc))
73 else: 64 else:
74 pkg_dic[pkg]["LICENSES"] = re.sub(r'[|&()*]', ' ', pkg_dic[pkg]["LICENSE"]) 65 incompatible_licenses = incompatible_pkg_license(d, bad_licenses, pkg_dic[pkg]["LICENSE"])
75 pkg_dic[pkg]["LICENSES"] = re.sub(r' *', ' ', pkg_dic[pkg]["LICENSES"]) 66 if incompatible_licenses:
76 pkg_dic[pkg]["LICENSES"] = pkg_dic[pkg]["LICENSES"].split() 67 oe.qa.handle_error('license-incompatible', "Including %s with incompatible license(s) %s into the image, because it has been allowed by exception list." %(pkg, ' '.join(incompatible_licenses)), d)
77 if pkg in whitelist: 68 try:
78 oe.qa.handle_error('license-incompatible', "Including %s with an incompatible license %s into the image, because it has been whitelisted." %(pkg, pkg_dic[pkg]["LICENSE"]), d) 69 (pkg_dic[pkg]["LICENSE"], pkg_dic[pkg]["LICENSES"]) = \
70 oe.license.manifest_licenses(pkg_dic[pkg]["LICENSE"],
71 remaining_bad_licenses, canonical_license, d)
72 except oe.license.LicenseError as exc:
73 bb.fatal('%s: %s' % (d.getVar('P'), exc))
79 74
80 if not "IMAGE_MANIFEST" in pkg_dic[pkg]: 75 if not "IMAGE_MANIFEST" in pkg_dic[pkg]:
81 # Rootfs manifest 76 # Rootfs manifest