[meta-swupdate,v2,03/12] swupdate: support signed image with variable name
diff mbox series

Message ID 20191024185635.31754-4-adrian.freihofer@siemens.com
State Changes Requested
Headers show
Series
  • simplify swupdate config
Related show

Commit Message

Freihofer, Adrian Oct. 24, 2019, 6:56 p.m. UTC
Support the following in a sw-description:
  filename = "@@ROOTFS_IMAGE@@";
  sha256 = "@@@ROOTFS_IMAGE@@";

First the @@ROOTFS_IMAGE@@ gets replaced e.g. by @my-image. Second
@my-image gets replaced by the sha256 hash.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 classes/swupdate-common.bbclass | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Stefano Babic Oct. 28, 2019, 2:06 p.m. UTC | #1
Hi Adrian,

On 24/10/19 20:56, Adrian Freihofer wrote:
> Support the following in a sw-description:
>   filename = "@@ROOTFS_IMAGE@@";
>   sha256 = "@@@ROOTFS_IMAGE@@";
> 

Ok, but this is how it works now, see my previous e-mail. Can you better
explain the issue you found ? I do not know why it is not working on
your side.

Best regards,
Stefano Babic

> First the @@ROOTFS_IMAGE@@ gets replaced e.g. by @my-image. Second
> @my-image gets replaced by the sha256 hash.
> 
> Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
> ---
>  classes/swupdate-common.bbclass | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/classes/swupdate-common.bbclass b/classes/swupdate-common.bbclass
> index c0b302a..38f1906 100644
> --- a/classes/swupdate-common.bbclass
> +++ b/classes/swupdate-common.bbclass
> @@ -37,22 +37,22 @@ def swupdate_expand_bitbake_variables(d, s):
>          for line in f:
>              found = False
>              while True:
> -                m = re.match(r"^(?P<before_placeholder>.+)@@(?P<bitbake_variable_name>\w+)@@(?P<after_placeholder>.+)$", line)
> +                m = re.match(r"^(?P<before_placeholder>.+)@@(?P<sign_at>@?)(?P<bitbake_variable_name>\w+)@@(?P<after_placeholder>.+)$", line)
>                  if m:
>                      bitbake_variable_value = d.getVar(m.group('bitbake_variable_name'), True)
>                      if bitbake_variable_value is None:
>                         bitbake_variable_value = ""
>                         bb.warn("BitBake variable %s not set" % (m.group('bitbake_variable_name')))
> -                    line = m.group('before_placeholder') + bitbake_variable_value + m.group('after_placeholder')
> +                    line = m.group('before_placeholder') + m.group('sign_at') + bitbake_variable_value + m.group('after_placeholder')
>                      found = True
>                      continue
>                  else:
> -                    m = re.match(r"^(?P<before_placeholder>.+)@@(?P<bitbake_variable_name>.+)\[(?P<flag_var_name>.+)\]@@(?P<after_placeholder>.+)$", line)
> +                    m = re.match(r"^(?P<before_placeholder>.+)(?P<sign_at>@?)@@(?P<bitbake_variable_name>.+)\[(?P<flag_var_name>.+)\]@@(?P<after_placeholder>.+)$", line)
>                      if m:
>                         bitbake_variable_value = (d.getVarFlag(m.group('bitbake_variable_name'), m.group('flag_var_name'), True) or "")
>                         if bitbake_variable_value is None:
>                            bitbake_variable_value = ""
> -                       line = m.group('before_placeholder') + bitbake_variable_value + m.group('after_placeholder')
> +                       line = m.group('before_placeholder') + m.group('sign_at') + bitbake_variable_value + m.group('after_placeholder')
>                         continue
>  
>                      if found:
>

Patch
diff mbox series

diff --git a/classes/swupdate-common.bbclass b/classes/swupdate-common.bbclass
index c0b302a..38f1906 100644
--- a/classes/swupdate-common.bbclass
+++ b/classes/swupdate-common.bbclass
@@ -37,22 +37,22 @@  def swupdate_expand_bitbake_variables(d, s):
         for line in f:
             found = False
             while True:
-                m = re.match(r"^(?P<before_placeholder>.+)@@(?P<bitbake_variable_name>\w+)@@(?P<after_placeholder>.+)$", line)
+                m = re.match(r"^(?P<before_placeholder>.+)@@(?P<sign_at>@?)(?P<bitbake_variable_name>\w+)@@(?P<after_placeholder>.+)$", line)
                 if m:
                     bitbake_variable_value = d.getVar(m.group('bitbake_variable_name'), True)
                     if bitbake_variable_value is None:
                        bitbake_variable_value = ""
                        bb.warn("BitBake variable %s not set" % (m.group('bitbake_variable_name')))
-                    line = m.group('before_placeholder') + bitbake_variable_value + m.group('after_placeholder')
+                    line = m.group('before_placeholder') + m.group('sign_at') + bitbake_variable_value + m.group('after_placeholder')
                     found = True
                     continue
                 else:
-                    m = re.match(r"^(?P<before_placeholder>.+)@@(?P<bitbake_variable_name>.+)\[(?P<flag_var_name>.+)\]@@(?P<after_placeholder>.+)$", line)
+                    m = re.match(r"^(?P<before_placeholder>.+)(?P<sign_at>@?)@@(?P<bitbake_variable_name>.+)\[(?P<flag_var_name>.+)\]@@(?P<after_placeholder>.+)$", line)
                     if m:
                        bitbake_variable_value = (d.getVarFlag(m.group('bitbake_variable_name'), m.group('flag_var_name'), True) or "")
                        if bitbake_variable_value is None:
                           bitbake_variable_value = ""
-                       line = m.group('before_placeholder') + bitbake_variable_value + m.group('after_placeholder')
+                       line = m.group('before_placeholder') + m.group('sign_at') + bitbake_variable_value + m.group('after_placeholder')
                        continue
 
                     if found: