summaryrefslogtreecommitdiffstats
path: root/meta/classes/license.bbclass
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2015-05-08 20:41:29 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-09 22:28:14 +0100
commit8c7082de0ad2a963b5823834a83723127ddb454e (patch)
tree8d66960351cba20ebacc6544ef7a5dee14a93937 /meta/classes/license.bbclass
parentb971eb0313f483b0a0653189a8f56921cc242901 (diff)
downloadpoky-8c7082de0ad2a963b5823834a83723127ddb454e.tar.gz
license_class: Generalize license_ok function
Add dont_want_licenses as parameter to license_ok function and move it to oe.license module in order to use in other modules. (From OE-Core rev: 243fe3a4583a21ad6c0b2a26196ed18d41740f7a) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/license.bbclass')
-rw-r--r--meta/classes/license.bbclass21
1 files changed, 4 insertions, 17 deletions
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 975867d241..780b9d5863 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -341,36 +341,23 @@ def incompatible_license(d, dont_want_licenses, package=None):
341 take into consideration 'or' operand. dont_want_licenses should be passed 341 take into consideration 'or' operand. dont_want_licenses should be passed
342 as canonical (SPDX) names. 342 as canonical (SPDX) names.
343 """ 343 """
344 import re
345 import oe.license 344 import oe.license
346 from fnmatch import fnmatchcase as fnmatch
347 license = d.getVar("LICENSE_%s" % package, True) if package else None 345 license = d.getVar("LICENSE_%s" % package, True) if package else None
348 if not license: 346 if not license:
349 license = d.getVar('LICENSE', True) 347 license = d.getVar('LICENSE', True)
350 348
351 def license_ok(license):
352 for dwl in dont_want_licenses:
353 # If you want to exclude license named generically 'X', we
354 # surely want to exclude 'X+' as well. In consequence, we
355 # will exclude a trailing '+' character from LICENSE in
356 # case INCOMPATIBLE_LICENSE is not a 'X+' license.
357 lic = license
358 if not re.search('\+$', dwl):
359 lic = re.sub('\+', '', license)
360 if fnmatch(lic, dwl):
361 return False
362 return True
363
364 # Handles an "or" or two license sets provided by 349 # Handles an "or" or two license sets provided by
365 # flattened_licenses(), pick one that works if possible. 350 # flattened_licenses(), pick one that works if possible.
366 def choose_lic_set(a, b): 351 def choose_lic_set(a, b):
367 return a if all(license_ok(lic) for lic in a) else b 352 return a if all(oe.license.license_ok(lic, dont_want_licenses) \
353 for lic in a) else b
368 354
369 try: 355 try:
370 licenses = oe.license.flattened_licenses(license, choose_lic_set) 356 licenses = oe.license.flattened_licenses(license, choose_lic_set)
371 except oe.license.LicenseError as exc: 357 except oe.license.LicenseError as exc:
372 bb.fatal('%s: %s' % (d.getVar('P', True), exc)) 358 bb.fatal('%s: %s' % (d.getVar('P', True), exc))
373 return any(not license_ok(canonical_license(d, l)) for l in licenses) 359 return any(not oe.license.license_ok(canonical_license(d, l), \
360 dont_want_licenses) for l in licenses)
374 361
375def check_license_flags(d): 362def check_license_flags(d):
376 """ 363 """