summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/base.bbclass13
-rw-r--r--meta/lib/oe/license.py18
2 files changed, 31 insertions, 0 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index f2e3d4092e..79edfe5451 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -543,6 +543,19 @@ python () {
543 if pn in incompatwl: 543 if pn in incompatwl:
544 bb.note("INCLUDING " + pn + " as buildable despite INCOMPATIBLE_LICENSE because it has been whitelisted") 544 bb.note("INCLUDING " + pn + " as buildable despite INCOMPATIBLE_LICENSE because it has been whitelisted")
545 545
546 # Try to verify per-package (LICENSE_<pkg>) values. LICENSE should be a
547 # superset of all per-package licenses. We do not do advanced (pattern)
548 # matching of license expressions - just check that all license strings
549 # in LICENSE_<pkg> are found in LICENSE.
550 license_set = oe.license.list_licenses(license)
551 for pkg in d.getVar('PACKAGES', True).split():
552 pkg_license = d.getVar('LICENSE_' + pkg, True)
553 if pkg_license:
554 unlisted = oe.license.list_licenses(pkg_license) - license_set
555 if unlisted:
556 bb.warn("LICENSE_%s includes licenses (%s) that are not "
557 "listed in LICENSE" % (pkg, ' '.join(unlisted)))
558
546 needsrcrev = False 559 needsrcrev = False
547 srcuri = d.getVar('SRC_URI', True) 560 srcuri = d.getVar('SRC_URI', True)
548 for uri in srcuri.split(): 561 for uri in srcuri.split():
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index 39ef9654fc..8d2fd1709c 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -215,3 +215,21 @@ def manifest_licenses(licensestr, dont_want_licenses, canonical_license, d):
215 manifest.licensestr = manifest.licensestr.replace('[', '(').replace(']', ')') 215 manifest.licensestr = manifest.licensestr.replace('[', '(').replace(']', ')')
216 216
217 return (manifest.licensestr, manifest.licenses) 217 return (manifest.licensestr, manifest.licenses)
218
219class ListVisitor(LicenseVisitor):
220 """Record all different licenses found in the license string"""
221 def __init__(self):
222 self.licenses = set()
223
224 def visit_Str(self, node):
225 self.licenses.add(node.s)
226
227def list_licenses(licensestr):
228 """Simply get a list of all licenses mentioned in a license string.
229 Binary operators are not applied or taken into account in any way"""
230 visitor = ListVisitor()
231 try:
232 visitor.visit_string(licensestr)
233 except SyntaxError as exc:
234 raise LicenseSyntaxError(licensestr, exc)
235 return visitor.licenses