Comments
Patch
@@ -349,6 +349,13 @@ python () {
if license == "INVALID":
bb.fatal('This recipe does not have the LICENSE field set (%s)' % pn)
+ unmatched_license_flag = check_license_flags(d)
+ if unmatched_license_flag:
+ bb.debug(1, "Skipping %s because it has a restricted license (%s) not"
+ " whitelisted in LICENSE_FLAGS_WHITELIST" % (pn, unmatched_license_flag))
+ raise bb.parse.SkipPackage("because it has a restricted license (%s) not"
+ " whitelisted in LICENSE_FLAGS_WHITELIST" % unmatched_license_flag)
+
commercial_license = " %s " % d.getVar('COMMERCIAL_LICENSE', 1)
import re
pnr = "[ \t]%s[ \t]" % pn.replace('+', "\+")
@@ -282,6 +282,36 @@ def incompatible_license(d,dont_want_license):
return True
return False
+
+def check_license_flags(d):
+ """
+ This function checks if a recipe has any LICENSE_FLAGs that aren't whitelisted.
+
+ If it does, it returns the first LICENSE_FLAG missing from the whitelist, or all the
+ the LICENSE_FLAGs if there is no whitelist.
+
+ If everything is is properly whitelisted, it returns None.
+ """
+
+ def all_license_flags_match(flags, whitelist):
+ """ Return first unmatched flag, None if all flags match """
+
+ for flag in flags.split():
+ if not flag in whitelist.split():
+ return flag
+ return None
+
+ license_flags = d.getVar('LICENSE_FLAGS', True)
+ if license_flags:
+ license_flags_whitelist = d.getVar('LICENSE_FLAGS_WHITELIST', True)
+ if not license_flags_whitelist:
+ return license_flags
+ unmatched_flag = all_license_flags_match(license_flags, license_flags_whitelist)
+ if unmatched_flag:
+ return unmatched_flag
+ return None
+
+
SSTATETASKS += "do_populate_lic"
do_populate_lic[sstate-name] = "populate-lic"
do_populate_lic[sstate-inputdirs] = "${LICSSTATEDIR}"