mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 09:49:33 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
9ead8e762e
commit
d6449581c9
@@ -54,28 +54,23 @@ def write_license_files(d, license_manifest, pkg_dic, rootfs=True):
|
||||
bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE") or "").split()
|
||||
bad_licenses = expand_wildcard_licenses(d, bad_licenses)
|
||||
|
||||
whitelist = []
|
||||
for lic in bad_licenses:
|
||||
whitelist.extend((d.getVar("WHITELIST_" + lic) or "").split())
|
||||
|
||||
exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
|
||||
with open(license_manifest, "w") as license_file:
|
||||
for pkg in sorted(pkg_dic):
|
||||
if bad_licenses and pkg not in whitelist:
|
||||
try:
|
||||
licenses = incompatible_pkg_license(d, bad_licenses, pkg_dic[pkg]["LICENSE"])
|
||||
if licenses:
|
||||
bb.fatal("Package %s cannot be installed into the image because it has incompatible license(s): %s" %(pkg, ' '.join(licenses)))
|
||||
(pkg_dic[pkg]["LICENSE"], pkg_dic[pkg]["LICENSES"]) = \
|
||||
oe.license.manifest_licenses(pkg_dic[pkg]["LICENSE"],
|
||||
bad_licenses, canonical_license, d)
|
||||
except oe.license.LicenseError as exc:
|
||||
bb.fatal('%s: %s' % (d.getVar('P'), exc))
|
||||
remaining_bad_licenses = oe.license.apply_pkg_license_exception(pkg, bad_licenses, exceptions)
|
||||
incompatible_licenses = incompatible_pkg_license(d, remaining_bad_licenses, pkg_dic[pkg]["LICENSE"])
|
||||
if incompatible_licenses:
|
||||
bb.fatal("Package %s cannot be installed into the image because it has incompatible license(s): %s" %(pkg, ' '.join(incompatible_licenses)))
|
||||
else:
|
||||
pkg_dic[pkg]["LICENSES"] = re.sub(r'[|&()*]', ' ', pkg_dic[pkg]["LICENSE"])
|
||||
pkg_dic[pkg]["LICENSES"] = re.sub(r' *', ' ', pkg_dic[pkg]["LICENSES"])
|
||||
pkg_dic[pkg]["LICENSES"] = pkg_dic[pkg]["LICENSES"].split()
|
||||
if pkg in whitelist:
|
||||
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)
|
||||
incompatible_licenses = incompatible_pkg_license(d, bad_licenses, pkg_dic[pkg]["LICENSE"])
|
||||
if incompatible_licenses:
|
||||
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)
|
||||
try:
|
||||
(pkg_dic[pkg]["LICENSE"], pkg_dic[pkg]["LICENSES"]) = \
|
||||
oe.license.manifest_licenses(pkg_dic[pkg]["LICENSE"],
|
||||
remaining_bad_licenses, canonical_license, d)
|
||||
except oe.license.LicenseError as exc:
|
||||
bb.fatal('%s: %s' % (d.getVar('P'), exc))
|
||||
|
||||
if not "IMAGE_MANIFEST" in pkg_dic[pkg]:
|
||||
# Rootfs manifest
|
||||
|
||||
Reference in New Issue
Block a user