diff mbox series

[2/6] bbconfigbuild/configfragments.py: replace fragment_exists() with a more generic get_fragment()

Message ID 20251029120835.4075555-2-alex.kanavin@gmail.com
State New
Headers show
Series [1/6] bbconfigbuild/configfragments.py: run discover_fragments() only once when enabling them | expand

Commit Message

Alexander Kanavin Oct. 29, 2025, 12:08 p.m. UTC
From: Alexander Kanavin <alex@linutronix.de>

This can be used to get fragment information by its name (or None,
if there's no fragment), rather than just check for its existence.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/lib/bbconfigbuild/configfragments.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/meta/lib/bbconfigbuild/configfragments.py b/meta/lib/bbconfigbuild/configfragments.py
index 60cdced555c..59e760f2909 100644
--- a/meta/lib/bbconfigbuild/configfragments.py
+++ b/meta/lib/bbconfigbuild/configfragments.py
@@ -97,12 +97,12 @@  class ConfigFragmentsPlugin(LayerPlugin):
                     print_fragment(f, args.verbose, is_enabled=False)
             print('')
 
-    def fragment_exists(self, fragmentname, fragments):
+    def get_fragment(self, fragmentname, fragments):
         for layername, layerdata in fragments.items():
             for f in layerdata['fragments']:
               if f['name'] == fragmentname:
-                  return True
-        return False
+                  return f
+        return None
 
     def fragment_prefix(self, fragmentname):
         return fragmentname.split("/",1)[0]
@@ -138,7 +138,7 @@  class ConfigFragmentsPlugin(LayerPlugin):
 
         fragments = self.discover_fragments()
         for f in args.fragmentname:
-            if not self.fragment_exists(f, fragments) and not self.builtin_fragment_exists(f):
+            if not self.get_fragment(f, fragments) and not self.builtin_fragment_exists(f):
                 raise Exception("Fragment {} does not exist; use 'list-fragments' to see the full list.".format(f))
 
         self.create_conf(args.confpath)