summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaul Wold <Saul.Wold@windriver.com>2022-02-21 15:39:03 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-21 23:44:24 +0000
commitcc07ffe8f7734008cb56a73549fce2ef1d4aa033 (patch)
treea46e3f61ea77d293790083779767de326865cb95
parent0b78f36432680b833d3f028645b9d9387587f477 (diff)
downloadpoky-cc07ffe8f7734008cb56a73549fce2ef1d4aa033.tar.gz
meta: Further LICENSE_FLAGS variable updates
Add further tweaks to comments and variable names for license variable change. (From OE-Core rev: 4125d86f1d3adc53230c02bce4bab46b8c21116f) Signed-off-by: Saul Wold <saul.wold@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/base.bbclass4
-rw-r--r--meta/classes/license.bbclass35
2 files changed, 20 insertions, 19 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index be820ddb2c..227f1f5a75 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -542,9 +542,9 @@ python () {
542 unmatched_license_flags = check_license_flags(d) 542 unmatched_license_flags = check_license_flags(d)
543 if unmatched_license_flags: 543 if unmatched_license_flags:
544 if len(unmatched_license_flags) == 1: 544 if len(unmatched_license_flags) == 1:
545 message = "because it has a restricted license '{0}'. Which is not whitelisted in LICENSE_FLAGS_ACCEPTED".format(unmatched_license_flags[0]) 545 message = "because it has a restricted license '{0}'. Which is not listed in LICENSE_FLAGS_ACCEPTED".format(unmatched_license_flags[0])
546 else: 546 else:
547 message = "because it has restricted licenses {0}. Which are not whitelisted in LICENSE_FLAGS_ACCEPTED".format( 547 message = "because it has restricted licenses {0}. Which are not listed in LICENSE_FLAGS_ACCEPTED".format(
548 ", ".join("'{0}'".format(f) for f in unmatched_license_flags)) 548 ", ".join("'{0}'".format(f) for f in unmatched_license_flags))
549 bb.debug(1, "Skipping %s %s" % (pn, message)) 549 bb.debug(1, "Skipping %s %s" % (pn, message))
550 raise bb.parse.SkipRecipe(message) 550 raise bb.parse.SkipRecipe(message)
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index dd1e07ee37..dec9867209 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -341,30 +341,31 @@ def incompatible_license(d, dont_want_licenses, package=None):
341def check_license_flags(d): 341def check_license_flags(d):
342 """ 342 """
343 This function checks if a recipe has any LICENSE_FLAGS that 343 This function checks if a recipe has any LICENSE_FLAGS that
344 aren't whitelisted. 344 aren't acceptable.
345 345
346 If it does, it returns the all LICENSE_FLAGS missing from the whitelist, or 346 If it does, it returns the all LICENSE_FLAGS missing from the list
347 all of the LICENSE_FLAGS if there is no whitelist. 347 of acceptable license flags, or all of the LICENSE_FLAGS if there
348 is no list of acceptable flags.
348 349
349 If everything is is properly whitelisted, it returns None. 350 If everything is is acceptable, it returns None.
350 """ 351 """
351 352
352 def license_flag_matches(flag, whitelist, pn): 353 def license_flag_matches(flag, acceptlist, pn):
353 """ 354 """
354 Return True if flag matches something in whitelist, None if not. 355 Return True if flag matches something in acceptlist, None if not.
355 356
356 Before we test a flag against the whitelist, we append _${PN} 357 Before we test a flag against the acceptlist, we append _${PN}
357 to it. We then try to match that string against the 358 to it. We then try to match that string against the
358 whitelist. This covers the normal case, where we expect 359 acceptlist. This covers the normal case, where we expect
359 LICENSE_FLAGS to be a simple string like 'commercial', which 360 LICENSE_FLAGS to be a simple string like 'commercial', which
360 the user typically matches exactly in the whitelist by 361 the user typically matches exactly in the acceptlist by
361 explicitly appending the package name e.g 'commercial_foo'. 362 explicitly appending the package name e.g 'commercial_foo'.
362 If we fail the match however, we then split the flag across 363 If we fail the match however, we then split the flag across
363 '_' and append each fragment and test until we either match or 364 '_' and append each fragment and test until we either match or
364 run out of fragments. 365 run out of fragments.
365 """ 366 """
366 flag_pn = ("%s_%s" % (flag, pn)) 367 flag_pn = ("%s_%s" % (flag, pn))
367 for candidate in whitelist: 368 for candidate in acceptlist:
368 if flag_pn == candidate: 369 if flag_pn == candidate:
369 return True 370 return True
370 371
@@ -375,27 +376,27 @@ def check_license_flags(d):
375 if flag_cur: 376 if flag_cur:
376 flag_cur += "_" 377 flag_cur += "_"
377 flag_cur += flagment 378 flag_cur += flagment
378 for candidate in whitelist: 379 for candidate in acceptlist:
379 if flag_cur == candidate: 380 if flag_cur == candidate:
380 return True 381 return True
381 return False 382 return False
382 383
383 def all_license_flags_match(license_flags, whitelist): 384 def all_license_flags_match(license_flags, acceptlist):
384 """ Return all unmatched flags, None if all flags match """ 385 """ Return all unmatched flags, None if all flags match """
385 pn = d.getVar('PN') 386 pn = d.getVar('PN')
386 split_whitelist = whitelist.split() 387 split_acceptlist = acceptlist.split()
387 flags = [] 388 flags = []
388 for flag in license_flags.split(): 389 for flag in license_flags.split():
389 if not license_flag_matches(flag, split_whitelist, pn): 390 if not license_flag_matches(flag, split_acceptlist, pn):
390 flags.append(flag) 391 flags.append(flag)
391 return flags if flags else None 392 return flags if flags else None
392 393
393 license_flags = d.getVar('LICENSE_FLAGS') 394 license_flags = d.getVar('LICENSE_FLAGS')
394 if license_flags: 395 if license_flags:
395 whitelist = d.getVar('LICENSE_FLAGS_ACCEPTED') 396 acceptlist = d.getVar('LICENSE_FLAGS_ACCEPTED')
396 if not whitelist: 397 if not acceptlist:
397 return license_flags.split() 398 return license_flags.split()
398 unmatched_flags = all_license_flags_match(license_flags, whitelist) 399 unmatched_flags = all_license_flags_match(license_flags, acceptlist)
399 if unmatched_flags: 400 if unmatched_flags:
400 return unmatched_flags 401 return unmatched_flags
401 return None 402 return None