diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-02-28 15:40:32 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-03-02 18:43:25 +0000 |
commit | 82f24d21978456476f631812e73033d23a7eac64 (patch) | |
tree | cb6ba9dee8ac5606664e70c15cc49f6ac5fb7df2 /meta/classes | |
parent | 321cf8962ea2f3ce6b3942fe02ec2ce8d258cce3 (diff) | |
download | poky-82f24d21978456476f631812e73033d23a7eac64.tar.gz |
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>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/license.bbclass | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass index 68c022248c..cb1f46983a 100644 --- a/meta/classes/license.bbclass +++ b/meta/classes/license.bbclass | |||
@@ -277,28 +277,27 @@ AVAILABLE_LICENSES := "${@' '.join(available_licenses(d))}" | |||
277 | 277 | ||
278 | def expand_wildcard_licenses(d, wildcard_licenses): | 278 | def expand_wildcard_licenses(d, wildcard_licenses): |
279 | """ | 279 | """ |
280 | Return actual spdx format license names if wildcards are used. We expand | 280 | There are some common wildcard values users may want to use. Support them |
281 | wildcards from SPDXLICENSEMAP flags and AVAILABLE_LICENSES. | 281 | here. |
282 | """ | 282 | """ |
283 | import fnmatch | 283 | licenses = set(wildcard_licenses) |
284 | 284 | mapping = { | |
285 | licenses = wildcard_licenses[:] | 285 | "GPL-3.0*" : ["GPL-3.0-only", "GPL-3.0-or-later"], |
286 | spdxmapkeys = d.getVarFlags('SPDXLICENSEMAP').keys() | 286 | "LGPL-3.0*" : ["LGPL-3.0-only", "LGPL-3.0-or-later"], |
287 | for wld_lic in wildcard_licenses: | 287 | } |
288 | spdxflags = fnmatch.filter(spdxmapkeys, wld_lic) | 288 | for k in mapping: |
289 | licenses += [d.getVarFlag('SPDXLICENSEMAP', flag) for flag in spdxflags] | 289 | if k in wildcard_licenses: |
290 | # Assume that if we are passed "GPL-3.0" or "*GPL-3.0", then it means | 290 | licenses.remove(k) |
291 | # "-or-later" as well. | 291 | for item in mapping[k]: |
292 | if not wld_lic.endswith(("-or-later", "-only", "*", "+")): | 292 | licenses.add(item) |
293 | spdxflags = fnmatch.filter(spdxmapkeys, wld_lic + "+") | 293 | |
294 | licenses += [d.getVarFlag('SPDXLICENSEMAP', flag) for flag in spdxflags] | 294 | for l in licenses: |
295 | 295 | if l in oe.license.obsolete_license_list(): | |
296 | spdx_lics = d.getVar('AVAILABLE_LICENSES').split() | 296 | bb.fatal("Error, %s is an obsolete license, please use an SPDX reference in INCOMPATIBLE_LICENSE" % l) |
297 | for wld_lic in wildcard_licenses: | 297 | if "*" in l: |
298 | licenses += fnmatch.filter(spdx_lics, wld_lic) | 298 | bb.fatal("Error, %s is an invalid license wildcard entry" % l) |
299 | 299 | ||
300 | licenses = list(set(licenses)) | 300 | return list(licenses) |
301 | return licenses | ||
302 | 301 | ||
303 | def incompatible_license_contains(license, truevalue, falsevalue, d): | 302 | def incompatible_license_contains(license, truevalue, falsevalue, d): |
304 | license = canonical_license(d, license) | 303 | license = canonical_license(d, license) |