diff mbox series

archiver.bbclass: fix BB_GENERATE_MIRROR_TARBALLS checking

Message ID 20240808110409.4077831-1-ejo@pengutronix.de
State Accepted, archived
Commit f6185d51b84d8d2eb578dbd322c1c61537efabf6
Headers show
Series archiver.bbclass: fix BB_GENERATE_MIRROR_TARBALLS checking | expand

Commit Message

Enrico Jörns Aug. 8, 2024, 11:04 a.m. UTC
The variable 'have_mirror_tarballs' is used as a boolean while it is
actually the result of 'd.getVar('BB_GENERATE_MIRROR_TARBALLS')' and
thus a string.

Fix this by converting it into a boolean before using it.

Signed-off-by: Enrico Jörns <ejo@pengutronix.de>
---
 meta/classes/archiver.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Peter Kjellerstedt Aug. 8, 2024, 12:16 p.m. UTC | #1
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Enrico Jörns
> Sent: den 8 augusti 2024 13:04
> To: openembedded-core@lists.openembedded.org
> Cc: yocto@pengutronix.de
> Subject: [OE-core] [PATCH] archiver.bbclass: fix BB_GENERATE_MIRROR_TARBALLS checking
> 
> The variable 'have_mirror_tarballs' is used as a boolean while it is
> actually the result of 'd.getVar('BB_GENERATE_MIRROR_TARBALLS')' and
> thus a string.
> 
> Fix this by converting it into a boolean before using it.
> 
> Signed-off-by: Enrico Jörns <ejo@pengutronix.de>
> ---
>  meta/classes/archiver.bbclass | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass
> index 9d286224d6..9c8b0daf31 100644
> --- a/meta/classes/archiver.bbclass
> +++ b/meta/classes/archiver.bbclass
> @@ -339,7 +339,7 @@ python do_ar_mirror() {
>      dl_dir = d.getVar('DL_DIR')
>      mirror_exclusions = (d.getVar('ARCHIVER_MIRROR_EXCLUDE') or '').split()
>      mirror_mode = d.getVarFlag('ARCHIVER_MODE', 'mirror')
> -    have_mirror_tarballs = d.getVar('BB_GENERATE_MIRROR_TARBALLS')
> +    have_mirror_tarballs = d.getVar('BB_GENERATE_MIRROR_TARBALLS') == "1"

May I suggest:

    have_mirror_tarballs = oe.types.boolean(d.getVar('BB_GENERATE_MIRROR_TARBALLS'))

instead?

> 
>      if mirror_mode == 'combined':
>          destdir = d.getVar('ARCHIVER_COMBINED_MIRRORDIR')
> --
> 2.39.2

//Peter
Enrico Jörns Aug. 9, 2024, 8:38 a.m. UTC | #2
Am Donnerstag, dem 08.08.2024 um 12:16 +0000 schrieb Peter Kjellerstedt:
> > -----Original Message-----
> > From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On
> > Behalf Of Enrico Jörns
> > Sent: den 8 augusti 2024 13:04
> > To: openembedded-core@lists.openembedded.org
> > Cc: yocto@pengutronix.de
> > Subject: [OE-core] [PATCH] archiver.bbclass: fix BB_GENERATE_MIRROR_TARBALLS checking
> > 
> > The variable 'have_mirror_tarballs' is used as a boolean while it is
> > actually the result of 'd.getVar('BB_GENERATE_MIRROR_TARBALLS')' and
> > thus a string.
> > 
> > Fix this by converting it into a boolean before using it.
> > 
> > Signed-off-by: Enrico Jörns <ejo@pengutronix.de>
> > ---
> >  meta/classes/archiver.bbclass | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass
> > index 9d286224d6..9c8b0daf31 100644
> > --- a/meta/classes/archiver.bbclass
> > +++ b/meta/classes/archiver.bbclass
> > @@ -339,7 +339,7 @@ python do_ar_mirror() {
> >      dl_dir = d.getVar('DL_DIR')
> >      mirror_exclusions = (d.getVar('ARCHIVER_MIRROR_EXCLUDE') or '').split()
> >      mirror_mode = d.getVarFlag('ARCHIVER_MODE', 'mirror')
> > -    have_mirror_tarballs = d.getVar('BB_GENERATE_MIRROR_TARBALLS')
> > +    have_mirror_tarballs = d.getVar('BB_GENERATE_MIRROR_TARBALLS') == "1"
> 
> May I suggest:
> 
>     have_mirror_tarballs = oe.types.boolean(d.getVar('BB_GENERATE_MIRROR_TARBALLS'))
> 
> instead?

Oh, did not know this helper exists. Thank you for the hint!
Will send a v2.

Regards, Enrico

> > 
> >      if mirror_mode == 'combined':
> >          destdir = d.getVar('ARCHIVER_COMBINED_MIRRORDIR')
> > --
> > 2.39.2
> 
> //Peter
>
diff mbox series

Patch

diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass
index 9d286224d6..9c8b0daf31 100644
--- a/meta/classes/archiver.bbclass
+++ b/meta/classes/archiver.bbclass
@@ -339,7 +339,7 @@  python do_ar_mirror() {
     dl_dir = d.getVar('DL_DIR')
     mirror_exclusions = (d.getVar('ARCHIVER_MIRROR_EXCLUDE') or '').split()
     mirror_mode = d.getVarFlag('ARCHIVER_MODE', 'mirror')
-    have_mirror_tarballs = d.getVar('BB_GENERATE_MIRROR_TARBALLS')
+    have_mirror_tarballs = d.getVar('BB_GENERATE_MIRROR_TARBALLS') == "1"
 
     if mirror_mode == 'combined':
         destdir = d.getVar('ARCHIVER_COMBINED_MIRRORDIR')