configfragments.py: Correct the help for enable-fragment
PATCH v2 1/3 configfragments.py: Correct the help for enable-fragment
The help entry for --quiet had been added to list-fragments rather than enable-fragment.
Due to the fact that --quiet is a global option, this actually adds a dummy --quiet option as it would otherwise hide the global option, but would never be set since any --quiet argument would already have been parsed when this option is parsed.
---
PATCHv2: No changes.
meta/lib/bbconfigbuild/configfragments.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
meta/lib/bbconfigbuild/configfragments.py +3 -1
@@ -197,7 +197,9 @@ class ConfigFragmentsPlugin(LayerPlugin): parser_enable_fragment = self.add_command(sp, 'enable-fragment', self.do_enable_fragment, parserecipes=False) parser_enable_fragment.add_argument("--confpath", default=default_confpath, help='Configuration file which contains a list of enabled fragments (default is {}).'.format(default_confpath)) - parser_list_fragments.add_argument('--quiet', '-q', action='store_true', help='Do not print descriptions of the newly enabled fragments') + # Store the quiet argument in quiet_dummy. This is because --quiet is a + # global option and this one is only here to add an entry for --help. + parser_enable_fragment.add_argument('--quiet', '-q', action='store_true', dest='quiet_dummy', help='Do not print descriptions of the newly enabled fragments') parser_enable_fragment.add_argument('fragmentname', help='The name of the fragment (use list-fragments to see them)', nargs='+') parser_disable_fragment = self.add_command(sp, 'disable-fragment', self.do_disable_fragment, parserecipes=False)
PATCH v2 2/3 configfragments.py: Make list-fragments fail early
If a fragment has not been configured correctly, make list-fragments fail with an error before it has output information about any built-in fragments.
---
PATCHv2: No changes.
meta/lib/bbconfigbuild/configfragments.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
meta/lib/bbconfigbuild/configfragments.py +3 -1
@@ -75,11 +75,13 @@ class ConfigFragmentsPlugin(LayerPlugin): print('{}\tSets {} = "{}"'.format(f, builtin_dict[prefix], value)) print('') + allfragments = self.discover_fragments() + all_enabled_fragments = (self.tinfoil.config_data.getVar('OE_FRAGMENTS') or "").split() all_builtin_fragments = (self.tinfoil.config_data.getVar('OE_FRAGMENTS_BUILTIN') or "").split() print_builtin_fragments(all_builtin_fragments, all_enabled_fragments) - for layername, layerdata in self.discover_fragments().items(): + for layername, layerdata in allfragments.items(): layerdir = layerdata['layerdir'] fragments = layerdata['fragments'] enabled_fragments = [f for f in fragments if f['name'] in all_enabled_fragments]
PATCH v2 3/3 configfragments.py: Improve reporting of errors
In reply to Peter KjellerstedtUse bb.fatal() to report errors. This makes for a nicer experience for the user.
---
PATCHv2: Only change errors to use bb.fatal(). Leave warnings as they
were.
meta/lib/bbconfigbuild/configfragments.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
meta/lib/bbconfigbuild/configfragments.py +3 -3
@@ -28,10 +28,10 @@ class ConfigFragmentsPlugin(LayerPlugin): summary = d.getVar('BB_CONF_FRAGMENT_SUMMARY') description = d.getVar('BB_CONF_FRAGMENT_DESCRIPTION') if not summary: - raise Exception('Please add a one-line summary as BB_CONF_FRAGMENT_SUMMARY = \"...\" variable at the beginning of {}'.format(path)) + bb.fatal('Please add a one-line summary as BB_CONF_FRAGMENT_SUMMARY = "..." variable at the beginning of {}'.format(path)) if not description: - raise Exception('Please add a description as BB_CONF_FRAGMENT_DESCRIPTION = \"...\" variable at the beginning of {}'.format(path)) + bb.fatal('Please add a description as BB_CONF_FRAGMENT_DESCRIPTION = "..." variable at the beginning of {}'.format(path)) return summary, description
@@ -141,7 +141,7 @@ class ConfigFragmentsPlugin(LayerPlugin): fragments = self.discover_fragments() for f in args.fragmentname: 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)) + bb.fatal("Fragment {} does not exist; use 'list-fragments' to see the full list.".format(f)) self.create_conf(args.confpath) modified = bb.utils.edit_metadata_file(args.confpath, ["OE_FRAGMENTS"], enable_helper)