aboutsummaryrefslogtreecommitdiffstats
path: root/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-19 12:27:27 +0100
commit8f55010c18057be040f073d8bcb4c5c2c311d809 (patch)
treed4c794b0578432a0814ff28e9db516807d0d4bc9 /lib
parent5463c16e3619d324aed137f47f93f0997a227d29 (diff)
downloadbitbake-8f55010c18057be040f073d8bcb4c5c2c311d809.tar.gz
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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/bb/data_smart.py17
-rw-r--r--lib/bb/tests/data.py9
2 files changed, 22 insertions, 4 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 8c4c6a9a3..6b94fc4b4 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -736,6 +736,7 @@ class DataSmart(MutableMapping):
local_var, overridedata = self._findVar(var)
value = None
+ removes = set()
if flag == "_content" and overridedata is not None and not parsing:
match = False
active = {}
@@ -762,7 +763,11 @@ class DataSmart(MutableMapping):
match = active[a]
del active[a]
if match:
- value = self.getVar(match, False)
+ value, subparser = self.getVarFlag(match, "_content", False, retparser=True)
+ if hasattr(subparser, "removes"):
+ # We have to carry the removes from the overridden variable to apply at the
+ # end of processing
+ removes = subparser.removes
if local_var is not None and value is None:
if flag in local_var:
@@ -805,7 +810,6 @@ class DataSmart(MutableMapping):
value = parser.value
if value and flag == "_content" and local_var is not None and "_remove" in local_var and not parsing:
- removes = {}
self.need_overrides()
for (r, o) in local_var["_remove"]:
match = True
@@ -814,15 +818,20 @@ class DataSmart(MutableMapping):
if not o2 in self.overrides:
match = False
if match:
- removes[r] = self.expand(r).split()
+ removes.add(r)
+ if value and flag == "_content" and not parsing:
if removes and parser:
+ expanded_removes = {}
+ for r in removes:
+ expanded_removes[r] = self.expand(r).split()
+
parser.removes = set()
val = ""
for v in __whitespace_split__.split(parser.value):
skip = False
for r in removes:
- if v in removes[r]:
+ if v in expanded_removes[r]:
parser.removes.add(r)
skip = True
if skip:
diff --git a/lib/bb/tests/data.py b/lib/bb/tests/data.py
index 9ac78e368..db3e2010a 100644
--- a/lib/bb/tests/data.py
+++ b/lib/bb/tests/data.py
@@ -386,6 +386,15 @@ class TestOverrides(unittest.TestCase):
self.d.setVar("OVERRIDES", "foo:bar:some_val")
self.assertEqual(self.d.getVar("TEST"), "testvalue3")
+ def test_remove_with_override(self):
+ self.d.setVar("TEST_bar", "testvalue2")
+ self.d.setVar("TEST_some_val", "testvalue3 testvalue5")
+ self.d.setVar("TEST_some_val_remove", "testvalue3")
+ self.d.setVar("TEST_foo", "testvalue4")
+ self.d.setVar("OVERRIDES", "foo:bar:some_val")
+ self.assertEqual(self.d.getVar("TEST"), " testvalue5")
+
+
class TestKeyExpansion(unittest.TestCase):
def setUp(self):
self.d = bb.data.init()