summaryrefslogtreecommitdiffstats
path: root/meta/classes/license.bbclass
diff options
context:
space:
mode:
authorAndy Ross <andy.ross@windriver.com>2012-11-29 11:08:47 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-12-11 15:54:36 +0000
commitec17940f7236a47983f2f1dc0208652a0b550c82 (patch)
tree4cba1e1c28cef45eb22cb180bd20c2f566542ad8 /meta/classes/license.bbclass
parent82d6ef6a7a582312e4c655f666ba4b641b005cd5 (diff)
downloadpoky-ec17940f7236a47983f2f1dc0208652a0b550c82.tar.gz
base/license.bbclass: handle multiple INCOMPATIBLE_LICENSEs
Allow INCOMPATIBLE_LICENSE to be a whitespace-separated list of incompatible license strings and/or glob patterns. Also fix wildcarding: the string in INCOMPATIBLE_LICENSE was clearly intended to match with wildcards (e.g. "*GPLv3" to match both GPLv3 and LGPLv3), but this was broken because of a bug in return_spdx() which would die with a runtime error when there was no SPDXLICENSEMAP entry for the string. (From OE-Core rev: 8a8d00f4c9f7fe5f9f173b43b86cd18a6c75435c) Signed-off-by: Andy Ross <andy.ross@windriver.com> Signed-off-by: Elizabeth Flanagan <elizabeth.flanagan@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/license.bbclass')
-rw-r--r--meta/classes/license.bbclass68
1 files changed, 25 insertions, 43 deletions
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index e1878956f8..68f45f52f0 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -203,14 +203,11 @@ python do_populate_lic() {
203 203
204def return_spdx(d, license): 204def return_spdx(d, license):
205 """ 205 """
206 This function returns the spdx mapping of a license. 206 This function returns the spdx mapping of a license if it exists.
207 """ 207 """
208 if d.getVarFlag('SPDXLICENSEMAP', license) != None: 208 return d.getVarFlag('SPDXLICENSEMAP', license, True)
209 return license
210 else:
211 return d.getVarFlag('SPDXLICENSEMAP', license_type)
212 209
213def incompatible_license(d, dont_want_license, package=""): 210def incompatible_license(d, dont_want_licenses, package=None):
214 """ 211 """
215 This function checks if a recipe has only incompatible licenses. It also take into consideration 'or' 212 This function checks if a recipe has only incompatible licenses. It also take into consideration 'or'
216 operand. 213 operand.
@@ -219,45 +216,30 @@ def incompatible_license(d, dont_want_license, package=""):
219 import oe.license 216 import oe.license
220 from fnmatch import fnmatchcase as fnmatch 217 from fnmatch import fnmatchcase as fnmatch
221 pn = d.getVar('PN', True) 218 pn = d.getVar('PN', True)
222 dont_want_licenses = [] 219 license = d.getVar("LICENSE_%s-%s" % (pn, package), True) if package else None
223 dont_want_licenses.append(d.getVar('INCOMPATIBLE_LICENSE', True)) 220 if not license:
224 recipe_license = d.getVar('LICENSE', True) 221 license = d.getVar('LICENSE', True)
225 if package != "": 222
226 if d.getVar('LICENSE_' + pn + '-' + package, True): 223 def license_ok(license):
227 license = d.getVar('LICENSE_' + pn + '-' + package, True) 224 for dwl in dont_want_licenses:
228 else: 225 # If you want to exclude license named generically 'X', we
229 license = recipe_license 226 # surely want to exclude 'X+' as well. In consequence, we
230 else: 227 # will exclude a trailing '+' character from LICENSE in
231 license = recipe_license 228 # case INCOMPATIBLE_LICENSE is not a 'X+' license.
232 spdx_license = return_spdx(d, dont_want_license) 229 lic = license
233 dont_want_licenses.append(spdx_license) 230 if not re.search('\+$', dwl):
234 231 lic = re.sub('\+', '', license)
235 def include_license(license): 232 if fnmatch(lic, dwl):
236 if any(fnmatch(license, pattern) for pattern in dont_want_licenses):
237 return False 233 return False
238 else: 234 return True
239 return True
240 235
241 def choose_licenses(a, b): 236 # Handles an "or" or two license sets provided by
242 if all(include_license(lic) for lic in a): 237 # flattened_licenses(), pick one that works if possible.
243 return a 238 def choose_lic_set(a, b):
244 else: 239 return a if all(license_ok(lic) for lic in a) else b
245 return b
246 240
247 """ 241 licenses=oe.license.flattened_licenses(license, choose_lic_set)
248 If you want to exlude license named generically 'X', we surely want to exlude 'X+' as well. 242 return any(not license_ok(l) for l in licenses)
249 In consequence, we will exclude the '+' character from LICENSE in case INCOMPATIBLE_LICENSE
250 is not a 'X+' license.
251 """
252 if not re.search(r'[+]',dont_want_license):
253 licenses=oe.license.flattened_licenses(re.sub(r'[+]', '', license), choose_licenses)
254 else:
255 licenses=oe.license.flattened_licenses(license, choose_licenses)
256
257 for onelicense in licenses:
258 if not include_license(onelicense):
259 return True
260 return False
261 243
262def check_license_flags(d): 244def check_license_flags(d):
263 """ 245 """