]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
lib/configfragments: add a show-fragments command
authorAntonin Godard <antonin.godard@bootlin.com>
Fri, 5 Sep 2025 12:23:57 +0000 (14:23 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 8 Sep 2025 17:02:37 +0000 (18:02 +0100)
We can print information on fragments (name, location, description,
etc.), but not their content.

Add a show-fragment command to do that. It can be used as follows:

  $ bitbake-config-build show-fragment core/yocto/sstate-mirror-cdn

And prints:

  .../meta/conf/fragments/yocto/sstate-mirror-cdn.conf:

  BB_CONF_FRAGMENT_SUMMARY = "Use prebuilt sstate artifacts for standard Yocto build configurations."
  BB_CONF_FRAGMENT_DESCRIPTION = "The Yocto Project has prebuilt artefacts available for standard build configurations. \
  ...

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/bbconfigbuild/configfragments.py

index 61c33ac316109f4b85014d01f2bd53f73148d96a..fce3301bac971d3cd4f0cca771ab417ed96f6648 100644 (file)
@@ -156,6 +156,18 @@ class ConfigFragmentsPlugin(LayerPlugin):
         if modified:
             print("Fragment {} removed from {}.".format(", ".join(args.fragmentname), args.confpath))
 
+    def do_show_fragment(self, args):
+        """ Show the content of a fragment """
+        for layername, layerdata in self.discover_fragments().items():
+            fragments = layerdata['fragments']
+            for fragment in fragments:
+                if fragment['name'] == args.fragmentname:
+                    print(f"{fragment['path']}:")
+                    print()
+                    with open(fragment['path']) as fd:
+                        print(fd.read())
+                    return
+
     def do_disable_all_fragments(self, args):
         """ Disable all fragments in the local build configuration """
         def disable_all_helper(varname, origvalue, op, newlines):
@@ -181,5 +193,8 @@ class ConfigFragmentsPlugin(LayerPlugin):
         parser_disable_fragment.add_argument("--confpath", default=default_confpath, help='Configuration file which contains a list of enabled fragments (default is {}).'.format(default_confpath))
         parser_disable_fragment.add_argument('fragmentname', help='The name of the fragment', nargs='+')
 
+        parser_show_fragment = self.add_command(sp, 'show-fragment', self.do_show_fragment, parserecipes=False)
+        parser_show_fragment.add_argument('fragmentname', help='The name of the fragment')
+
         parser_disable_all = self.add_command(sp, 'disable-all-fragments', self.do_disable_all_fragments, parserecipes=False)
         parser_disable_all.add_argument("--confpath", default=default_confpath, help='Configuration file which contains a list of enabled fragments (default is {}).'.format(default_confpath))