public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 2/2] license: Validate if LICENSE is well defined.
Date: Mon, 22 Dec 2014 17:30:46 -0600	[thread overview]
Message-ID: <603319d77c3d720e430df8f42fdc01d544cab29b.1419290780.git.anibal.limon@linux.intel.com> (raw)
In-Reply-To: <cover.1419290780.git.anibal.limon@linux.intel.com>
In-Reply-To: <cover.1419290780.git.anibal.limon@linux.intel.com>

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>
---
 meta/classes/base.bbclass    |  1 +
 meta/classes/license.bbclass | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 06cfe26..b8f61f3 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -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"
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index c55ee77..f85d4f9 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -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}/"
-- 
1.9.1



      parent reply	other threads:[~2014-12-22 23:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-22 23:30 [PATCH 0/2] License class fixes Aníbal Limón
2014-12-22 23:30 ` [PATCH 1/2] license_class: fix license.manifest shows LICENSE field differently to recipe Aníbal Limón
2014-12-22 23:30 ` Aníbal Limón [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=603319d77c3d720e430df8f42fdc01d544cab29b.1419290780.git.anibal.limon@linux.intel.com \
    --to=anibal.limon@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox