diff mbox series

[bitbake-devel,V4,3/3] lib/bb/parse/ast.py: error out for internal fragment in case of a previous value

Message ID 20251120073324.136238-3-Qi.Chen@windriver.com
State New
Headers show
Series [bitbake-devel,V4,1/3] lib/bb/cooker.py: fix reset in case of different featureset | expand

Commit Message

Chen, Qi Nov. 20, 2025, 7:33 a.m. UTC
From: Chen Qi <Qi.Chen@windriver.com>

When an internal fragment is enabled, and there's already a value
for the corresponding variable, we should error out to avoid any
confusion.

For example, when 'machine/qemux86-64' fragement is enabled, and
we get some "MACHINE = xxx" in local.conf or env, we should error
out and recomment users to use 'bitbake-config-build disable-fragment'.

We should be tolerating '??=' assignments. For example, DISTRO defaults
to "nodistro" in oe-core layer, and when 'distro/poky" fragment is enabled,
there should be no confusion.

Fixes [YOCTO #16060]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 lib/bb/parse/ast.py | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/lib/bb/parse/ast.py b/lib/bb/parse/ast.py
index bf9bd4f55..00e3615e6 100644
--- a/lib/bb/parse/ast.py
+++ b/lib/bb/parse/ast.py
@@ -367,6 +367,12 @@  class AddFragmentsNode(AstNode):
         def check_and_set_builtin_fragment(fragment, data, builtin_fragments):
             prefix, value = fragment.split('/', 1)
             if prefix in builtin_fragments.keys():
+                if data.getVar(builtin_fragments[prefix], noweakdefault=True) != None:
+                    bb.fatal(
+                        ("A builtin fragment '%s' is used while %s has already got an assignment.\n"
+                         "Please either disable the fragment or remove the value assignment.\n"
+                         "To disable the fragment, use 'bitbake-config-build disable-fragment %s'."
+                         ) % (fragment, builtin_fragments[prefix], fragment))
                 fragment_history = data.varhistory.variable(self.fragments_variable)
                 loginfo={}
                 for fh in fragment_history[::-1]: