1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 13:29:49 +00:00

license: Rework INCOMPATIBLE_LICENSE wildcard handling

The current wildcard handling is badly documented and inconsistently
used and understood.

Forcing users to have to use "GPL-3.0-only GPL-3.0-or-later" whilst
explict is not very user friendly. Equally, using the current wildcards
is ambigious. This supports pre-defined expansions only and at least makes
it clear what GPL-3.0* means (it doesn't include the exception licenses).

This is hopefully an acceptable compromise between literal meaning and
having something usable.

Non-SPDX forms of license in this field have been dropped and errors are
shown for unsupported expansions and unsupported old style license terms.

Users need to carefully consider how to migrate to the new syntax but
the meaning should be well defined and clear from here forward.

(From OE-Core rev: 724fc8047cae6ed6197d7deca887b1594871c90e)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2022-02-28 15:40:32 +00:00
parent 321cf8962e
commit 82f24d2197
2 changed files with 78 additions and 65 deletions
+18 -19
View File
@@ -277,28 +277,27 @@ AVAILABLE_LICENSES := "${@' '.join(available_licenses(d))}"
def expand_wildcard_licenses(d, wildcard_licenses):
"""
Return actual spdx format license names if wildcards are used. We expand
wildcards from SPDXLICENSEMAP flags and AVAILABLE_LICENSES.
There are some common wildcard values users may want to use. Support them
here.
"""
import fnmatch
licenses = set(wildcard_licenses)
mapping = {
"GPL-3.0*" : ["GPL-3.0-only", "GPL-3.0-or-later"],
"LGPL-3.0*" : ["LGPL-3.0-only", "LGPL-3.0-or-later"],
}
for k in mapping:
if k in wildcard_licenses:
licenses.remove(k)
for item in mapping[k]:
licenses.add(item)
licenses = wildcard_licenses[:]
spdxmapkeys = d.getVarFlags('SPDXLICENSEMAP').keys()
for wld_lic in wildcard_licenses:
spdxflags = fnmatch.filter(spdxmapkeys, wld_lic)
licenses += [d.getVarFlag('SPDXLICENSEMAP', flag) for flag in spdxflags]
# Assume that if we are passed "GPL-3.0" or "*GPL-3.0", then it means
# "-or-later" as well.
if not wld_lic.endswith(("-or-later", "-only", "*", "+")):
spdxflags = fnmatch.filter(spdxmapkeys, wld_lic + "+")
licenses += [d.getVarFlag('SPDXLICENSEMAP', flag) for flag in spdxflags]
for l in licenses:
if l in oe.license.obsolete_license_list():
bb.fatal("Error, %s is an obsolete license, please use an SPDX reference in INCOMPATIBLE_LICENSE" % l)
if "*" in l:
bb.fatal("Error, %s is an invalid license wildcard entry" % l)
spdx_lics = d.getVar('AVAILABLE_LICENSES').split()
for wld_lic in wildcard_licenses:
licenses += fnmatch.filter(spdx_lics, wld_lic)
licenses = list(set(licenses))
return licenses
return list(licenses)
def incompatible_license_contains(license, truevalue, falsevalue, d):
license = canonical_license(d, license)