summaryrefslogtreecommitdiffstats
path: root/meta/classes/license.bbclass
diff options
context:
space:
mode:
authorAndrei Gherzan <andrei.gherzan@windriver.com>2012-01-10 17:17:58 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-01-10 17:40:44 +0000
commit4005c3ff5e673f9d561026c76326054bd0a3a2b6 (patch)
tree8876f26e016fa2be1284450e795259c096a2a2d2 /meta/classes/license.bbclass
parenta5463088fe57462bf681b648d21212808454fc2a (diff)
downloadpoky-4005c3ff5e673f9d561026c76326054bd0a3a2b6.tar.gz
license.bbclass base.bbclass: support for 'or' operand in LICENSE and for SPDX license names
A new function was defined in license.bbclass in order to correctly exclude packages where OE-Style licence naming is used. In this way licenses as GPL-3, GPLv3, GPLv3.0 etc will be excluded from a non-GPLv3 build. This function takes into consideration if 'or' operand is used. The function defined in license.bbclass is called in base.bbclass where packages are excluded based on INCOMPATIBLE_LICENSE variable. [YOCTO #1884] [YOCTO #1844] (From OE-Core rev: 28456593be0b7e15bb51595d547d7e5347cce24b) Signed-off-by: Andrei Gherzan <andrei at gherzan.ro> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/license.bbclass')
-rw-r--r--meta/classes/license.bbclass45
1 files changed, 45 insertions, 0 deletions
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index d351b5aaed..4b98e29916 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -237,6 +237,51 @@ python do_populate_lic() {
237 237
238} 238}
239 239
240def incompatible_license(d,dont_want_license):
241 """
242 This function checks if a package has only incompatible licenses. It also take into consideration 'or'
243 operand.
244 """
245 import re
246 import oe.license
247 from fnmatch import fnmatchcase as fnmatch
248
249 dont_want_licenses = []
250 dont_want_licenses.append(d.getVar('INCOMPATIBLE_LICENSE', 1))
251 if d.getVarFlag('SPDXLICENSEMAP', dont_want_license):
252 dont_want_licenses.append(d.getVarFlag('SPDXLICENSEMAP', dont_want_license))
253
254 def include_license(license):
255 if any(fnmatch(license, pattern) for pattern in dont_want_licenses):
256 return False
257 else:
258 spdx_license = d.getVarFlag('SPDXLICENSEMAP', license)
259 if spdx_license and any(fnmatch(spdx_license, pattern) for pattern in dont_want_licenses):
260 return False
261 else:
262 return True
263
264 def choose_licenses(a, b):
265 if all(include_license(lic) for lic in a):
266 return a
267 else:
268 return b
269
270 """
271 If you want to exlude license named generically 'X', we surely want to exlude 'X+' as well.
272 In consequence, we will exclude the '+' character from LICENSE in case INCOMPATIBLE_LICENSE
273 is not a 'X+' license.
274 """
275 if not re.search(r'[+]',dont_want_license):
276 licenses=oe.license.flattened_licenses(re.sub(r'[+]', '', d.getVar('LICENSE', True)), choose_licenses)
277 else:
278 licenses=oe.license.flattened_licenses(d.getVar('LICENSE', True), choose_licenses)
279
280 for onelicense in licenses:
281 if not include_license(onelicense):
282 return True
283 return False
284
240SSTATETASKS += "do_populate_lic" 285SSTATETASKS += "do_populate_lic"
241do_populate_lic[sstate-name] = "populate-lic" 286do_populate_lic[sstate-name] = "populate-lic"
242do_populate_lic[sstate-inputdirs] = "${LICSSTATEDIR}" 287do_populate_lic[sstate-inputdirs] = "${LICSSTATEDIR}"