diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-08-02 16:33:54 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-08-04 10:38:43 +0100 |
commit | 92d8bd0eb5f7fc14c7e77d7f8e09f94929a15337 (patch) | |
tree | b889dfe3db18141ed67e73a3264e955b3196004a | |
parent | 70137f689f6c1909e327832f1c41b75dddd55c5a (diff) | |
download | poky-92d8bd0eb5f7fc14c7e77d7f8e09f94929a15337.tar.gz |
bitbake: data_smart: Fix inactive overide accidental variable value corruption
Setting something like:
BAR:append:unusedoverride
should cause BAR to be None, not "" which was what the datastore was
returning. This caused problems when mixing variables like:
RDEPENDS:${PN}:inactiveoverride
RDEPENDS:${BPN}
since key expansion would report key overlap when there was none. This
is a bug in the datastore. Fix it and add a test too.
[YOCTO #14088]
(Bitbake rev: 699e36c270d863258502d315ed00a1b940bfbf96)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/data_smart.py | 8 | ||||
-rw-r--r-- | bitbake/lib/bb/tests/data.py | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 43e9e78555..65528c6ae6 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py | |||
@@ -750,8 +750,6 @@ class DataSmart(MutableMapping): | |||
750 | 750 | ||
751 | 751 | ||
752 | if flag == "_content" and local_var is not None and ":append" in local_var and not parsing: | 752 | if flag == "_content" and local_var is not None and ":append" in local_var and not parsing: |
753 | if not value: | ||
754 | value = "" | ||
755 | self.need_overrides() | 753 | self.need_overrides() |
756 | for (r, o) in local_var[":append"]: | 754 | for (r, o) in local_var[":append"]: |
757 | match = True | 755 | match = True |
@@ -760,11 +758,11 @@ class DataSmart(MutableMapping): | |||
760 | if not o2 in self.overrides: | 758 | if not o2 in self.overrides: |
761 | match = False | 759 | match = False |
762 | if match: | 760 | if match: |
761 | if value is None: | ||
762 | value = "" | ||
763 | value = value + r | 763 | value = value + r |
764 | 764 | ||
765 | if flag == "_content" and local_var is not None and ":prepend" in local_var and not parsing: | 765 | if flag == "_content" and local_var is not None and ":prepend" in local_var and not parsing: |
766 | if not value: | ||
767 | value = "" | ||
768 | self.need_overrides() | 766 | self.need_overrides() |
769 | for (r, o) in local_var[":prepend"]: | 767 | for (r, o) in local_var[":prepend"]: |
770 | 768 | ||
@@ -774,6 +772,8 @@ class DataSmart(MutableMapping): | |||
774 | if not o2 in self.overrides: | 772 | if not o2 in self.overrides: |
775 | match = False | 773 | match = False |
776 | if match: | 774 | if match: |
775 | if value is None: | ||
776 | value = "" | ||
777 | value = r + value | 777 | value = r + value |
778 | 778 | ||
779 | parser = None | 779 | parser = None |
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py index 7f1d3ffbbc..e667c7c7d3 100644 --- a/bitbake/lib/bb/tests/data.py +++ b/bitbake/lib/bb/tests/data.py | |||
@@ -405,6 +405,11 @@ class TestOverrides(unittest.TestCase): | |||
405 | bb.data.expandKeys(self.d) | 405 | bb.data.expandKeys(self.d) |
406 | self.assertEqual(self.d.getVar("VERSION"), "2") | 406 | self.assertEqual(self.d.getVar("VERSION"), "2") |
407 | 407 | ||
408 | def test_append_and_unused_override(self): | ||
409 | # Had a bug where an unused override append could return "" instead of None | ||
410 | self.d.setVar("BAR:append:unusedoverride", "testvalue2") | ||
411 | self.assertEqual(self.d.getVar("BAR"), None) | ||
412 | |||
408 | class TestKeyExpansion(unittest.TestCase): | 413 | class TestKeyExpansion(unittest.TestCase): |
409 | def setUp(self): | 414 | def setUp(self): |
410 | self.d = bb.data.init() | 415 | self.d = bb.data.init() |