diff options
Diffstat (limited to 'meta/classes/copyleft_compliance.bbclass')
-rw-r--r-- | meta/classes/copyleft_compliance.bbclass | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/meta/classes/copyleft_compliance.bbclass b/meta/classes/copyleft_compliance.bbclass index fd046381b6..6f058e0f20 100644 --- a/meta/classes/copyleft_compliance.bbclass +++ b/meta/classes/copyleft_compliance.bbclass | |||
@@ -46,32 +46,17 @@ def copyleft_should_include(d): | |||
46 | include = oe.data.typed_value('COPYLEFT_LICENSE_INCLUDE', d) | 46 | include = oe.data.typed_value('COPYLEFT_LICENSE_INCLUDE', d) |
47 | exclude = oe.data.typed_value('COPYLEFT_LICENSE_EXCLUDE', d) | 47 | exclude = oe.data.typed_value('COPYLEFT_LICENSE_EXCLUDE', d) |
48 | 48 | ||
49 | def include_license(license): | ||
50 | if any(fnmatch(license, pattern) for pattern in exclude): | ||
51 | return False | ||
52 | if any(fnmatch(license, pattern) for pattern in include): | ||
53 | return True | ||
54 | return False | ||
55 | |||
56 | def choose_licenses(a, b): | ||
57 | """Select the left option in an OR if all its licenses are to be included""" | ||
58 | if all(include_license(lic) for lic in a): | ||
59 | return a | ||
60 | else: | ||
61 | return b | ||
62 | |||
63 | try: | 49 | try: |
64 | licenses = oe.license.flattened_licenses(d.getVar('LICENSE', True), choose_licenses) | 50 | is_included, excluded = oe.license.is_included(d.getVar('LICENSE', True), include, exclude) |
65 | except oe.license.InvalidLicense as exc: | 51 | except oe.license.InvalidLicense as exc: |
66 | bb.fatal('%s: %s' % (d.getVar('PF', True), exc)) | 52 | bb.fatal('%s: %s' % (d.getVar('PF', True), exc)) |
67 | except SyntaxError as exc: | 53 | except SyntaxError as exc: |
68 | bb.warn('%s: error when parsing the LICENSE variable: %s' % (d.getVar('P', True), exc)) | 54 | bb.warn('%s: error when parsing the LICENSE variable: %s' % (d.getVar('P', True), exc)) |
69 | else: | 55 | else: |
70 | excluded = filter(lambda lic: not include_license(lic), licenses) | 56 | if is_included: |
71 | if excluded: | ||
72 | return False, 'recipe has excluded licenses: %s' % ', '.join(excluded) | ||
73 | else: | ||
74 | return True, None | 57 | return True, None |
58 | else: | ||
59 | return False, 'recipe has excluded licenses: %s' % ', '.join(excluded) | ||
75 | 60 | ||
76 | python do_prepare_copyleft_sources () { | 61 | python do_prepare_copyleft_sources () { |
77 | """Populate a tree of the recipe sources and emit patch series files""" | 62 | """Populate a tree of the recipe sources and emit patch series files""" |