diff mbox series

[v4,2/3] bb/data_smart: fix override syntax warning

Message ID GV1PR07MB9120D47783B36E780C1BF012A8712@GV1PR07MB9120.eurprd07.prod.outlook.com
State New
Headers show
Series [v4,1/3] bb/data_smart: remove dead code | expand

Commit Message

Konrad Weihmann Oct. 3, 2024, 8:13 a.m. UTC
when defining a function do_removesomething,
the parser warned about

Variable do_removesomething contains an operation using the
old override syntax. Please convert this layer/metadata before
attempting to use with a newer bitbake

correct it would be to search for a override operator at the end
of the string or for the next operator.

To avoid running the expensive regex search on every setVar call
the current "cheap" check would be have to be triggered,
before the more precise check is run.

Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
---
  lib/bb/data_smart.py | 15 ++++++++-------
  1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Peter Kjellerstedt Oct. 3, 2024, 10:30 a.m. UTC | #1
> -----Original Message-----
> From: bitbake-devel@lists.openembedded.org <bitbake-devel@lists.openembedded.org> On Behalf Of Konrad Weihmann
> Sent: den 3 oktober 2024 10:13
> To: bitbake-devel@lists.openembedded.org
> Subject: [bitbake-devel] [PATCH v4 2/3] bb/data_smart: fix override syntax warning
> 
> when defining a function do_removesomething,
> the parser warned about
> 
> Variable do_removesomething contains an operation using the
> old override syntax. Please convert this layer/metadata before
> attempting to use with a newer bitbake
> 
> correct it would be to search for a override operator at the end
> of the string or for the next operator.
> 
> To avoid running the expensive regex search on every setVar call
> the current "cheap" check would be have to be triggered,
> before the more precise check is run.
> 
> Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
> ---
>   lib/bb/data_smart.py | 15 ++++++++-------
>   1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
> index 4e15a43c2..bd2716b2b 100644
> --- a/lib/bb/data_smart.py
> +++ b/lib/bb/data_smart.py
> @@ -35,6 +35,7 @@ __expand_var_regexp__ = re.compile(r"\${[a-zA-Z0-9\-_+./~:]+?}")
>   __expand_python_regexp__ = re.compile(r"\${@(?:{.*?}|.)+?}")
>   __whitespace_split__ = re.compile(r'(\s)')
>   __override_regexp__ = re.compile(r'[a-z0-9]+')
> +__old_override_detailed_regexp__ = re.compile(r"(_append|_prepend|_remove)(_|$)")

While the patch is no longer line broken, there is still something 
weird happening. All context lines seem to have an extra space at 
the start of the line. This of course prevents the patches from 
being applied. I tried to apply this patch using:

b4 shazam -p bitbake-devel GV1PR07MB9120D47783B36E780C1BF012A8712@GV1PR07MB9120.eurprd07.prod.outlook.com

//Peter

> 
>   bitbake_renamed_vars = {
>       "BB_ENV_WHITELIST": "BB_ENV_PASSTHROUGH",
> @@ -539,14 +540,14 @@ class DataSmart(MutableMapping):
>           return var in self.overridedata
> 
>       def setVar(self, var, value, **loginfo):
> -
>           if not var.startswith("__anon_") and ("_append" in var or "_prepend" in var or "_remove" in var):
> -            info = "%s" % var
> -            if "file" in loginfo:
> -                info += " file: %s" % loginfo["file"]
> -            if "line" in loginfo:
> -                info += " line: %s" % loginfo["line"]
> -            bb.fatal("Variable %s contains an operation using the old override syntax. Please convert this layer/metadata before attempting to use with a newer bitbake." % info)
> +            if re.search(__old_override_detailed_regexp__, var) is not None:
> +                info = "%s" % var
> +                if "file" in loginfo:
> +                    info += " file: %s" % loginfo["file"]
> +                if "line" in loginfo:
> +                    info += " line: %s" % loginfo["line"]
> +                bb.fatal("Variable %s contains an operation using the old override syntax. Please convert this layer/metadata before attempting to use with a newer bitbake." % info)
> 
>           shortvar = var.split(":", 1)[0]
>           if shortvar in self._var_renames:
> --
> 2.34.1
Konrad Weihmann Oct. 3, 2024, 10:42 a.m. UTC | #2
On 03.10.24 12:30, Peter Kjellerstedt wrote:
>> -----Original Message-----
>> From: bitbake-devel@lists.openembedded.org <bitbake-devel@lists.openembedded.org> On Behalf Of Konrad Weihmann
>> Sent: den 3 oktober 2024 10:13
>> To: bitbake-devel@lists.openembedded.org
>> Subject: [bitbake-devel] [PATCH v4 2/3] bb/data_smart: fix override syntax warning
>>
>> when defining a function do_removesomething,
>> the parser warned about
>>
>> Variable do_removesomething contains an operation using the
>> old override syntax. Please convert this layer/metadata before
>> attempting to use with a newer bitbake
>>
>> correct it would be to search for a override operator at the end
>> of the string or for the next operator.
>>
>> To avoid running the expensive regex search on every setVar call
>> the current "cheap" check would be have to be triggered,
>> before the more precise check is run.
>>
>> Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
>> ---
>>    lib/bb/data_smart.py | 15 ++++++++-------
>>    1 file changed, 8 insertions(+), 7 deletions(-)
>>
>> diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
>> index 4e15a43c2..bd2716b2b 100644
>> --- a/lib/bb/data_smart.py
>> +++ b/lib/bb/data_smart.py
>> @@ -35,6 +35,7 @@ __expand_var_regexp__ = re.compile(r"\${[a-zA-Z0-9\-_+./~:]+?}")
>>    __expand_python_regexp__ = re.compile(r"\${@(?:{.*?}|.)+?}")
>>    __whitespace_split__ = re.compile(r'(\s)')
>>    __override_regexp__ = re.compile(r'[a-z0-9]+')
>> +__old_override_detailed_regexp__ = re.compile(r"(_append|_prepend|_remove)(_|$)")
> 
> While the patch is no longer line broken, there is still something
> weird happening. All context lines seem to have an extra space at
> the start of the line. This of course prevents the patches from
> being applied. I tried to apply this patch using:
> 
> b4 shazam -p bitbake-devel GV1PR07MB9120D47783B36E780C1BF012A8712@GV1PR07MB9120.eurprd07.prod.outlook.com

:-( - I'm officially given up.

Someone else can pick up the pieces, all that is simply not worth the effort anymore on my side.
Will continue to use my out-of-tree patches.

> 
> //Peter
> 
>>
>>    bitbake_renamed_vars = {
>>        "BB_ENV_WHITELIST": "BB_ENV_PASSTHROUGH",
>> @@ -539,14 +540,14 @@ class DataSmart(MutableMapping):
>>            return var in self.overridedata
>>
>>        def setVar(self, var, value, **loginfo):
>> -
>>            if not var.startswith("__anon_") and ("_append" in var or "_prepend" in var or "_remove" in var):
>> -            info = "%s" % var
>> -            if "file" in loginfo:
>> -                info += " file: %s" % loginfo["file"]
>> -            if "line" in loginfo:
>> -                info += " line: %s" % loginfo["line"]
>> -            bb.fatal("Variable %s contains an operation using the old override syntax. Please convert this layer/metadata before attempting to use with a newer bitbake." % info)
>> +            if re.search(__old_override_detailed_regexp__, var) is not None:
>> +                info = "%s" % var
>> +                if "file" in loginfo:
>> +                    info += " file: %s" % loginfo["file"]
>> +                if "line" in loginfo:
>> +                    info += " line: %s" % loginfo["line"]
>> +                bb.fatal("Variable %s contains an operation using the old override syntax. Please convert this layer/metadata before attempting to use with a newer bitbake." % info)
>>
>>            shortvar = var.split(":", 1)[0]
>>            if shortvar in self._var_renames:
>> --
>> 2.34.1
diff mbox series

Patch

diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 4e15a43c2..bd2716b2b 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -35,6 +35,7 @@  __expand_var_regexp__ = re.compile(r"\${[a-zA-Z0-9\-_+./~:]+?}")
  __expand_python_regexp__ = re.compile(r"\${@(?:{.*?}|.)+?}")
  __whitespace_split__ = re.compile(r'(\s)')
  __override_regexp__ = re.compile(r'[a-z0-9]+')
+__old_override_detailed_regexp__ = re.compile(r"(_append|_prepend|_remove)(_|$)")
  
  bitbake_renamed_vars = {
      "BB_ENV_WHITELIST": "BB_ENV_PASSTHROUGH",
@@ -539,14 +540,14 @@  class DataSmart(MutableMapping):
          return var in self.overridedata
  
      def setVar(self, var, value, **loginfo):
-
          if not var.startswith("__anon_") and ("_append" in var or "_prepend" in var or "_remove" in var):
-            info = "%s" % var
-            if "file" in loginfo:
-                info += " file: %s" % loginfo["file"]
-            if "line" in loginfo:
-                info += " line: %s" % loginfo["line"]
-            bb.fatal("Variable %s contains an operation using the old override syntax. Please convert this layer/metadata before attempting to use with a newer bitbake." % info)
+            if re.search(__old_override_detailed_regexp__, var) is not None:
+                info = "%s" % var
+                if "file" in loginfo:
+                    info += " file: %s" % loginfo["file"]
+                if "line" in loginfo:
+                    info += " line: %s" % loginfo["line"]
+                bb.fatal("Variable %s contains an operation using the old override syntax. Please convert this layer/metadata before attempting to use with a newer bitbake." % info)
  
          shortvar = var.split(":", 1)[0]
          if shortvar in self._var_renames: