diff mbox series

[meta-swupdate] swupdate-common: Modify sha256 placeholder regex

Message ID 20210914201335.18948-1-colin.mcallister@garmin.com
State Accepted
Headers show
Series [meta-swupdate] swupdate-common: Modify sha256 placeholder regex | expand

Commit Message

McAllister, Colin Sept. 14, 2021, 8:13 p.m. UTC
From: Colin McAllister <colin.mcallister@garmin.com>

Updated the regex to detect placeholders for sha256 checksums in JSON
formatted sw-description files in addition to libconfig formatted files.

Signed-off-by: Colin McAllister <colin.mcallister@garmin.com>
---
 classes/swupdate-common.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

McAllister, Colin Sept. 14, 2021, 8:16 p.m. UTC | #1
Not sure how to specify this other than sending in another patch, but can 
this patch be applied to the Dunfell branch in addition to master?

Colin

On Tuesday, September 14, 2021 at 3:13:44 PM UTC-5 Colin McAllister wrote:

> From: Colin McAllister <colin.mc...@garmin.com>
>
> Updated the regex to detect placeholders for sha256 checksums in JSON
> formatted sw-description files in addition to libconfig formatted files.
>
> Signed-off-by: Colin McAllister <colin.mc...@garmin.com>
> ---
> classes/swupdate-common.bbclass | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/classes/swupdate-common.bbclass 
> b/classes/swupdate-common.bbclass
> index dabd466..497ef43 100644
> --- a/classes/swupdate-common.bbclass
> +++ b/classes/swupdate-common.bbclass
> @@ -80,7 +80,7 @@ def swupdate_write_sha256(s):
> for line in f:
> shastr = r"sha256.+=.+@(.+\")"
> #m = re.match(r"^(?P<before_placeholder>.+)sha256.+=.+(?P<filename>\w+)", 
> line)
> - m = 
> re.match(r"^(?P<before_placeholder>.+)sha256.+=.+(?P<quote>[\'\"])@(?P<filename>.*)(?P=quote)", 
> line)
> + m = 
> re.match(r"^(?P<before_placeholder>.+)sha256.+[=:].*(?P<quote>[\'\"])@(?P<filename>.*)(?P=quote)", 
> line)
> if m:
> filename = m.group('filename')
> hash = swupdate_get_sha256(s, filename)
> -- 
> 2.25.1
>
>
Stefano Babic Sept. 15, 2021, 3:15 p.m. UTC | #2
On 14.09.21 22:13, colin.mcallister via swupdate wrote:
> From: Colin McAllister <colin.mcallister@garmin.com>
> 
> Updated the regex to detect placeholders for sha256 checksums in JSON
> formatted sw-description files in addition to libconfig formatted files.
> 
> Signed-off-by: Colin McAllister <colin.mcallister@garmin.com>
> ---
>   classes/swupdate-common.bbclass | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/classes/swupdate-common.bbclass b/classes/swupdate-common.bbclass
> index dabd466..497ef43 100644
> --- a/classes/swupdate-common.bbclass
> +++ b/classes/swupdate-common.bbclass
> @@ -80,7 +80,7 @@ def swupdate_write_sha256(s):
>          for line in f:
>             shastr = r"sha256.+=.+@(.+\")"
>             #m = re.match(r"^(?P<before_placeholder>.+)sha256.+=.+(?P<filename>\w+)", line)
> -          m = re.match(r"^(?P<before_placeholder>.+)sha256.+=.+(?P<quote>[\'\"])@(?P<filename>.*)(?P=quote)", line)
> +          m = re.match(r"^(?P<before_placeholder>.+)sha256.+[=:].*(?P<quote>[\'\"])@(?P<filename>.*)(?P=quote)", line)
>             if m:
>                 filename = m.group('filename')
>                 hash = swupdate_get_sha256(s, filename)
> 


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

Applied to -master, -hardknott, -dunfell, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/classes/swupdate-common.bbclass b/classes/swupdate-common.bbclass
index dabd466..497ef43 100644
--- a/classes/swupdate-common.bbclass
+++ b/classes/swupdate-common.bbclass
@@ -80,7 +80,7 @@  def swupdate_write_sha256(s):
        for line in f:
           shastr = r"sha256.+=.+@(.+\")"
           #m = re.match(r"^(?P<before_placeholder>.+)sha256.+=.+(?P<filename>\w+)", line)
-          m = re.match(r"^(?P<before_placeholder>.+)sha256.+=.+(?P<quote>[\'\"])@(?P<filename>.*)(?P=quote)", line)
+          m = re.match(r"^(?P<before_placeholder>.+)sha256.+[=:].*(?P<quote>[\'\"])@(?P<filename>.*)(?P=quote)", line)
           if m:
               filename = m.group('filename')
               hash = swupdate_get_sha256(s, filename)