summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-10-19 12:24:18 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-10-20 14:27:03 +0100
commita9dc2ac9e00e3bbea872c8d22568e3acfb9ba3d4 (patch)
treea5219b7daa29d83c1f6123f8bb56509f27df70ed /bitbake/lib
parent52f1041e1a99d391d954f138589cef497a143cb1 (diff)
downloadpoky-a9dc2ac9e00e3bbea872c8d22568e3acfb9ba3d4.tar.gz
bitbake: data_smart: Fix removal handling interaction issue with overrides
If a variable has a _remove applied to it but that variable is in turn 'renamed' through OVERRIDES, the removal gets lost with the current code. TEST = "foo" TEST_someval = "bar" TEST_someval_remove = "bar" OVERRIDES = "someval" currently gives "bar" for TEST but should give "". This fixes the code to track the removal and adds a test case to ensure this doesn't regress again. (Bitbake rev: 8f55010c18057be040f073d8bcb4c5c2c311d809) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/data_smart.py17
-rw-r--r--bitbake/lib/bb/tests/data.py9
2 files changed, 22 insertions, 4 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index 8c4c6a9a32..6b94fc4b42 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -736,6 +736,7 @@ class DataSmart(MutableMapping):
736 736
737 local_var, overridedata = self._findVar(var) 737 local_var, overridedata = self._findVar(var)
738 value = None 738 value = None
739 removes = set()
739 if flag == "_content" and overridedata is not None and not parsing: 740 if flag == "_content" and overridedata is not None and not parsing:
740 match = False 741 match = False
741 active = {} 742 active = {}
@@ -762,7 +763,11 @@ class DataSmart(MutableMapping):
762 match = active[a] 763 match = active[a]
763 del active[a] 764 del active[a]
764 if match: 765 if match:
765 value = self.getVar(match, False) 766 value, subparser = self.getVarFlag(match, "_content", False, retparser=True)
767 if hasattr(subparser, "removes"):
768 # We have to carry the removes from the overridden variable to apply at the
769 # end of processing
770 removes = subparser.removes
766 771
767 if local_var is not None and value is None: 772 if local_var is not None and value is None:
768 if flag in local_var: 773 if flag in local_var:
@@ -805,7 +810,6 @@ class DataSmart(MutableMapping):
805 value = parser.value 810 value = parser.value
806 811
807 if value and flag == "_content" and local_var is not None and "_remove" in local_var and not parsing: 812 if value and flag == "_content" and local_var is not None and "_remove" in local_var and not parsing:
808 removes = {}
809 self.need_overrides() 813 self.need_overrides()
810 for (r, o) in local_var["_remove"]: 814 for (r, o) in local_var["_remove"]:
811 match = True 815 match = True
@@ -814,15 +818,20 @@ class DataSmart(MutableMapping):
814 if not o2 in self.overrides: 818 if not o2 in self.overrides:
815 match = False 819 match = False
816 if match: 820 if match:
817 removes[r] = self.expand(r).split() 821 removes.add(r)
818 822
823 if value and flag == "_content" and not parsing:
819 if removes and parser: 824 if removes and parser:
825 expanded_removes = {}
826 for r in removes:
827 expanded_removes[r] = self.expand(r).split()
828
820 parser.removes = set() 829 parser.removes = set()
821 val = "" 830 val = ""
822 for v in __whitespace_split__.split(parser.value): 831 for v in __whitespace_split__.split(parser.value):
823 skip = False 832 skip = False
824 for r in removes: 833 for r in removes:
825 if v in removes[r]: 834 if v in expanded_removes[r]:
826 parser.removes.add(r) 835 parser.removes.add(r)
827 skip = True 836 skip = True
828 if skip: 837 if skip:
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py
index 9ac78e3683..db3e2010a9 100644
--- a/bitbake/lib/bb/tests/data.py
+++ b/bitbake/lib/bb/tests/data.py
@@ -386,6 +386,15 @@ class TestOverrides(unittest.TestCase):
386 self.d.setVar("OVERRIDES", "foo:bar:some_val") 386 self.d.setVar("OVERRIDES", "foo:bar:some_val")
387 self.assertEqual(self.d.getVar("TEST"), "testvalue3") 387 self.assertEqual(self.d.getVar("TEST"), "testvalue3")
388 388
389 def test_remove_with_override(self):
390 self.d.setVar("TEST_bar", "testvalue2")
391 self.d.setVar("TEST_some_val", "testvalue3 testvalue5")
392 self.d.setVar("TEST_some_val_remove", "testvalue3")
393 self.d.setVar("TEST_foo", "testvalue4")
394 self.d.setVar("OVERRIDES", "foo:bar:some_val")
395 self.assertEqual(self.d.getVar("TEST"), " testvalue5")
396
397
389class TestKeyExpansion(unittest.TestCase): 398class TestKeyExpansion(unittest.TestCase):
390 def setUp(self): 399 def setUp(self):
391 self.d = bb.data.init() 400 self.d = bb.data.init()