diff options
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/base.bbclass | 3 | ||||
-rw-r--r-- | meta/classes/license.bbclass | 45 |
2 files changed, 46 insertions, 2 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index e65a7220f5..f0c358ea32 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass | |||
@@ -398,9 +398,8 @@ python () { | |||
398 | dont_want_whitelist = (d.getVar('WHITELIST_%s' % dont_want_license, 1) or "").split() | 398 | dont_want_whitelist = (d.getVar('WHITELIST_%s' % dont_want_license, 1) or "").split() |
399 | if pn not in hosttools_whitelist and pn not in lgplv2_whitelist and pn not in dont_want_whitelist: | 399 | if pn not in hosttools_whitelist and pn not in lgplv2_whitelist and pn not in dont_want_whitelist: |
400 | 400 | ||
401 | import re | ||
402 | this_license = d.getVar('LICENSE', 1) | 401 | this_license = d.getVar('LICENSE', 1) |
403 | if this_license and re.search(dont_want_license, this_license): | 402 | if incompatible_license(d,dont_want_license): |
404 | bb.note("SKIPPING %s because it's %s" % (pn, this_license)) | 403 | bb.note("SKIPPING %s because it's %s" % (pn, this_license)) |
405 | raise bb.parse.SkipPackage("incompatible with license %s" % this_license) | 404 | raise bb.parse.SkipPackage("incompatible with license %s" % this_license) |
406 | 405 | ||
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 | ||
240 | def 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 | |||
240 | SSTATETASKS += "do_populate_lic" | 285 | SSTATETASKS += "do_populate_lic" |
241 | do_populate_lic[sstate-name] = "populate-lic" | 286 | do_populate_lic[sstate-name] = "populate-lic" |
242 | do_populate_lic[sstate-inputdirs] = "${LICSSTATEDIR}" | 287 | do_populate_lic[sstate-inputdirs] = "${LICSSTATEDIR}" |