]> code.ossystems Code Review - openembedded-core.git/commitdiff
license: Validate if LICENSE is well defined.
authorAníbal Limón <anibal.limon@linux.intel.com>
Mon, 22 Dec 2014 23:30:46 +0000 (17:30 -0600)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 24 Dec 2014 17:48:57 +0000 (17:48 +0000)
Add check_license_format function that shows warning if LICENSE don't have
valid operators and also if have space separated entries without operator,
add check_license_format validation into base class.

[YOCTO #6758]

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/base.bbclass
meta/classes/license.bbclass

index 06cfe260ac31d89636e46a11d0c3dd725aec6399..b8f61f3955d7e94a4cb8dca82c54ca072005d25f 100644 (file)
@@ -390,6 +390,7 @@ python () {
         bb.fatal('This recipe does not have the LICENSE field set (%s)' % pn)
 
     if bb.data.inherits_class('license', d):
+        check_license_format(d)
         unmatched_license_flag = check_license_flags(d)
         if unmatched_license_flag:
             bb.debug(1, "Skipping %s because it has a restricted license not"
index c55ee77ebfb6114dd9fb45f65b94148260eff790..f85d4f9bcf437778326133bcc307bc6cf6f8377b 100644 (file)
@@ -409,6 +409,28 @@ def check_license_flags(d):
             return unmatched_flag
     return None
 
+def check_license_format(d):
+    """
+    This function checks if LICENSE is well defined,
+        Validate operators in LICENSES.
+        No spaces are allowed between LICENSES.
+    """
+    pn = d.getVar('PN', True)
+    licenses = d.getVar('LICENSE', True)
+    from oe.license import license_operator
+    from oe.license import license_pattern
+
+    elements = filter(lambda x: x.strip(), license_operator.split(licenses))
+    for pos, element in enumerate(elements):
+        if license_pattern.match(element):
+            if pos > 0 and license_pattern.match(elements[pos - 1]):
+                bb.warn("Recipe %s, LICENSE (%s) has invalid format, " \
+                        "LICENSES must have operator \"%s\" between them." %
+                        (pn, licenses, license_operator.pattern))
+        elif not license_operator.match(element):
+            bb.warn("Recipe %s, LICENSE (%s) has invalid operator (%s) not in" \
+                  " \"%s\"." % (pn, licenses, element, license_operator.pattern))
+
 SSTATETASKS += "do_populate_lic"
 do_populate_lic[sstate-inputdirs] = "${LICSSTATEDIR}"
 do_populate_lic[sstate-outputdirs] = "${LICENSE_DIRECTORY}/"