summaryrefslogtreecommitdiffstats
path: root/meta/classes/copyleft_filter.bbclass
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2014-03-24 13:39:26 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-25 09:55:35 +0000
commit4a91e1449b0c869979231b7f4c98e09c7a5d732a (patch)
treea312244c885b17792a28cab19d584ebf20cc7d88 /meta/classes/copyleft_filter.bbclass
parent39ea97470fbd5d2aee4d784494d4c5ad157960fb (diff)
downloadpoky-4a91e1449b0c869979231b7f4c98e09c7a5d732a.tar.gz
archiver.bbclass: make it can filter the license
* Filter the license (default: no), the recipe whose license in COPYLEFT_LICENSE_INCLUDE will be included, and in COPYLEFT_LICENSE_EXCLUDE will be excluded. * The user can set the recipe type that would be archived (native, target, and so on), deafult to all. The copyleft_filter.bbclass is come from copyleft_compliance.bbclass, which is used by both copyleft_compliance.bbclass and archiver.bbclass. [YOCTO #5740] (From OE-Core rev: 0e798d5cbcf585535e19633828dc540a282261fc) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/copyleft_filter.bbclass')
-rw-r--r--meta/classes/copyleft_filter.bbclass62
1 files changed, 62 insertions, 0 deletions
diff --git a/meta/classes/copyleft_filter.bbclass b/meta/classes/copyleft_filter.bbclass
new file mode 100644
index 0000000000..2c1d8f1c90
--- /dev/null
+++ b/meta/classes/copyleft_filter.bbclass
@@ -0,0 +1,62 @@
1# Filter the license, the copyleft_should_include returns True for the
2# COPYLEFT_LICENSE_INCLUDE recipe, and False for the
3# COPYLEFT_LICENSE_EXCLUDE.
4#
5# By default, includes all GPL and LGPL, and excludes CLOSED and Proprietary.
6#
7# vi:sts=4:sw=4:et
8
9COPYLEFT_LICENSE_INCLUDE ?= 'GPL* LGPL*'
10COPYLEFT_LICENSE_INCLUDE[type] = 'list'
11COPYLEFT_LICENSE_INCLUDE[doc] = 'Space separated list of globs which include licenses'
12
13COPYLEFT_LICENSE_EXCLUDE ?= 'CLOSED Proprietary'
14COPYLEFT_LICENSE_EXCLUDE[type] = 'list'
15COPYLEFT_LICENSE_EXCLUDE[doc] = 'Space separated list of globs which exclude licenses'
16
17COPYLEFT_RECIPE_TYPE ?= '${@copyleft_recipe_type(d)}'
18COPYLEFT_RECIPE_TYPE[doc] = 'The "type" of the current recipe (e.g. target, native, cross)'
19
20COPYLEFT_RECIPE_TYPES ?= 'target'
21COPYLEFT_RECIPE_TYPES[type] = 'list'
22COPYLEFT_RECIPE_TYPES[doc] = 'Space separated list of recipe types to include'
23
24COPYLEFT_AVAILABLE_RECIPE_TYPES = 'target native nativesdk cross crosssdk cross-canadian'
25COPYLEFT_AVAILABLE_RECIPE_TYPES[type] = 'list'
26COPYLEFT_AVAILABLE_RECIPE_TYPES[doc] = 'Space separated list of available recipe types'
27
28def copyleft_recipe_type(d):
29 for recipe_type in oe.data.typed_value('COPYLEFT_AVAILABLE_RECIPE_TYPES', d):
30 if oe.utils.inherits(d, recipe_type):
31 return recipe_type
32 return 'target'
33
34def copyleft_should_include(d):
35 """
36 Determine if this recipe's sources should be deployed for compliance
37 """
38 import ast
39 import oe.license
40 from fnmatch import fnmatchcase as fnmatch
41
42 recipe_type = d.getVar('COPYLEFT_RECIPE_TYPE', True)
43 if recipe_type not in oe.data.typed_value('COPYLEFT_RECIPE_TYPES', d):
44 return False, 'recipe type "%s" is excluded' % recipe_type
45
46 include = oe.data.typed_value('COPYLEFT_LICENSE_INCLUDE', d)
47 exclude = oe.data.typed_value('COPYLEFT_LICENSE_EXCLUDE', d)
48
49 try:
50 is_included, reason = oe.license.is_included(d.getVar('LICENSE', True), include, exclude)
51 except oe.license.LicenseError as exc:
52 bb.fatal('%s: %s' % (d.getVar('PF', True), exc))
53 else:
54 if is_included:
55 if reason:
56 return True, 'recipe has included licenses: %s' % ', '.join(reason)
57 else:
58 return False, 'recipe does not include a copyleft license'
59 else:
60 return False, 'recipe has excluded licenses: %s' % ', '.join(reason)
61
62