Patchwork [3/3] sanity.bbclass: Check for bogus values in BBCLASSEXTEND

login
register
mail settings
Submitter Peter Seebach
Date May 2, 2012, 1:45 a.m.
Message ID <24944576961308660582b4a62b2c609fcef0bcea.1335922726.git.peter.seebach@windriver.com>
Download mbox | patch
Permalink /patch/26795/
State New
Headers show

Comments

Peter Seebach - May 2, 2012, 1:45 a.m.
Suggestion that came out of my sanity-checks of multilibs; verify
that stuff in BBCLASSEXTEND is valid.

Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
---
 meta/classes/sanity.bbclass |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
Richard Purdie - May 9, 2012, 8:59 p.m.
On Tue, 2012-05-01 at 20:45 -0500, Peter Seebach wrote:
> Suggestion that came out of my sanity-checks of multilibs; verify
> that stuff in BBCLASSEXTEND is valid.
> 
> Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
> ---
>  meta/classes/sanity.bbclass |   13 +++++++++++++
>  1 files changed, 13 insertions(+), 0 deletions(-)
> 
> diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
> index 635049e..9f3f1d5 100644
> --- a/meta/classes/sanity.bbclass
> +++ b/meta/classes/sanity.bbclass
> @@ -81,6 +81,15 @@ def check_toolchain(data):
>  
>      return ""
>  
> +def check_bbclassextend(data):
> +    allowed = ('native', 'nativesdk', 'multilib', 'cross')
> +    extends = (data.getVar("BBCLASSEXTEND", True) or "").split()
> +    errors = []
> +    for pair in [x.split(':') for x in extends]:
> +        if pair[0] not in allowed:
> +            errors.append('BBCLASSEXTEND has invalid value: %s' % pair[0])
> +    return '\n'.join(errors)
> +
>  def check_conf_exists(fn, data):
>      bbpath = []
>      fn = data.expand(fn)
> @@ -401,6 +410,10 @@ def check_sanity(e):
>      if toolchain_msg != "":
>          messages = messages + toolchain_msg + '\n'
>  
> +    bbclassextend_msg = check_bbclassextend(e.data)
> +    if bbclassextend_msg != "":
> +        messages = messages + bbclassextend_msg + '\n'
> +
>      # Check if DISPLAY is set if IMAGETEST is set
>      if not data.getVar( 'DISPLAY', e.data, True ) and data.getVar( 'IMAGETEST', e.data, True ) == 'qemu':
>          messages = messages + 'qemuimagetest needs a X desktop to start qemu, please set DISPLAY correctly (e.g. DISPLAY=:1.0)\n'

FWIW, this isn't going to work. Its checking the sanity in
"configuration" space, pre recipe parse so it won't pick up on the
errors we want it to.

So whilst its well intentioned, it isn't going to work as designed and
we'll have to rethink it. I can't think of a good way to fix it right
now, we don't really have a structure for recipe checks at this point.

Cheers,

Richard
Peter Seebach - May 9, 2012, 9:09 p.m.
On Wed, 9 May 2012 21:59:49 +0100
Richard Purdie <richard.purdie@linuxfoundation.org> wrote:

> FWIW, this isn't going to work. Its checking the sanity in
> "configuration" space, pre recipe parse so it won't pick up on the
> errors we want it to.
> 
> So whilst its well intentioned, it isn't going to work as designed and
> we'll have to rethink it. I can't think of a good way to fix it right
> now, we don't really have a structure for recipe checks at this point.

Oh, that has to be per-recipe?  I thought BBCLASSEXTEND was top-level.

Adding recipe checks of some sort seems useful, but that is a bigger
project, so I guess we can drop that.  Note that this was in sgw's
consolidated pull request, too.

-s

Patch

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index 635049e..9f3f1d5 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -81,6 +81,15 @@  def check_toolchain(data):
 
     return ""
 
+def check_bbclassextend(data):
+    allowed = ('native', 'nativesdk', 'multilib', 'cross')
+    extends = (data.getVar("BBCLASSEXTEND", True) or "").split()
+    errors = []
+    for pair in [x.split(':') for x in extends]:
+        if pair[0] not in allowed:
+            errors.append('BBCLASSEXTEND has invalid value: %s' % pair[0])
+    return '\n'.join(errors)
+
 def check_conf_exists(fn, data):
     bbpath = []
     fn = data.expand(fn)
@@ -401,6 +410,10 @@  def check_sanity(e):
     if toolchain_msg != "":
         messages = messages + toolchain_msg + '\n'
 
+    bbclassextend_msg = check_bbclassextend(e.data)
+    if bbclassextend_msg != "":
+        messages = messages + bbclassextend_msg + '\n'
+
     # Check if DISPLAY is set if IMAGETEST is set
     if not data.getVar( 'DISPLAY', e.data, True ) and data.getVar( 'IMAGETEST', e.data, True ) == 'qemu':
         messages = messages + 'qemuimagetest needs a X desktop to start qemu, please set DISPLAY correctly (e.g. DISPLAY=:1.0)\n'