diff options
author | Christopher Larson <chris_larson@mentor.com> | 2012-01-09 15:02:34 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-01-17 14:53:19 +0000 |
commit | 7ce97336aad5e6ecefb5e735a13e345d1b8bd8fb (patch) | |
tree | 270b4abfa31518895add0e9f2fbea7722288d07c /meta/classes/copyleft_compliance.bbclass | |
parent | 49a0821376ef6146345d673b1e9eddd34aee931a (diff) | |
download | poky-7ce97336aad5e6ecefb5e735a13e345d1b8bd8fb.tar.gz |
oe.license: add is_included convenience function
Given a license string and whitelist and blacklist, determine if the
license string matches the whitelist and does not match the blacklist.
When encountering an OR, it prefers the side with the highest weight (more
included licenses). It then checks the inclusion of the flattened list of
licenses from there.
Returns a tuple holding the boolean state and a list of the applicable
licenses which were excluded (or None, if the state is True)
Examples:
is_included, excluded = oe.license.is_included(licensestr, ['GPL*', 'LGPL*'])
is_included, excluded = oe.license.is_included(licensestr, blacklist=['Proprietary', 'CLOSED'])
(From OE-Core rev: 7903433898b4683a1c09cc9a6a379421bc9bbd58)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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""" |