All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] data_smart: Pass flags through variable rename
@ 2022-06-09  7:06 Alex Kiernan
  2022-06-09  9:58 ` [bitbake-devel] " Richard Purdie
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Kiernan @ 2022-06-09  7:06 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Alex Kiernan, otavio.salvador, Alex Kiernan

During variable expansion, the flags are not passed through but are
discarded which makes constructs such as:

  ALTERNATIVE_TARGET:${PN}-foo[name] = "value"

fail.

This was previously attempted in 2013:

  https://lists.openembedded.org/g/bitbake-devel/message/3333

It's unclear what the issue called out last time was:

> I think this does not work for all cases but I don't know how to deal
> properly with it. It fixes the case of updates-alternative but breaks
> other code.

  https://lists.openembedded.org/g/bitbake-devel/message/3334

But this code now passes both oe-selftest and bitbake-selftest.

Cc: otavio.salvador@ossystems.com.br
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Signed-off-by: Alex Kiernan <alexk@zuma.ai>
---
 lib/bb/data_smart.py | 12 +++++++-----
 lib/bb/tests/data.py |  4 ++++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index dd20ca557ee2..308f8eab4913 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -675,13 +675,15 @@ class DataSmart(MutableMapping):
 
         srcflags = self.getVarFlags(key, False, True) or {}
         for i in srcflags:
-            if i not in (__setvar_keyword__):
+            if i == "_content":
                 continue
             src = srcflags[i]
-
-            dest = self.getVarFlag(newkey, i, False) or []
-            dest.extend(src)
-            self.setVarFlag(newkey, i, dest, ignore=True)
+            if i in (__setvar_keyword__):
+                dest = self.getVarFlag(newkey, i, False) or []
+                dest.extend(src)
+                self.setVarFlag(newkey, i, dest, ignore=True)
+            else:
+                self.setVarFlag(newkey, i, src, ignore=True)
 
         if key in self.overridedata:
             self.overridedata[newkey] = []
diff --git a/lib/bb/tests/data.py b/lib/bb/tests/data.py
index e667c7c7d359..5cdf1494f3c4 100644
--- a/lib/bb/tests/data.py
+++ b/lib/bb/tests/data.py
@@ -440,6 +440,10 @@ class TestFlags(unittest.TestCase):
         self.assertEqual(self.d.getVarFlag("foo", "flag1", False), "value of flag1")
         self.assertEqual(self.d.getVarFlag("foo", "flag2", False), None)
 
+    def test_renameflag(self):
+        self.d.renameVar("foo", "bar")
+        self.assertEqual(self.d.getVarFlag("bar", "flag1", False), "value of flag1")
+
 
 class Contains(unittest.TestCase):
     def setUp(self):
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-28 11:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-09  7:06 [PATCH] data_smart: Pass flags through variable rename Alex Kiernan
2022-06-09  9:58 ` [bitbake-devel] " Richard Purdie
2022-06-09 10:33   ` Alex Kiernan
     [not found]   ` <16F6ED45D7C68CA7.32696@lists.openembedded.org>
2022-06-16 12:27     ` Alex Kiernan
2022-06-27 11:10       ` Richard Purdie
2022-06-28 11:13         ` Alex Kiernan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.