diff options
author | Alexander Kanavin <alex@linutronix.de> | 2025-10-02 18:16:58 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-10-03 17:51:38 +0100 |
commit | 431e5ebf53327f32c9a84567b2bf4147ab64b9e3 (patch) | |
tree | 62c2d31898a6fdebc8bb1294a0b7fdc4a77ddb0d | |
parent | 7a3925c6e50d90b70e687c3c75ca3ab4c10cb245 (diff) | |
download | poky-431e5ebf53327f32c9a84567b2bf4147ab64b9e3.tar.gz |
lib/bbconfigbuild/configfragments: disable the previous builtin fragment when enabling a new one
There was a flaw in the logic that allowed multiple builtin fragments with
the same prefix to be enabled at the same time. The correct behaviour
is that only one of them should be enabled, and when enabling it
all previously enabled fragments should be removed.
The issues that this caused are further explained in
https://bugzilla.yoctoproject.org/show_bug.cgi?id=15987
[YOCTO #15987]
(From OE-Core rev: ada326e2070510fd018a6df3ce686fdce52517d2)
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/bbconfigbuild/configfragments.py | 7 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/cases/bblayers.py | 15 |
2 files changed, 15 insertions, 7 deletions
diff --git a/meta/lib/bbconfigbuild/configfragments.py b/meta/lib/bbconfigbuild/configfragments.py index 452e418c38..fec985b442 100644 --- a/meta/lib/bbconfigbuild/configfragments.py +++ b/meta/lib/bbconfigbuild/configfragments.py | |||
@@ -104,8 +104,11 @@ class ConfigFragmentsPlugin(LayerPlugin): | |||
104 | return True | 104 | return True |
105 | return False | 105 | return False |
106 | 106 | ||
107 | def fragment_prefix(self, fragmentname): | ||
108 | return fragmentname.split("/",1)[0] | ||
109 | |||
107 | def builtin_fragment_exists(self, fragmentname): | 110 | def builtin_fragment_exists(self, fragmentname): |
108 | fragment_prefix = fragmentname.split("/",1)[0] | 111 | fragment_prefix = self.fragment_prefix(fragmentname) |
109 | fragment_prefix_defs = set([f.split(':')[0] for f in self.tinfoil.config_data.getVar('OE_FRAGMENTS_BUILTIN').split()]) | 112 | fragment_prefix_defs = set([f.split(':')[0] for f in self.tinfoil.config_data.getVar('OE_FRAGMENTS_BUILTIN').split()]) |
110 | return fragment_prefix in fragment_prefix_defs | 113 | return fragment_prefix in fragment_prefix_defs |
111 | 114 | ||
@@ -128,6 +131,8 @@ class ConfigFragmentsPlugin(LayerPlugin): | |||
128 | if f in enabled_fragments: | 131 | if f in enabled_fragments: |
129 | print("Fragment {} already included in {}".format(f, args.confpath)) | 132 | print("Fragment {} already included in {}".format(f, args.confpath)) |
130 | else: | 133 | else: |
134 | # first filter out all built-in fragments with the same prefix as the one that is being enabled | ||
135 | enabled_fragments = [fragment for fragment in enabled_fragments if not(self.builtin_fragment_exists(fragment) and self.fragment_prefix(fragment) == self.fragment_prefix(f))] | ||
131 | enabled_fragments.append(f) | 136 | enabled_fragments.append(f) |
132 | return " ".join(enabled_fragments), None, 0, True | 137 | return " ".join(enabled_fragments), None, 0, True |
133 | 138 | ||
diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py index d82c5aaf37..7eb176aa04 100644 --- a/meta/lib/oeqa/selftest/cases/bblayers.py +++ b/meta/lib/oeqa/selftest/cases/bblayers.py | |||
@@ -281,11 +281,11 @@ class BitbakeConfigBuild(OESelftestTestCase): | |||
281 | 2. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set after setting | 281 | 2. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set after setting |
282 | the fragment. | 282 | the fragment. |
283 | 3. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set after setting | 283 | 3. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set after setting |
284 | the fragment with another value that overrides the first one. | 284 | the fragment with another value that replaces the first one. |
285 | 4. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is set to the previous | 285 | 4. Repeat steps 2 and 3 to verify that going back and forth between values |
286 | value after removing the second assignment (from step 3). | 286 | works. |
287 | 5. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is not set after | 287 | 5. Verify that SELFTEST_BUILTIN_FRAGMENT_VARIABLE is not set after |
288 | removing the original assignment. | 288 | removing the final assignment. |
289 | """ | 289 | """ |
290 | self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), None) | 290 | self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), None) |
291 | 291 | ||
@@ -295,10 +295,13 @@ class BitbakeConfigBuild(OESelftestTestCase): | |||
295 | runCmd('bitbake-config-build enable-fragment selftest-fragment/someothervalue') | 295 | runCmd('bitbake-config-build enable-fragment selftest-fragment/someothervalue') |
296 | self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'someothervalue') | 296 | self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'someothervalue') |
297 | 297 | ||
298 | runCmd('bitbake-config-build disable-fragment selftest-fragment/someothervalue') | 298 | runCmd('bitbake-config-build enable-fragment selftest-fragment/somevalue') |
299 | self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'somevalue') | 299 | self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'somevalue') |
300 | 300 | ||
301 | runCmd('bitbake-config-build disable-fragment selftest-fragment/somevalue') | 301 | runCmd('bitbake-config-build enable-fragment selftest-fragment/someothervalue') |
302 | self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), 'someothervalue') | ||
303 | |||
304 | runCmd('bitbake-config-build disable-fragment selftest-fragment/someothervalue') | ||
302 | self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), None) | 305 | self.assertEqual(get_bb_var('SELFTEST_BUILTIN_FRAGMENT_VARIABLE'), None) |
303 | 306 | ||
304 | def test_show_fragment(self): | 307 | def test_show_fragment(self): |