Skip to contentSkip to conversation

data_smart: restore the ability to use capital letters

PATCH Superseded Yann Dirson 2 participants 12 messages Oct 7 – Oct 13 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 2/2 data_smart: restore the ability to use capital letters

This reverts commit 6eb56624e6d8dc1944e559b4f6584bfe66f566ba.

That commit was meant as an ad-hoc band-aid when "_" was used as override prefix, and it explicitly blocked capital letters from being usable in the overrides. There is no reason to keep it now we use ":" as prefix.

---
 lib/bb/data_smart.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/data_smart.py +1 -1
index 8aa7c1f99..3c149239f 100644
@@ -31,7 +31,7 @@ from bb.COW  import COWDictBase
 logger = logging.getLogger("BitBake.Data")
 
 __setvar_keyword__ = [":append", ":prepend", ":remove"]
-__setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>:append|:prepend|:remove)(:(?P<add>[^A-Z]*))?$')
+__setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>:append|:prepend|:remove)(:(?P<add>.*))?$')
 __expand_var_regexp__ = re.compile(r"\${[a-zA-Z0-9\-_+./~:]+}")
 __expand_python_regexp__ = re.compile(r"\${@(?:{.*?}|.)+?}")
 __whitespace_split__ = re.compile(r'(\s)')
Signature · 10 lines
2.47.3



--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
#2 lore raw

Re: [PATCH 1/2] parse: add a (failing) test for a variable override with capital letters

In reply to a message not in the archive

Both patches are meant for both master and 2.18.

Quoted 27 lines · Yann Dirson
---
  lib/bb/tests/parse.py | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)
lib/bb/tests/parse.py +14 -0
index 6ac2137e0..9fc094b16 100644
@@ -150,6 +150,27 @@ exportD = "d"
          self.assertEqual(d.getVar("exportD"), "d")
          self.assertIsNone(d.getVarFlag("exportD", "export"))
 
+    mixedcase_pn_override = """
+PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False), d)[0]}"
+OVERRIDES = "pn-${PN}"
+RPROVIDES:perl-ExtUtils-MakeMaker = "base"
+RPROVIDES:perl-ExtUtils-MakeMaker:append:pn-ExtUtils-MakeMaker = " text"
+"""
+
+    def test_parse_mixedcase_pn_override(self):
+        # Recipes named after CPAN distributions have mixed-case PNs, so
+        # OVERRIDES contains a mixed-case pn-${PN} entry. An operation
+        # guarded by that override must still be applied.
+        with tempfile.TemporaryDirectory() as tempdir:
+            recipe = os.path.join(tempdir, "ExtUtils-MakeMaker.bb")
+            with open(recipe, "w") as f:

lib/bb/tests/parse.py exportD = "d" · line 176

Quoted 10 lines
lib/bb/tests/parse.py +7 -0
+                f.write(self.mixedcase_pn_override)
+            os.chdir(tempdir)
+            d = bb.parse.handle(recipe, self.d)['']
+        self.assertEqual(d.getVar("PN"), "ExtUtils-MakeMaker")
+        self.assertIn("pn-ExtUtils-MakeMaker", d.getVar("OVERRIDES").split(":"))
+        self.assertEqual(d.getVar("RPROVIDES:perl-ExtUtils-MakeMaker"), "base text")
+
      overridetest = """
  RRECOMMENDS:${PN} = "a"
  RRECOMMENDS:${PN}:libc = "b"

--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

PATCH v2 1/2 parse: add a (failing) test for a variable override with capital letters

---
 lib/bb/tests/parse.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
lib/bb/tests/parse.py +22 -0
index 6ac2137e0..7e7dbd923 100644
@@ -150,6 +150,28 @@ exportD = "d"
         self.assertEqual(d.getVar("exportD"), "d")
         self.assertIsNone(d.getVarFlag("exportD", "export"))
 
+    mixedcase_pn_override = """
+PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False), d)[0]}"
+OVERRIDES = "pn-${PN}"
+RPROVIDES:perl-ExtUtils-MakeMaker = "base"
+RPROVIDES:perl-ExtUtils-MakeMaker:append:pn-ExtUtils-MakeMaker = " text"
+"""
+
+    @unittest.expectedFailure
+    def test_parse_mixedcase_pn_override(self):
+        # Recipes named after CPAN distributions have mixed-case PNs, so
+        # OVERRIDES contains a mixed-case pn-${PN} entry. An operation
+        # guarded by that override must still be applied.
+        with tempfile.TemporaryDirectory() as tempdir:
+            recipe = os.path.join(tempdir, "ExtUtils-MakeMaker.bb")
+            with open(recipe, "w") as f:
+                f.write(self.mixedcase_pn_override)
+            os.chdir(tempdir)
+            d = bb.parse.handle(recipe, self.d)['']
+        self.assertEqual(d.getVar("PN"), "ExtUtils-MakeMaker")
+        self.assertIn("pn-ExtUtils-MakeMaker", d.getVar("OVERRIDES").split(":"))
+        self.assertEqual(d.getVar("RPROVIDES:perl-ExtUtils-MakeMaker"), "base text")
+
     overridetest = """
 RRECOMMENDS:${PN} = "a"
 RRECOMMENDS:${PN}:libc = "b"
Signature · 10 lines
2.47.3



--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
#5 lore raw

PATCH v2 2/2 data_smart: restore the ability to use capital letters

In reply to a message not in the archive

This reverts commit 6eb56624e6d8dc1944e559b4f6584bfe66f566ba.

That commit was meant as an ad-hoc band-aid when "_" was used as override prefix, and it explicitly blocked capital letters from being usable in the overrides. There is no reason to keep it now we use ":" as prefix.

---
 lib/bb/data_smart.py  | 2 +-
 lib/bb/tests/parse.py | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
lib/bb/data_smart.py +1 -1
index 8aa7c1f99..3c149239f 100644
@@ -31,7 +31,7 @@ from bb.COW  import COWDictBase
 logger = logging.getLogger("BitBake.Data")
 
 __setvar_keyword__ = [":append", ":prepend", ":remove"]
-__setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>:append|:prepend|:remove)(:(?P<add>[^A-Z]*))?$')
+__setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>:append|:prepend|:remove)(:(?P<add>.*))?$')
 __expand_var_regexp__ = re.compile(r"\${[a-zA-Z0-9\-_+./~:]+}")
 __expand_python_regexp__ = re.compile(r"\${@(?:{.*?}|.)+?}")
 __whitespace_split__ = re.compile(r'(\s)')
lib/bb/tests/parse.py +0 -1
index 7e7dbd923..9fc094b16 100644
@@ -157,7 +157,6 @@ RPROVIDES:perl-ExtUtils-MakeMaker = "base"
 RPROVIDES:perl-ExtUtils-MakeMaker:append:pn-ExtUtils-MakeMaker = " text"
 """
 
-    @unittest.expectedFailure
     def test_parse_mixedcase_pn_override(self):
         # Recipes named after CPAN distributions have mixed-case PNs, so
         # OVERRIDES contains a mixed-case pn-${PN} entry. An operation
Signature · 10 lines
2.47.3



--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
#6 lore raw
Quoted 9 lines · Yann Dirson via lists.openembedded.org

This reverts commit 6eb56624e6d8dc1944e559b4f6584bfe66f566ba.

That commit was meant as an ad-hoc band-aid when "_" was used as override prefix, and it explicitly blocked capital letters from being usable in the overrides. There is no reason to keep it now we use ":" as prefix.

---

Hi Yann,

Thanks for the new version, but we are still seeing the same failure:

FAIL: test_append_in_expanded_override (bb.tests.data.TestOverrides.test_append_in_expanded_override)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/lib/bb/tests/data.py", line 417, in test_append_in_expanded_override
self.assertEqual(self.d.getVar("TEST"), "base appended")
AssertionError: 'base' != 'base appended'
- base
+ base appended

https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/5075
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/5043
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/4856

Can you have a look at the issue?

Thanks,
Mathieu

Signature · 3 lines
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#7 lore raw
Quoted 24 lines · Mathieu Dubois-Briand
Quoted 9 lines · Yann Dirson via lists.openembedded.org

This reverts commit 6eb56624e6d8dc1944e559b4f6584bfe66f566ba.

That commit was meant as an ad-hoc band-aid when "_" was used as override prefix, and it explicitly blocked capital letters from being usable in the overrides. There is no reason to keep it now we use ":" as prefix.

---

Hi Yann,

Thanks for the new version, but we are still seeing the same failure:

FAIL: test_append_in_expanded_override (bb.tests.data.TestOverrides.test_append_in_expanded_override)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/srv/pokybuild/yocto-worker/oe-selftest-armhost/build/layers/bitbake/lib/bb/tests/data.py", line 417, in test_append_in_expanded_override
self.assertEqual(self.d.getVar("TEST"), "base appended")
AssertionError: 'base' != 'base appended'
- base
+ base appended

Quoted 3 lines

https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/5075
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/5043
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/4856

Wow, that's funky. Getting the same sha1 tested in the autobuilder I don't see any failure, do I have anything special to do to reproduce how the autobuilder tests things?

$ git fetch origin 83afc355141f2451058f505f18be4b95486ec050
...
 From https://git.openembedded.org/bitbake
  * branch                83afc355141f2451058f505f18be4b95486ec050 -> 
FETCH_HEAD
$ git checkout FETCH_HEAD
...
HEAD is now at 83afc3551 data_smart: restore the ability to use capital 
letters
$ ./bin/bitbake-selftest 
bb.tests.parse.ParseTest.test_parse_mixedcase_pn_override
.
----------------------------------------------------------------------
Ran 1 test in 0.001s

OK

$ git checkout HEAD^
...
HEAD is now at 6e7bdd494 parse: add a (failing) test for a variable 
override with capital letters
$ ./bin/bitbake-selftest 
bb.tests.parse.ParseTest.test_parse_mixedcase_pn_override
x
----------------------------------------------------------------------
Ran 1 test in 0.002s

OK (expected failures=1)

--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

#8 lore raw

v3 cover capital letters in overrides

In reply to a message not in the archive

New in v3:
- add a test showing non-expansion of lowercase variable in override
- fix that, which also fixes the regression observed in v2

New in v2:
- use @unittest.expectedFailure

Yann Dirson (4):
data: add a (failing) test showing non-expansion of lowercase variable
in override
data_smart: differ taking overrides with unexpanded variables into
account
parse: add a (failing) test for a variable override with capital
letters
data_smart: restore the ability to use capital letters

 lib/bb/data_smart.py  |  2 +-
 lib/bb/tests/data.py  | 10 ++++++++++
 lib/bb/tests/parse.py | 21 +++++++++++++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)
Signature · 10 lines
2.47.3



--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

PATCH v3 1/4 data: add a (failing) test showing non-expansion of lowercase variable in override

This is a minor variation of the test_append_in_expanded_override test.

---
 lib/bb/tests/data.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/bb/tests/data.py +11 -0
index 491774747..31a1ec323 100644
@@ -416,6 +416,17 @@ class TestOverrides(unittest.TestCase):
         bb.data.expandKeys(self.d)
         self.assertEqual(self.d.getVar("TEST"), "base appended")
 
+    # Test an :append whose override name is lowercase
+    @unittest.expectedFailure
+    def test_append_in_expanded_lowercase_override(self):
+        self.d.setVar("machine", "qemux86")
+        self.d.setVar("PN", "gizmo")
+        self.d.setVar("OVERRIDES", "gizmo:pn-gizmo-qemux86")
+        self.d.setVar("TEST:${PN}", "base")
+        self.d.setVar("TEST:${PN}:append:pn-gizmo-${machine}", " appended")
+        bb.data.expandKeys(self.d)
+        self.assertEqual(self.d.getVar("TEST"), "base appended")
+
     # Test renaming to a key which is itself not expanded yet, as native.bbclass
     # does. The dependent override keys must be left for expandKeys() to rename.
     def test_rename_to_unexpanded_key_with_override(self):
Signature · 10 lines
2.47.3



--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
#11 lore raw

PATCH v3 2/4 data_smart: differ taking overrides with unexpanded variables into account

In reply to a message not in the archive

In original code, in a setVar call for, say, "TEST:foo-${MACHINE}", the __setvar_regexp__ regexp does not match *because of capitals*, so it stores a variable name including $ and caps. Later during finalization expandKeys then calls renameVar and setVar, at which point the regexp matches and the override is detected.

The reason why this works is not because there is a variable in the override text, but because there are uppercase letters, so it would break with lowercase, as well as if we want to change the regexp to allow uppercase in an override string.

Assisted-by Claude Opus 5.5
---
 lib/bb/data_smart.py | 2 +-
 lib/bb/tests/data.py | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
lib/bb/data_smart.py +1 -1
index 8aa7c1f99..a6e4bddb6 100644
@@ -31,7 +31,7 @@ from bb.COW  import COWDictBase
 logger = logging.getLogger("BitBake.Data")
 
 __setvar_keyword__ = [":append", ":prepend", ":remove"]
-__setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>:append|:prepend|:remove)(:(?P<add>[^A-Z]*))?$')
+__setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>:append|:prepend|:remove)(:(?P<add>[^A-Z$]*))?$')
 __expand_var_regexp__ = re.compile(r"\${[a-zA-Z0-9\-_+./~:]+}")
 __expand_python_regexp__ = re.compile(r"\${@(?:{.*?}|.)+?}")
 __whitespace_split__ = re.compile(r'(\s)')
lib/bb/tests/data.py +0 -1
index 31a1ec323..fb455be98 100644
@@ -417,7 +417,6 @@ class TestOverrides(unittest.TestCase):
         self.assertEqual(self.d.getVar("TEST"), "base appended")
 
     # Test an :append whose override name is lowercase
-    @unittest.expectedFailure
     def test_append_in_expanded_lowercase_override(self):
         self.d.setVar("machine", "qemux86")
         self.d.setVar("PN", "gizmo")
Signature · 10 lines
2.47.3



--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
#12 lore raw

PATCH v3 3/4 parse: add a (failing) test for a variable override with capital letters

In reply to a message not in the archive
---
 lib/bb/tests/parse.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
lib/bb/tests/parse.py +22 -0
index 6ac2137e0..7e7dbd923 100644
@@ -150,6 +150,28 @@ exportD = "d"
         self.assertEqual(d.getVar("exportD"), "d")
         self.assertIsNone(d.getVarFlag("exportD", "export"))
 
+    mixedcase_pn_override = """
+PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False), d)[0]}"
+OVERRIDES = "pn-${PN}"
+RPROVIDES:perl-ExtUtils-MakeMaker = "base"
+RPROVIDES:perl-ExtUtils-MakeMaker:append:pn-ExtUtils-MakeMaker = " text"
+"""
+
+    @unittest.expectedFailure
+    def test_parse_mixedcase_pn_override(self):
+        # Recipes named after CPAN distributions have mixed-case PNs, so
+        # OVERRIDES contains a mixed-case pn-${PN} entry. An operation
+        # guarded by that override must still be applied.
+        with tempfile.TemporaryDirectory() as tempdir:
+            recipe = os.path.join(tempdir, "ExtUtils-MakeMaker.bb")
+            with open(recipe, "w") as f:
+                f.write(self.mixedcase_pn_override)
+            os.chdir(tempdir)
+            d = bb.parse.handle(recipe, self.d)['']
+        self.assertEqual(d.getVar("PN"), "ExtUtils-MakeMaker")
+        self.assertIn("pn-ExtUtils-MakeMaker", d.getVar("OVERRIDES").split(":"))
+        self.assertEqual(d.getVar("RPROVIDES:perl-ExtUtils-MakeMaker"), "base text")
+
     overridetest = """
 RRECOMMENDS:${PN} = "a"
 RRECOMMENDS:${PN}:libc = "b"
Signature · 10 lines
2.47.3



--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
#13 lore raw

PATCH v3 4/4 data_smart: restore the ability to use capital letters

In reply to a message not in the archive

This reverts commit 6eb56624e6d8dc1944e559b4f6584bfe66f566ba.

That commit was meant as an ad-hoc band-aid when "_" was used as override prefix, and it explicitly blocked capital letters from being usable in the overrides. There is no reason to keep it now we use ":" as prefix.

---
 lib/bb/data_smart.py  | 2 +-
 lib/bb/tests/parse.py | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)
lib/bb/data_smart.py +1 -1
index a6e4bddb6..a95c08425 100644
@@ -31,7 +31,7 @@ from bb.COW  import COWDictBase
 logger = logging.getLogger("BitBake.Data")
 
 __setvar_keyword__ = [":append", ":prepend", ":remove"]
-__setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>:append|:prepend|:remove)(:(?P<add>[^A-Z$]*))?$')
+__setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>:append|:prepend|:remove)(:(?P<add>[^$]*))?$')
 __expand_var_regexp__ = re.compile(r"\${[a-zA-Z0-9\-_+./~:]+}")
 __expand_python_regexp__ = re.compile(r"\${@(?:{.*?}|.)+?}")
 __whitespace_split__ = re.compile(r'(\s)')
lib/bb/tests/parse.py +0 -1
index 7e7dbd923..9fc094b16 100644
@@ -157,7 +157,6 @@ RPROVIDES:perl-ExtUtils-MakeMaker = "base"
 RPROVIDES:perl-ExtUtils-MakeMaker:append:pn-ExtUtils-MakeMaker = " text"
 """
 
-    @unittest.expectedFailure
     def test_parse_mixedcase_pn_override(self):
         # Recipes named after CPAN distributions have mixed-case PNs, so
         # OVERRIDES contains a mixed-case pn-${PN} entry. An operation
Signature · 10 lines
2.47.3



--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech
#14 lore raw

v2 cover capital letters in overrides

In reply to a message not in the archive

New in v2:
- use @unittest.expectedFailure

Yann Dirson (2):
parse: add a (failing) test for a variable override with capital
letters
data_smart: restore the ability to use capital letters

 lib/bb/data_smart.py  |  2 +-
 lib/bb/tests/parse.py | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
Signature · 10 lines
2.47.3



--
Yann Dirson | Vates Platform Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech