diff options
| author | Andy Ross <andy.ross@windriver.com> | 2012-11-29 11:08:47 -0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-12-11 15:54:36 +0000 |
| commit | ec17940f7236a47983f2f1dc0208652a0b550c82 (patch) | |
| tree | 4cba1e1c28cef45eb22cb180bd20c2f566542ad8 /meta | |
| parent | 82d6ef6a7a582312e4c655f666ba4b641b005cd5 (diff) | |
| download | poky-ec17940f7236a47983f2f1dc0208652a0b550c82.tar.gz | |
base/license.bbclass: handle multiple INCOMPATIBLE_LICENSEs
Allow INCOMPATIBLE_LICENSE to be a whitespace-separated list of
incompatible license strings and/or glob patterns.
Also fix wildcarding: the string in INCOMPATIBLE_LICENSE was clearly
intended to match with wildcards (e.g. "*GPLv3" to match both GPLv3
and LGPLv3), but this was broken because of a bug in return_spdx()
which would die with a runtime error when there was no SPDXLICENSEMAP
entry for the string.
(From OE-Core rev: 8a8d00f4c9f7fe5f9f173b43b86cd18a6c75435c)
Signed-off-by: Andy Ross <andy.ross@windriver.com>
Signed-off-by: Elizabeth Flanagan <elizabeth.flanagan@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/classes/base.bbclass | 69 | ||||
| -rw-r--r-- | meta/classes/license.bbclass | 68 |
2 files changed, 60 insertions, 77 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index ac97a35c4c..f7b6fb8998 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass | |||
| @@ -525,43 +525,44 @@ python () { | |||
| 525 | raise bb.parse.SkipPackage("incompatible with machine %s (not in COMPATIBLE_MACHINE)" % this_machine) | 525 | raise bb.parse.SkipPackage("incompatible with machine %s (not in COMPATIBLE_MACHINE)" % this_machine) |
| 526 | 526 | ||
| 527 | 527 | ||
| 528 | dont_want_license = d.getVar('INCOMPATIBLE_LICENSE', True) | 528 | bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE', True) or "").split() |
| 529 | 529 | ||
| 530 | if dont_want_license and not pn.endswith("-native") and not pn.endswith("-cross") and not pn.endswith("-cross-initial") and not pn.endswith("-cross-intermediate") and not pn.endswith("-crosssdk-intermediate") and not pn.endswith("-crosssdk") and not pn.endswith("-crosssdk-initial") and not pn.endswith("-cross-canadian-%s" % d.getVar('TRANSLATED_TARGET_ARCH', True)) and not pn.startswith("nativesdk-"): | 530 | check_license = False if pn.startswith("nativesdk-") else True |
| 531 | # Internally, we'll use the license mapping. This way INCOMPATIBLE_LICENSE = "GPLv2" and | 531 | for t in ["-native", "-cross", "-cross-initial", "-cross-intermediate", |
| 532 | # INCOMPATIBLE_LICENSE = "GPLv2.0" will pick up all variations of GPL-2.0 | 532 | "-crosssdk-intermediate", "-crosssdk", "-crosssdk-initial", |
| 533 | spdx_license = return_spdx(d, dont_want_license) | 533 | "-cross-canadian-" + d.getVar('TRANSLATED_TARGET_ARCH', True)]: |
| 534 | hosttools_whitelist = (d.getVar('HOSTTOOLS_WHITELIST_%s' % dont_want_license, True) or d.getVar('HOSTTOOLS_WHITELIST_%s' % spdx_license, True) or "").split() | 534 | if pn.endswith(t): |
| 535 | lgplv2_whitelist = (d.getVar('LGPLv2_WHITELIST_%s' % dont_want_license, True) or d.getVar('HOSTTOOLS_WHITELIST_%s' % spdx_license, True) or "").split() | 535 | check_license = False |
| 536 | dont_want_whitelist = (d.getVar('WHITELIST_%s' % dont_want_license, True) or d.getVar('HOSTTOOLS_WHITELIST_%s' % spdx_license, True) or "").split() | 536 | |
| 537 | if pn not in hosttools_whitelist and pn not in lgplv2_whitelist and pn not in dont_want_whitelist: | 537 | if check_license and bad_licenses: |
| 538 | this_license = d.getVar('LICENSE', True) | 538 | whitelist = [] |
| 539 | # At this point we know the recipe contains an INCOMPATIBLE_LICENSE, however it may contain packages that do not. | 539 | for lic in bad_licenses: |
| 540 | packages = d.getVar('PACKAGES', True).split() | 540 | for w in ["HOSTTOOLS_WHITELIST_", "LGPLv2_WHITELIST_", "WHITELIST_"]: |
| 541 | dont_skip_recipe = False | 541 | whitelist.extend((d.getVar(w + lic, True) or "").split()) |
| 542 | skipped_packages = {} | 542 | spdx_license = return_spdx(d, lic) |
| 543 | unskipped_packages = [] | 543 | if spdx_license: |
| 544 | for pkg in packages: | 544 | whitelist.extend((d.getVar('HOSTTOOLS_WHITELIST_%s' % spdx_license, True) or "").split()) |
| 545 | if incompatible_license(d, dont_want_license, pkg): | 545 | if not pn in whitelist: |
| 546 | skipped_packages[pkg] = this_license | 546 | recipe_license = d.getVar('LICENSE', True) |
| 547 | dont_skip_recipe = True | 547 | pkgs = d.getVar('PACKAGES', True).split() |
| 548 | skipped_pkgs = [] | ||
| 549 | unskipped_pkgs = [] | ||
| 550 | for pkg in pkgs: | ||
| 551 | if incompatible_license(d, bad_licenses, pkg): | ||
| 552 | skipped_pkgs.append(pkg) | ||
| 548 | else: | 553 | else: |
| 549 | unskipped_packages.append(pkg) | 554 | unskipped_pkgs.append(pkg) |
| 550 | if not unskipped_packages: | 555 | some_skipped = skipped_pkgs and unskipped_pkgs |
| 551 | # if we hit here and have excluded all packages, then we can just exclude the recipe | 556 | all_skipped = skipped_pkgs and not unskipped_pkgs |
| 552 | dont_skip_recipe = False | 557 | if some_skipped: |
| 553 | elif skipped_packages and unskipped_packages: | 558 | for pkg in skipped_pkgs: |
| 554 | for pkg, license in skipped_packages.iteritems(): | 559 | bb.note("SKIPPING the package " + pkg + " at do_rootfs because it's " + recipe_license) |
| 555 | bb.note("SKIPPING the package " + pkg + " at do_rootfs because it's " + this_license) | ||
| 556 | d.setVar('LICENSE_EXCLUSION-' + pkg, 1) | 560 | d.setVar('LICENSE_EXCLUSION-' + pkg, 1) |
| 557 | for index, pkg in enumerate(unskipped_packages): | 561 | for pkg in unskipped_pkgs: |
| 558 | bb.note("INCLUDING the package " + pkg) | 562 | bb.note("INCLUDING the package " + pkg) |
| 559 | 563 | elif all_skipped or incompatible_license(d, bad_licenses): | |
| 560 | if dont_skip_recipe is False and incompatible_license(d, dont_want_license): | 564 | bb.note("SKIPPING recipe %s because it's %s" % (pn, recipe_license)) |
| 561 | bb.note("SKIPPING recipe %s because it's %s" % (pn, this_license)) | 565 | raise bb.parse.SkipPackage("incompatible with license %s" % recipe_license) |
| 562 | raise bb.parse.SkipPackage("incompatible with license %s" % this_license) | ||
| 563 | |||
| 564 | |||
| 565 | 566 | ||
| 566 | srcuri = d.getVar('SRC_URI', True) | 567 | srcuri = d.getVar('SRC_URI', True) |
| 567 | # Svn packages should DEPEND on subversion-native | 568 | # Svn packages should DEPEND on subversion-native |
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass index e1878956f8..68f45f52f0 100644 --- a/meta/classes/license.bbclass +++ b/meta/classes/license.bbclass | |||
| @@ -203,14 +203,11 @@ python do_populate_lic() { | |||
| 203 | 203 | ||
| 204 | def return_spdx(d, license): | 204 | def return_spdx(d, license): |
| 205 | """ | 205 | """ |
| 206 | This function returns the spdx mapping of a license. | 206 | This function returns the spdx mapping of a license if it exists. |
| 207 | """ | 207 | """ |
| 208 | if d.getVarFlag('SPDXLICENSEMAP', license) != None: | 208 | return d.getVarFlag('SPDXLICENSEMAP', license, True) |
| 209 | return license | ||
| 210 | else: | ||
| 211 | return d.getVarFlag('SPDXLICENSEMAP', license_type) | ||
| 212 | 209 | ||
| 213 | def incompatible_license(d, dont_want_license, package=""): | 210 | def incompatible_license(d, dont_want_licenses, package=None): |
| 214 | """ | 211 | """ |
| 215 | This function checks if a recipe has only incompatible licenses. It also take into consideration 'or' | 212 | This function checks if a recipe has only incompatible licenses. It also take into consideration 'or' |
| 216 | operand. | 213 | operand. |
| @@ -219,45 +216,30 @@ def incompatible_license(d, dont_want_license, package=""): | |||
| 219 | import oe.license | 216 | import oe.license |
| 220 | from fnmatch import fnmatchcase as fnmatch | 217 | from fnmatch import fnmatchcase as fnmatch |
| 221 | pn = d.getVar('PN', True) | 218 | pn = d.getVar('PN', True) |
| 222 | dont_want_licenses = [] | 219 | license = d.getVar("LICENSE_%s-%s" % (pn, package), True) if package else None |
| 223 | dont_want_licenses.append(d.getVar('INCOMPATIBLE_LICENSE', True)) | 220 | if not license: |
| 224 | recipe_license = d.getVar('LICENSE', True) | 221 | license = d.getVar('LICENSE', True) |
| 225 | if package != "": | 222 | |
| 226 | if d.getVar('LICENSE_' + pn + '-' + package, True): | 223 | def license_ok(license): |
| 227 | license = d.getVar('LICENSE_' + pn + '-' + package, True) | 224 | for dwl in dont_want_licenses: |
| 228 | else: | 225 | # If you want to exclude license named generically 'X', we |
| 229 | license = recipe_license | 226 | # surely want to exclude 'X+' as well. In consequence, we |
| 230 | else: | 227 | # will exclude a trailing '+' character from LICENSE in |
| 231 | license = recipe_license | 228 | # case INCOMPATIBLE_LICENSE is not a 'X+' license. |
| 232 | spdx_license = return_spdx(d, dont_want_license) | 229 | lic = license |
| 233 | dont_want_licenses.append(spdx_license) | 230 | if not re.search('\+$', dwl): |
| 234 | 231 | lic = re.sub('\+', '', license) | |
| 235 | def include_license(license): | 232 | if fnmatch(lic, dwl): |
| 236 | if any(fnmatch(license, pattern) for pattern in dont_want_licenses): | ||
| 237 | return False | 233 | return False |
| 238 | else: | 234 | return True |
| 239 | return True | ||
| 240 | 235 | ||
| 241 | def choose_licenses(a, b): | 236 | # Handles an "or" or two license sets provided by |
| 242 | if all(include_license(lic) for lic in a): | 237 | # flattened_licenses(), pick one that works if possible. |
| 243 | return a | 238 | def choose_lic_set(a, b): |
| 244 | else: | 239 | return a if all(license_ok(lic) for lic in a) else b |
| 245 | return b | ||
| 246 | 240 | ||
| 247 | """ | 241 | licenses=oe.license.flattened_licenses(license, choose_lic_set) |
| 248 | If you want to exlude license named generically 'X', we surely want to exlude 'X+' as well. | 242 | return any(not license_ok(l) for l in licenses) |
| 249 | In consequence, we will exclude the '+' character from LICENSE in case INCOMPATIBLE_LICENSE | ||
| 250 | is not a 'X+' license. | ||
| 251 | """ | ||
| 252 | if not re.search(r'[+]',dont_want_license): | ||
| 253 | licenses=oe.license.flattened_licenses(re.sub(r'[+]', '', license), choose_licenses) | ||
| 254 | else: | ||
| 255 | licenses=oe.license.flattened_licenses(license, choose_licenses) | ||
| 256 | |||
| 257 | for onelicense in licenses: | ||
| 258 | if not include_license(onelicense): | ||
| 259 | return True | ||
| 260 | return False | ||
| 261 | 243 | ||
| 262 | def check_license_flags(d): | 244 | def check_license_flags(d): |
| 263 | """ | 245 | """ |
