diff mbox series

[meta-swupdate] Extend variable expansion

Message ID DBAPR01MB6887177735282DF3467A47C38E082@DBAPR01MB6887.eurprd01.prod.exchangelabs.com
State Accepted
Delegated to: Stefano Babic
Headers show
Series [meta-swupdate] Extend variable expansion | expand

Commit Message

Daniel Mueller April 16, 2024, 7:05 a.m. UTC
Allow bitbake variable to contain one or more lines to be able to add
complete config blocks when building sw-description.

Signed-off-by: "Mueller, Daniel" <daniel.mueller@karlstorz.com>
---
The current variable expansion mechanism when generating the sw-description
doesn't allow placeholders for multiline config fragments (e.g. complete image
description in a bitbake var). It assumes placeholders are always between '='
and ';' (like filename = "@@SWU_ROOTFS_IMAGE@@.ext4";).

This patch removes this limitation.

 classes-recipe/swupdate-common.bbclass | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Daniel Mueller May 22, 2024, 7:37 a.m. UTC | #1
Hi Stefano

Is there anything else needed to consider this patch for upstream 
integration?

Regards
Daniel

On Tuesday, April 16, 2024 at 11:11:06 AM UTC+2 Mueller, Daniel wrote:

> Allow bitbake variable to contain one or more lines to be able to add
> complete config blocks when building sw-description.
>
> Signed-off-by: "Mueller, Daniel" <daniel....@karlstorz.com>
> ---
> The current variable expansion mechanism when generating the sw-description
> doesn't allow placeholders for multiline config fragments (e.g. complete 
> image
> description in a bitbake var). It assumes placeholders are always between 
> '='
> and ';' (like filename = "@@SWU_ROOTFS_IMAGE@@.ext4";).
>
> This patch removes this limitation.
>
> classes-recipe/swupdate-common.bbclass | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/classes-recipe/swupdate-common.bbclass 
> b/classes-recipe/swupdate-common.bbclass
> index 9074f7f..ad3c0a0 100644
> --- a/classes-recipe/swupdate-common.bbclass
> +++ b/classes-recipe/swupdate-common.bbclass
> @@ -102,7 +102,7 @@ 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<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:
> @@ -112,7 +112,7 @@ def swupdate_expand_bitbake_variables(d, s):
> 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<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:
> @@ -144,7 +144,7 @@ def swupdate_find_bitbake_variables(d):
> 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<bitbake_variable_name>\w+)@@(?P<after_placeholder>.*)$", 
> line)
> if m:
> bitbake_variable_value = m.group('bitbake_variable_name')
> vardeps.append(bitbake_variable_value)
> @@ -152,7 +152,7 @@ def swupdate_find_bitbake_variables(d):
> 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<bitbake_variable_name>.+)\[(?P<flag_var_name>.+)\]@@(?P<after_placeholder>.*)$", 
> line)
> if m:
> bitbake_variable_value = m.group('bitbake_variable_name')
> vardeps.append(bitbake_variable_value)
> -- 
> 2.43.2
>
>
Stefano Babic May 25, 2024, 3:36 p.m. UTC | #2
Hi Daniel,

On 22.05.24 09:37, 'Daniel Mueller' via swupdate wrote:
> Hi Stefano
>
> Is there anything else needed to consider this patch for upstream
> integration?
>

No, it is ok, I apply to meta-swupdate (on the supported branches).

Best regards,
Stefano

> Regards
> Daniel
>
> On Tuesday, April 16, 2024 at 11:11:06 AM UTC+2 Mueller, Daniel wrote:
>
>     Allow bitbake variable to contain one or more lines to be able to add
>     complete config blocks when building sw-description.
>
>     Signed-off-by: "Mueller, Daniel" <daniel....@karlstorz.com>
>     ---
>     The current variable expansion mechanism when generating the
>     sw-description
>     doesn't allow placeholders for multiline config fragments (e.g.
>     complete image
>     description in a bitbake var). It assumes placeholders are always
>     between '='
>     and ';' (like filename = "@@SWU_ROOTFS_IMAGE@@.ext4";).
>
>     This patch removes this limitation.
>
>     classes-recipe/swupdate-common.bbclass | 8 ++++----
>     1 file changed, 4 insertions(+), 4 deletions(-)
>
>     diff --git a/classes-recipe/swupdate-common.bbclass
>     b/classes-recipe/swupdate-common.bbclass
>     index 9074f7f..ad3c0a0 100644
>     --- a/classes-recipe/swupdate-common.bbclass
>     +++ b/classes-recipe/swupdate-common.bbclass
>     @@ -102,7 +102,7 @@ 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<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:
>     @@ -112,7 +112,7 @@ def swupdate_expand_bitbake_variables(d, s):
>     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<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:
>     @@ -144,7 +144,7 @@ def swupdate_find_bitbake_variables(d):
>     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<bitbake_variable_name>\w+)@@(?P<after_placeholder>.*)$", line)
>     if m:
>     bitbake_variable_value = m.group('bitbake_variable_name')
>     vardeps.append(bitbake_variable_value)
>     @@ -152,7 +152,7 @@ def swupdate_find_bitbake_variables(d):
>     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<bitbake_variable_name>.+)\[(?P<flag_var_name>.+)\]@@(?P<after_placeholder>.*)$", line)
>     if m:
>     bitbake_variable_value = m.group('bitbake_variable_name')
>     vardeps.append(bitbake_variable_value)
>     --
>     2.43.2
>
> --
> You received this message because you are subscribed to the Google
> Groups "swupdate" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swupdate+unsubscribe@googlegroups.com
> <mailto:swupdate+unsubscribe@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/swupdate/fa8deece-e602-41ca-bda1-2b99183b8361n%40googlegroups.com <https://groups.google.com/d/msgid/swupdate/fa8deece-e602-41ca-bda1-2b99183b8361n%40googlegroups.com?utm_medium=email&utm_source=footer>.
diff mbox series

Patch

diff --git a/classes-recipe/swupdate-common.bbclass b/classes-recipe/swupdate-common.bbclass
index 9074f7f..ad3c0a0 100644
--- a/classes-recipe/swupdate-common.bbclass
+++ b/classes-recipe/swupdate-common.bbclass
@@ -102,7 +102,7 @@  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<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:
@@ -112,7 +112,7 @@  def swupdate_expand_bitbake_variables(d, s):
                     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<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:
@@ -144,7 +144,7 @@  def swupdate_find_bitbake_variables(d):
             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<bitbake_variable_name>\w+)@@(?P<after_placeholder>.*)$", line)
                     if m:
                         bitbake_variable_value = m.group('bitbake_variable_name')
                         vardeps.append(bitbake_variable_value)
@@ -152,7 +152,7 @@  def swupdate_find_bitbake_variables(d):
                         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<bitbake_variable_name>.+)\[(?P<flag_var_name>.+)\]@@(?P<after_placeholder>.*)$", line)
                         if m:
                             bitbake_variable_value = m.group('bitbake_variable_name')
                             vardeps.append(bitbake_variable_value)