diff mbox series

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

Message ID 20191023211101.16591-4-adrian.freihofer@siemens.com
State Changes Requested
Headers show
Series simplify swupdate config | expand

Commit Message

Freihofer, Adrian Oct. 23, 2019, 9:10 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

Stefan Herbrechtsmeier Oct. 24, 2019, 8:43 a.m. UTC | #1
Am 23.10.19 um 23:10 schrieb Adrian Freihofer:
> 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.
> 

Please don't use a single @ and use an obviously solution which is easy 
readable. Maybe we should use ${} to support nested variables:
$${ROOTFS_IMAGE}_SHA256}

Alternative a sw-description.bbclass could create the sw-description 
on-the-fly.

Regards
   Stefan
Adrian Freihofer Oct. 24, 2019, 11:45 a.m. UTC | #2
Hi Stefan

Am Donnerstag, 24. Oktober 2019 10:43:37 UTC+2 schrieb Stefan 
Herbrechtsmeier:
>
> Am 23.10.19 um 23:10 schrieb Adrian Freihofer: 
> > 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. 
> > 
>
> Please don't use a single @ and use an obviously solution which is easy 
> readable. Maybe we should use ${} to support nested variables: 
> $${ROOTFS_IMAGE}_SHA256} 
>

A single @ was not invented by me. It's the syntax required for the sha256 
parameter. My patch just adds the possibility to combine the @@ with the 
already existing @. Everything else would break backward compatibility. 
Otherwise I would agree with your proposal. 

>
> Alternative a sw-description.bbclass could create the sw-description 
> on-the-fly. 
>
Creating such a class might be a long term goal. But this class needs to 
support all features of the sw-description file, which is not that easy.

>
> Regards 
>    Stefan 
>
diff mbox series

Patch

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: