summaryrefslogtreecommitdiffstats
path: root/meta/classes/license.bbclass
diff options
context:
space:
mode:
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 """