summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/copyleft_compliance.bbclass4
-rw-r--r--meta/lib/oe/license.py23
2 files changed, 20 insertions, 7 deletions
diff --git a/meta/classes/copyleft_compliance.bbclass b/meta/classes/copyleft_compliance.bbclass
index 6f058e0f20..2eb9dedd24 100644
--- a/meta/classes/copyleft_compliance.bbclass
+++ b/meta/classes/copyleft_compliance.bbclass
@@ -48,10 +48,8 @@ def copyleft_should_include(d):
48 48
49 try: 49 try:
50 is_included, excluded = oe.license.is_included(d.getVar('LICENSE', True), include, exclude) 50 is_included, excluded = oe.license.is_included(d.getVar('LICENSE', True), include, exclude)
51 except oe.license.InvalidLicense as exc: 51 except oe.license.LicenseError as exc:
52 bb.fatal('%s: %s' % (d.getVar('PF', True), exc)) 52 bb.fatal('%s: %s' % (d.getVar('PF', True), exc))
53 except SyntaxError as exc:
54 bb.warn('%s: error when parsing the LICENSE variable: %s' % (d.getVar('P', True), exc))
55 else: 53 else:
56 if is_included: 54 if is_included:
57 return True, None 55 return True, None
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index 3543cfe1f6..5914506a42 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -5,13 +5,25 @@ import ast
5import re 5import re
6from fnmatch import fnmatchcase as fnmatch 6from fnmatch import fnmatchcase as fnmatch
7 7
8class InvalidLicense(StandardError): 8class LicenseError(StandardError):
9 pass
10
11class LicenseSyntaxError(LicenseError):
12 def __init__(self, licensestr, exc):
13 self.licensestr = licensestr
14 self.exc = exc
15 LicenseError.__init__(self)
16
17 def __str__(self):
18 return "error in '%s': %s" % (self.licensestr, self.exc)
19
20class InvalidLicense(LicenseError):
9 def __init__(self, license): 21 def __init__(self, license):
10 self.license = license 22 self.license = license
11 StandardError.__init__(self) 23 LicenseError.__init__(self)
12 24
13 def __str__(self): 25 def __str__(self):
14 return "invalid license '%s'" % self.license 26 return "invalid characters in license '%s'" % self.license
15 27
16license_operator = re.compile('([&|() ])') 28license_operator = re.compile('([&|() ])')
17license_pattern = re.compile('[a-zA-Z0-9.+_\-]+$') 29license_pattern = re.compile('[a-zA-Z0-9.+_\-]+$')
@@ -59,7 +71,10 @@ class FlattenVisitor(LicenseVisitor):
59def flattened_licenses(licensestr, choose_licenses): 71def flattened_licenses(licensestr, choose_licenses):
60 """Given a license string and choose_licenses function, return a flat list of licenses""" 72 """Given a license string and choose_licenses function, return a flat list of licenses"""
61 flatten = FlattenVisitor(choose_licenses) 73 flatten = FlattenVisitor(choose_licenses)
62 flatten.visit_string(licensestr) 74 try:
75 flatten.visit_string(licensestr)
76 except SyntaxError as exc:
77 raise LicenseSyntaxError(licensestr, exc)
63 return flatten.licenses 78 return flatten.licenses
64 79
65def is_included(licensestr, whitelist=None, blacklist=None): 80def is_included(licensestr, whitelist=None, blacklist=None):