diff options
author | Ross Burton <ross.burton@intel.com> | 2014-07-17 15:41:05 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-07-19 00:09:01 +0100 |
commit | ba197e6ff3bd511463d4b64629a1344d593073f2 (patch) | |
tree | f21b23fa52515c5afe2670a975f572dd9bcbbb72 /meta | |
parent | a9710bcfefcfe9fd4293d72b3ca477e397dd3f33 (diff) | |
download | poky-ba197e6ff3bd511463d4b64629a1344d593073f2.tar.gz |
license.bbclass: canonicalise licenses when dealing with INCOMPATIBLE_LICENSE
If INCOMPATIBLE_LICENSE=GPL-3.0 but the recipe sets LICENSE=GPLv3, the current
code won't trigger because they're different strings.
Fix this by attempting to canonicalise every license name to a SPDX name, so
both names in this example become GPL-3.0.
[ YOCTO #5622 ]
(From OE-Core rev: 8998e13fc95f11d15c34fb09d8451a9d4b69f2f1)
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/base.bbclass | 2 | ||||
-rw-r--r-- | meta/classes/license.bbclass | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index c0d2c8ec88..8114cf648b 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass | |||
@@ -540,6 +540,8 @@ python () { | |||
540 | check_license = False | 540 | check_license = False |
541 | 541 | ||
542 | if check_license and bad_licenses: | 542 | if check_license and bad_licenses: |
543 | bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses) | ||
544 | |||
543 | whitelist = [] | 545 | whitelist = [] |
544 | for lic in bad_licenses: | 546 | for lic in bad_licenses: |
545 | for w in ["HOSTTOOLS_WHITELIST_", "LGPLv2_WHITELIST_", "WHITELIST_"]: | 547 | for w in ["HOSTTOOLS_WHITELIST_", "LGPLv2_WHITELIST_", "WHITELIST_"]: |
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass index 2a6e869736..601f5611cc 100644 --- a/meta/classes/license.bbclass +++ b/meta/classes/license.bbclass | |||
@@ -264,10 +264,18 @@ def return_spdx(d, license): | |||
264 | """ | 264 | """ |
265 | return d.getVarFlag('SPDXLICENSEMAP', license, True) | 265 | return d.getVarFlag('SPDXLICENSEMAP', license, True) |
266 | 266 | ||
267 | def canonical_license(d, license): | ||
268 | """ | ||
269 | Return the canonical (SPDX) form of the license if available (so GPLv3 | ||
270 | becomes GPL-3.0), or the passed license if there is no canonical form. | ||
271 | """ | ||
272 | return d.getVarFlag('SPDXLICENSEMAP', license, True) or license | ||
273 | |||
267 | def incompatible_license(d, dont_want_licenses, package=None): | 274 | def incompatible_license(d, dont_want_licenses, package=None): |
268 | """ | 275 | """ |
269 | This function checks if a recipe has only incompatible licenses. It also take into consideration 'or' | 276 | This function checks if a recipe has only incompatible licenses. It also |
270 | operand. | 277 | take into consideration 'or' operand. dont_want_licenses should be passed |
278 | as canonical (SPDX) names. | ||
271 | """ | 279 | """ |
272 | import re | 280 | import re |
273 | import oe.license | 281 | import oe.license |
@@ -298,7 +306,7 @@ def incompatible_license(d, dont_want_licenses, package=None): | |||
298 | licenses = oe.license.flattened_licenses(license, choose_lic_set) | 306 | licenses = oe.license.flattened_licenses(license, choose_lic_set) |
299 | except oe.license.LicenseError as exc: | 307 | except oe.license.LicenseError as exc: |
300 | bb.fatal('%s: %s' % (d.getVar('P', True), exc)) | 308 | bb.fatal('%s: %s' % (d.getVar('P', True), exc)) |
301 | return any(not license_ok(l) for l in licenses) | 309 | return any(not license_ok(canonical_license(d, l)) for l in licenses) |
302 | 310 | ||
303 | def check_license_flags(d): | 311 | def check_license_flags(d): |
304 | """ | 312 | """ |