Message ID | 20250904-show-fragments-v1-1-ff41f5a75959@bootlin.com |
---|---|
State | New |
Headers | show |
Series | lib/configfragments: add a show-fragments command | expand |
Thanks, lgtm. Hopefully takes away some of the 'magic' behind fragments, and encourages people to start making them :) Alex On Thu, 4 Sept 2025 at 15:18, Antonin Godard <antonin.godard@bootlin.com> wrote: > > 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> > --- > meta/lib/bbconfigbuild/configfragments.py | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > 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)) > > --- > base-commit: 0a849dc7edeecb6c16a8a0fe347015d6d85e9dfd > change-id: 20250904-show-fragments-140f8a1265a1 > > Best regards, > -- > Antonin Godard <antonin.godard@bootlin.com> >
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))
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> --- meta/lib/bbconfigbuild/configfragments.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- base-commit: 0a849dc7edeecb6c16a8a0fe347015d6d85e9dfd change-id: 20250904-show-fragments-140f8a1265a1 Best regards, -- Antonin Godard <antonin.godard@bootlin.com>