Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] sanity: check variable GO_IMPORT
       [not found] <20250225180939.21341-1-gavrosc.ref@yahoo.com>
@ 2025-02-25 18:09 ` Christos Gavros
  2025-02-25 20:33   ` Randy MacLeod
  0 siblings, 1 reply; 7+ messages in thread
From: Christos Gavros @ 2025-02-25 18:09 UTC (permalink / raw)
  To: openembedded-core
  Cc: Christos Gavros, Yoann Congal, Randy MacLeod, Alexander Kanavin

Check if the variable GO_IMPORT is
assigned with a value. If not generate an error.
Fixes [YOCTO #15763]

CC: Yoann Congal <yoann.congal@smile.fr>
CC: Randy MacLeod <randy.macleod@windriver.com>
CC: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Christos Gavros <gavrosc@yahoo.com>
---
 meta/classes-global/sanity.bbclass | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass
index 1bae998f74..01e48b4347 100644
--- a/meta/classes-global/sanity.bbclass
+++ b/meta/classes-global/sanity.bbclass
@@ -1010,6 +1010,10 @@ def check_sanity_everybuild(status, d):
         if '/dash' not in real_sh and '/bash' not in real_sh:
             status.addresult("Error, /bin/sh links to %s, must be dash or bash\n" % real_sh)
 
+    # Check if a value is assigned to GO_IMPORT variable
+    if not d.getVar('GO_IMPORT'):
+        status.addresult("GO_IMPORT variable is not assigned with a value")
+
 def check_sanity(sanity_data):
     class SanityStatus(object):
         def __init__(self):
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] sanity: check variable GO_IMPORT
  2025-02-25 18:09 ` [PATCH] sanity: check variable GO_IMPORT Christos Gavros
@ 2025-02-25 20:33   ` Randy MacLeod
  2025-02-25 20:37     ` Christos Gavros
  2025-02-25 22:43     ` [OE-core] " Richard Purdie
  0 siblings, 2 replies; 7+ messages in thread
From: Randy MacLeod @ 2025-02-25 20:33 UTC (permalink / raw)
  To: Christos Gavros, openembedded-core; +Cc: Yoann Congal, Alexander Kanavin

[-- Attachment #1: Type: text/plain, Size: 2044 bytes --]

On 2025-02-25 1:09 p.m., Christos Gavros wrote:
> Check if the variable GO_IMPORT is
> assigned with a value. If not generate an error.
> Fixes [YOCTO #15763]
>
> CC: Yoann Congal<yoann.congal@smile.fr>
> CC: Randy MacLeod<randy.macleod@windriver.com>
> CC: Alexander Kanavin<alex.kanavin@gmail.com>
> Signed-off-by: Christos Gavros<gavrosc@yahoo.com>
> ---
>   meta/classes-global/sanity.bbclass | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass
> index 1bae998f74..01e48b4347 100644
> --- a/meta/classes-global/sanity.bbclass
> +++ b/meta/classes-global/sanity.bbclass
> @@ -1010,6 +1010,10 @@ def check_sanity_everybuild(status, d):
>           if '/dash' not in real_sh and '/bash' not in real_sh:
>               status.addresult("Error, /bin/sh links to %s, must be dash or bash\n" % real_sh)
>   
> +    # Check if a value is assigned to GO_IMPORT variable
> +    if not d.getVar('GO_IMPORT'):
> +        status.addresult("GO_IMPORT variable is not assigned with a value")
> +
>   def check_sanity(sanity_data):
>       class SanityStatus(object):
>           def __init__(self):

Thanks Christos,

I know I suggested that you try sending this to see what people say and 
to get some guidance but
this break all the builds so clearly we can't merge it. I did expect you 
to do a build though... ;-)

❯ bitbake busybox
...
ERROR:  OE-core's config sanity checker detected a potential 
misconfiguration.
     Either fix the cause of this error or at your own risk disable the 
checker (see sanity.conf).
     Following is the list of potential problems / advisories:

     GO_IMPORT variable is not assigned with a value

We need a sanity check at the recipe level for go-based recipes only.
I'm not sure how to do that.

I may do a bit of digging and reply to my own email with a suggestion of 
a better approach
unless someone beats me to it!


-- 
# Randy MacLeod
# Wind River Linux

[-- Attachment #2: Type: text/html, Size: 2995 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] sanity: check variable GO_IMPORT
  2025-02-25 20:33   ` Randy MacLeod
@ 2025-02-25 20:37     ` Christos Gavros
  2025-02-25 22:43     ` [OE-core] " Richard Purdie
  1 sibling, 0 replies; 7+ messages in thread
From: Christos Gavros @ 2025-02-25 20:37 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 160 bytes --]

hi Randy

I did a build and I wrote a comment in the bug15763 that is generating an error!
I always built and test as much as I can before sending patches.

[-- Attachment #2: Type: text/html, Size: 210 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [OE-core] [PATCH] sanity: check variable GO_IMPORT
  2025-02-25 20:33   ` Randy MacLeod
  2025-02-25 20:37     ` Christos Gavros
@ 2025-02-25 22:43     ` Richard Purdie
  2025-02-26 10:00       ` Christos Gavros
  1 sibling, 1 reply; 7+ messages in thread
From: Richard Purdie @ 2025-02-25 22:43 UTC (permalink / raw)
  To: randy.macleod, Christos Gavros, openembedded-core
  Cc: Yoann Congal, Alexander Kanavin

On Tue, 2025-02-25 at 15:33 -0500, Randy MacLeod via lists.openembedded.org wrote:
>  On 2025-02-25 1:09 p.m., Christos Gavros wrote:
>  Check if the variable GO_IMPORT is
> > assigned with a value. If not generate an error.
> > Fixes [YOCTO #15763]
> > 
> > CC: Yoann Congal <yoann.congal@smile.fr>
> > CC: Randy MacLeod <randy.macleod@windriver.com>
> > CC: Alexander Kanavin <alex.kanavin@gmail.com>
> > Signed-off-by: Christos Gavros <gavrosc@yahoo.com>
> > ---
> >  meta/classes-global/sanity.bbclass | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/meta/classes-global/sanity.bbclass b/meta/classes-global/sanity.bbclass
> > index 1bae998f74..01e48b4347 100644
> > --- a/meta/classes-global/sanity.bbclass
> > +++ b/meta/classes-global/sanity.bbclass
> > @@ -1010,6 +1010,10 @@ def check_sanity_everybuild(status, d):
> >          if '/dash' not in real_sh and '/bash' not in real_sh:
> >              status.addresult("Error, /bin/sh links to %s, must be dash or bash\n" % real_sh)
> >  
> > +    # Check if a value is assigned to GO_IMPORT variable
> > +    if not d.getVar('GO_IMPORT'):
> > +        status.addresult("GO_IMPORT variable is not assigned with a value")
> > +
> >  def check_sanity(sanity_data):
> >      class SanityStatus(object):
> >          def __init__(self):
> >  
>  
> Thanks Christos,
>  
> I know I suggested that you try sending this to see what people say and to get some guidance but
>  this break all the builds so clearly we can't merge it. I did expect you to do a build though... ;-)
>   
> ❯ bitbake busybox
>  ...
>  ERROR:  OE-core's config sanity checker detected a potential misconfiguration.
>      Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
>      Following is the list of potential problems / advisories:
>  
>      GO_IMPORT variable is not assigned with a value
>  
> We need a sanity check at the recipe level for go-based recipes only.
>  I'm not sure how to do that.
>  
> I may do a bit of digging and reply to my own email with a suggestion of a better approach unless someone beats me to it!

The code is close, the location is wrong as "sanity test" is misleading
you.

The place this is used is in go.bbclass so I'd suggest we need a check
in that class alongside where it is used. It could be as simple as the
code above but in the form:

python () {
    # Check if a value is assigned to GO_IMPORT variable
    if not d.getVar('GO_IMPORT'):
        bb.fatal("GO_IMPORT variable needs to be set to use the go bbclass but has no value")
}

Cheers,

Richard




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] sanity: check variable GO_IMPORT
  2025-02-25 22:43     ` [OE-core] " Richard Purdie
@ 2025-02-26 10:00       ` Christos Gavros
  2025-02-27 13:15         ` Christos Gavros
  0 siblings, 1 reply; 7+ messages in thread
From: Christos Gavros @ 2025-02-26 10:00 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 65 bytes --]

hi

I will make the changes, test it and submit v2 next days!

[-- Attachment #2: Type: text/html, Size: 104 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] sanity: check variable GO_IMPORT
  2025-02-26 10:00       ` Christos Gavros
@ 2025-02-27 13:15         ` Christos Gavros
  2025-02-27 13:20           ` [OE-core] " Richard Purdie
  0 siblings, 1 reply; 7+ messages in thread
From: Christos Gavros @ 2025-02-27 13:15 UTC (permalink / raw)
  To: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 1323 bytes --]

hi Richard

I have added the code as you suggested in go.bbclass and then i created meta-mylayer and try to build there " go-helloworld_0.1.bb". It builds fine.

When i commented GO_IMPORT in the recipe the error i am getting is:

ERROR: ExpansionError during parsing /home/cg/CG/Programming/Yocto/poky/meta-mylayer/recipes-go/go-helloworld/go-helloworld.bb             | ETA:  --:--:--
bb.data_smart.ExpansionError: Failure expanding variable GO_SRCURI_DESTSUFFIX, expression was ${@os.path.join(os.path.basename(d.getVar('S')), 'src', d.getVar('GO_IMPORT')) + '/'} which triggered exception TypeError: join() argument must be str, bytes, or os.PathLike object, not 'NoneType'
The variable dependency chain for the failure is: GO_SRCURI_DESTSUFFIX -> SRC_URI

This is caused from this line in the recipe: SRC_URI = " git://go.googlesource.com/example;branch=master;protocol=https;destsuffix=${GO_SRCURI_DESTSUFFIX} ( git://go.googlesource.com/example;branch=master;protocol=https;destsuffix=$%7BGO_SRCURI_DESTSUFFIX%7D ) "

So it looks that expanding GO_SRCURI_DESTSUFFIX variable is executed before anonymous python function and the error "GO_IMPORT is not set" will not be generated.

If you don't have anything to comment , I will try to dive deeper and see how I can adapt it...

Br
Christos

[-- Attachment #2: Type: text/html, Size: 11061 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [OE-core] [PATCH] sanity: check variable GO_IMPORT
  2025-02-27 13:15         ` Christos Gavros
@ 2025-02-27 13:20           ` Richard Purdie
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Purdie @ 2025-02-27 13:20 UTC (permalink / raw)
  To: gavrosc, openembedded-core

On Thu, 2025-02-27 at 05:15 -0800, Christos Gavros via lists.openembedded.org wrote:
> hi Richard
>  
> I have added the code as you suggested in go.bbclass and then i created meta-mylayer and try to build there "go-helloworld_0.1.bb". It builds fine.
> 
>  
> When i commented GO_IMPORT in the recipe the error i am getting is:
>  
> 
> 
> 
> 
> ERROR: ExpansionError during parsing /home/cg/CG/Programming/Yocto/poky/meta-mylayer/recipes-go/go-helloworld/go-helloworld.bb             | ETA:  --:--:--
> bb.data_smart.ExpansionError: Failure expanding variable GO_SRCURI_DESTSUFFIX, expression was ${@os.path.join(os.path.basename(d.getVar('S')), 'src', d.getVar('GO_IMPORT')) + '/'} which triggered exception TypeError: join() argument must be str, bytes, or os.PathLike object, not 'NoneType'
> The variable dependency chain for the failure is: GO_SRCURI_DESTSUFFIX -> SRC_URI
>  
> 
> 
> This is caused from this line in the recipe: SRC_URI = "git://go.googlesource.com/example;branch=master;protocol=https;destsuffix=${GO_SRCURI_DESTSUFFIX}"
>  
> So it looks that expanding GO_SRCURI_DESTSUFFIX variable is executed before anonymous python function and the error "GO_IMPORT is not set" will not be generated.
>  
> If you don't have anything to comment , I will try to dive deeper and see how I can adapt it...
> 

That is unfortunate. As you say, it is expanding it earlier than the
anonymous python.

One slightly evil idea that comes to mind might be:

GO_IMPORT ??= "${@bb.fatal("The recipe needs to set GO_IMPORT for go.bbclass to work")}"

Not sure if that would work or not! It may still give a traceback
although I'm hoping it doesn't.


Cheers,

Richard




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-02-27 13:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250225180939.21341-1-gavrosc.ref@yahoo.com>
2025-02-25 18:09 ` [PATCH] sanity: check variable GO_IMPORT Christos Gavros
2025-02-25 20:33   ` Randy MacLeod
2025-02-25 20:37     ` Christos Gavros
2025-02-25 22:43     ` [OE-core] " Richard Purdie
2025-02-26 10:00       ` Christos Gavros
2025-02-27 13:15         ` Christos Gavros
2025-02-27 13:20           ` [OE-core] " Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox