Skip to contentSkip to conversation

fetcher: fix BB_STRICT_CHECKSUM datatype check

PATCH Superseded Alejandro Hernandez 2 participants 5 messages Sep 30, 2014 – Oct 9, 2014

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fetcher: fix BB_STRICT_CHECKSUM datatype check

Forcing strict to be a string, to avoid problems when performing comparisons

[YOCTO #6762]

---
 lib/bb/fetch2/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bb/fetch2/__init__.py +2 -2
index df2f2b0..10c3346 100644
@@ -543,8 +543,8 @@ def verify_checksum(ud, d):
 
     if ud.method.recommends_checksum(ud):
         # If strict checking enabled and neither sum defined, raise error
-        strict = d.getVar("BB_STRICT_CHECKSUM", True) or None
-        if strict and not (ud.md5_expected or ud.sha256_expected):
+        strict = d.getVar("BB_STRICT_CHECKSUM", "1") or "0"
+        if (strict == "1") and not (ud.md5_expected or ud.sha256_expected):
             logger.error('No checksum specified for %s, please add at least one to the recipe:\n'
                              'SRC_URI[%s] = "%s"\nSRC_URI[%s] = "%s"' %
                              (ud.localpath, ud.md5_name, md5data,
Signature · 1 line
1.9.1
#1 lore raw
Quoted 22 lines · Alejandro Hernandez

Forcing strict to be a string, to avoid problems when performing comparisons

[YOCTO #6762]

---
 lib/bb/fetch2/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bb/fetch2/__init__.py +2 -2
index df2f2b0..10c3346 100644
@@ -543,8 +543,8 @@ def verify_checksum(ud, d):
 
     if ud.method.recommends_checksum(ud):
         # If strict checking enabled and neither sum defined, raise error
-        strict = d.getVar("BB_STRICT_CHECKSUM", True) or None
-        if strict and not (ud.md5_expected or ud.sha256_expected):
+        strict = d.getVar("BB_STRICT_CHECKSUM", "1") or "0"
+        if (strict == "1") and not (ud.md5_expected or
Quoted 2 lines

ud.sha256_expected):

Why was True (second argument of getVar) changed to "1" here? It violates our conventions and doesn't actually change anything in the behavior.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#2 lore raw

It does not change behavior but it forces the value to be a string, avoiding related problems when performing comparisons on "strict", another option as Richard Purdie suggested would be to import the boolean function from /meta/lib/oe/types.py in OE-Core into a new types module in bitbake, forcing it to get a "good" value that we could then use.

Quoted 38 lines · Christopher Larson

On Tue, Sep 30, 2014 at 9:21 AM, Alejandro Hernandez <[email protected] <mailto:[email protected]>> wrote:

    Forcing strict to be a string, to avoid problems when performing
    comparisons

    [YOCTO #6762]

    Signed-off-by: Alejandro Hernandez
    <[email protected]
    <mailto:[email protected]>>
    ---
     lib/bb/fetch2/__init__.py | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)

    diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
    index df2f2b0..10c3346 100644
    --- a/lib/bb/fetch2/__init__.py
    +++ b/lib/bb/fetch2/__init__.py
    @@ -543,8 +543,8 @@ def verify_checksum(ud, d):

         if ud.method.recommends_checksum(ud):
             # If strict checking enabled and neither sum defined,
    raise error
    - strict = d.getVar("BB_STRICT_CHECKSUM", True) or None
    -        if strict and not (ud.md5_expected or ud.sha256_expected):
    + strict = d.getVar("BB_STRICT_CHECKSUM", "1") or "0"
    +        if (strict == "1") and not (ud.md5_expected or
    ud.sha256_expected):

Why was True (second argument of getVar) changed to "1" here? It violates our conventions and doesn't actually change anything in the behavior.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#3 lore raw
Quoted 5 lines · Alejandro Hernandez

It does not change behavior but it forces the value to be a string, avoiding related problems when performing comparisons on "strict", another option as Richard Purdie suggested would be to import the boolean function from /meta/lib/oe/types.py in OE-Core into a new types module in bitbake, forcing it to get a "good" value that we could then use.

No, that's incorrect. The second argument of getVar is a boolean argument named 'expand', which controls whether you get an expanded or unexpanded value. You're now passing a string in boolean context.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#4 lore raw

That is very true, I will fix that, thanks for pointing it out.

Quoted 18 lines · Christopher Larson

On Thu, Oct 9, 2014 at 1:22 PM, Alejandro Hernandez <[email protected] <mailto:[email protected]>> wrote:

It does not change behavior but it forces the value to be a string, avoiding related problems when performing comparisons on "strict", another option as Richard Purdie suggested would be to import the boolean function from /meta/lib/oe/types.py in OE-Core into a new types module in bitbake, forcing it to get a "good" value that we could then use.

No, that's incorrect. The second argument of getVar is a boolean argument named 'expand', which controls whether you get an expanded or unexpanded value. You're now passing a string in boolean context.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics