diff mbox series

[meta-swupdate,1/2] swupdate.bbclass: fix SWUPDATE_IMAGES_NOAPPEND_MACHINE parsing

Message ID 20210513081621.2461311-1-luca@lucaceresoli.net
State Accepted
Headers show
Series [meta-swupdate,1/2] swupdate.bbclass: fix SWUPDATE_IMAGES_NOAPPEND_MACHINE parsing | expand

Commit Message

Luca Ceresoli May 13, 2021, 8:16 a.m. UTC
The SWUPDATE_IMAGES_NOAPPEND_MACHINE check is incorrect and always takes
the 'elif' branch. This is because the allowed values for
SWUPDATE_IMAGES_NOAPPEND_MACHINE are "0", "1" or unset. The first two
values are strings, and getVarFlag() returns them as strings, but the code
checks for boolean.

Keep the allowed values to "0", "1" or unset as per the documentation and
to keep backward compatibility, and fix by comparing with strings instead
of booleans.

Fixes: b6534bbc2781 ("swupdate: simplify find images added to swu")
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
---
 classes/swupdate.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stefano Babic May 13, 2021, 9:18 a.m. UTC | #1
On 13.05.21 10:16, Luca Ceresoli wrote:
> The SWUPDATE_IMAGES_NOAPPEND_MACHINE check is incorrect and always takes
> the 'elif' branch. This is because the allowed values for
> SWUPDATE_IMAGES_NOAPPEND_MACHINE are "0", "1" or unset. The first two
> values are strings, and getVarFlag() returns them as strings, but the code
> checks for boolean.
> 
> Keep the allowed values to "0", "1" or unset as per the documentation and
> to keep backward compatibility, and fix by comparing with strings instead
> of booleans.
> 
> Fixes: b6534bbc2781 ("swupdate: simplify find images added to swu")
> Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
> ---
>   classes/swupdate.bbclass | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
> index 2c2430b35dd2..4affe681ff33 100644
> --- a/classes/swupdate.bbclass
> +++ b/classes/swupdate.bbclass
> @@ -136,9 +136,9 @@ python do_swuimage () {
>           encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", image, True) or "")
>           if fstypes:
>               noappend_machine = d.getVarFlag("SWUPDATE_IMAGES_NOAPPEND_MACHINE", image, True)
> -            if noappend_machine == False:  # Search for a file explicitely with MACHINE
> +            if noappend_machine == "0":  # Search for a file explicitely with MACHINE
>                   imagebases = [ image + '-' + d.getVar('MACHINE', True) ]
> -            elif noappend_machine == True:  # Search for a file explicitely without MACHINE
> +            elif noappend_machine == "1":  # Search for a file explicitely without MACHINE
>                   imagebases = [ image ]
>               else:  # None, means auto mode. Just try to find an image file with MACHINE or without MACHINE
>                   imagebases = [ image + '-' + d.getVar('MACHINE', True), image ]
> 

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
index 2c2430b35dd2..4affe681ff33 100644
--- a/classes/swupdate.bbclass
+++ b/classes/swupdate.bbclass
@@ -136,9 +136,9 @@  python do_swuimage () {
         encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", image, True) or "")
         if fstypes:
             noappend_machine = d.getVarFlag("SWUPDATE_IMAGES_NOAPPEND_MACHINE", image, True)
-            if noappend_machine == False:  # Search for a file explicitely with MACHINE
+            if noappend_machine == "0":  # Search for a file explicitely with MACHINE
                 imagebases = [ image + '-' + d.getVar('MACHINE', True) ]
-            elif noappend_machine == True:  # Search for a file explicitely without MACHINE
+            elif noappend_machine == "1":  # Search for a file explicitely without MACHINE
                 imagebases = [ image ]
             else:  # None, means auto mode. Just try to find an image file with MACHINE or without MACHINE
                 imagebases = [ image + '-' + d.getVar('MACHINE', True), image ]