diff options
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/base.bbclass | 2 | ||||
-rw-r--r-- | meta/classes/license.bbclass | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index de81a7d687..06cfe260ac 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass @@ -443,7 +443,7 @@ python () { check_license = False if check_license and bad_licenses: - bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses) + bad_licenses = expand_wildcard_licenses(d, bad_licenses) whitelist = [] for lic in bad_licenses: diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass index 14d3107c4a..ea4c8801e9 100644 --- a/meta/classes/license.bbclass +++ b/meta/classes/license.bbclass @@ -285,6 +285,31 @@ def canonical_license(d, license): lic += '+' return lic or license +def expand_wildcard_licenses(d, wildcard_licenses): + """ + Return actual spdx format license names if wildcard used. We expand + wildcards from SPDXLICENSEMAP flags and SRC_DISTRIBUTE_LICENSES values. + """ + import fnmatch + 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] + + spdx_lics = (d.getVar('SRC_DISTRIBUTE_LICENSES') or '').split() + for wld_lic in wildcard_licenses: + licenses += fnmatch.filter(spdx_lics, wld_lic) + + licenses = list(set(licenses)) + return licenses + +def incompatible_license_contains(license, truevalue, falsevalue, d): + license = canonical_license(d, license) + bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE', True) or "").split() + bad_licenses = expand_wildcard_licenses(d, bad_licenses) + return truevalue if license in bad_licenses else falsevalue + def incompatible_license(d, dont_want_licenses, package=None): """ This function checks if a recipe has only incompatible licenses. It also |