From: Antonin Godard Date: Fri, 5 Sep 2025 12:23:57 +0000 (+0200) Subject: lib/configfragments: add a show-fragments command X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=71cd1ae6a8367f2135855a2904e8b8d4967efd99;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git lib/configfragments: add a show-fragments command 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 Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- diff --git a/meta/lib/bbconfigbuild/configfragments.py b/meta/lib/bbconfigbuild/configfragments.py index 61c33ac316..fce3301bac 100644 --- a/meta/lib/bbconfigbuild/configfragments.py +++ b/meta/lib/bbconfigbuild/configfragments.py @@ -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))