diff options
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) |