lib: configfragments: Restrict fragment file checking
PATCH 1/2 lib: configfragments: Restrict fragment file checking
The current implementation of the config fragments is too aggressive in checking files; any file in the fragment directory is checked, including hidden files or files with weird extensions. In particular, if an editor is creating temporary backup files when editing, these will be checked and will almost assuredly fail, which prevents the tool from running.
Add a filter so that only non-hidden files that end with .conf are checked.
Signed-off-by Joshua Watt <[email protected]>
--- meta/lib/bbconfigbuild/configfragments.py | 2 ++ 1 file changed, 2 insertions(+)
meta/lib/bbconfigbuild/configfragments.py +2 -0
@@ -43,6 +43,8 @@ class ConfigFragmentsPlugin(LayerPlugin): for topdir, dirs, files in os.walk(os.path.join(layerdir, fragments_path_prefix)): fragmentdir = os.path.relpath(topdir, os.path.join(layerdir, fragments_path_prefix)) for fragmentfile in sorted(files): + if fragmentfile.startswith(".") or not fragmentfile.endswith(".conf"): + continue fragmentname = os.path.normpath("/".join((layername, fragmentdir, fragmentfile.split('.')[0]))) fragmentpath = os.path.join(topdir, fragmentfile) fragmentsummary, fragmentdesc = self.get_fragment_info(fragmentpath, fragmentname)
Signature · 1 line
2.47.1
PATCH 2/2 lib: configfragements: enable/disable multiple fragements at once
Extends the 'enable-fragment' and 'disable-fragment' commands so that they accept multiple fragments at once as a convenience for the user
Signed-off-by Joshua Watt <[email protected]>
--- meta/lib/bbconfigbuild/configfragments.py | 31 +++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-)
meta/lib/bbconfigbuild/configfragments.py +17 -14
@@ -103,34 +103,37 @@ class ConfigFragmentsPlugin(LayerPlugin): """ Enable a fragment in the local build configuration """ def enable_helper(varname, origvalue, op, newlines): enabled_fragments = origvalue.split() - if args.fragmentname in enabled_fragments: - print("Fragment {} already included in {}".format(args.fragmentname, args.confpath)) - else: - enabled_fragments.append(args.fragmentname) + for f in args.fragmentname: + if f in enabled_fragments: + print("Fragment {} already included in {}".format(f, args.confpath)) + else: + enabled_fragments.append(f) return " ".join(enabled_fragments), None, 0, True - if not self.fragment_exists(args.fragmentname): - raise Exception("Fragment {} does not exist; use 'list-fragments' to see the full list.".format(args.fragmentname)) + for f in args.fragmentname: + if not self.fragment_exists(f): + raise Exception("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) if modified: - print("Fragment {} added to {}.".format(args.fragmentname, args.confpath)) + print("Fragment {} added to {}.".format(", ".join(args.fragmentname), args.confpath)) def do_disable_fragment(self, args): """ Disable a fragment in the local build configuration """ def disable_helper(varname, origvalue, op, newlines): enabled_fragments = origvalue.split() - if args.fragmentname in enabled_fragments: - enabled_fragments.remove(args.fragmentname) - else: - print("Fragment {} not currently enabled in {}".format(args.fragmentname, args.confpath)) + for f in args.fragmentname: + if f in enabled_fragments: + enabled_fragments.remove(f) + else: + print("Fragment {} not currently enabled in {}".format(f, args.confpath)) return " ".join(enabled_fragments), None, 0, True self.create_conf(args.confpath) modified = bb.utils.edit_metadata_file(args.confpath, ["OE_FRAGMENTS"], disable_helper) if modified: - print("Fragment {} removed from {}.".format(args.fragmentname, args.confpath)) + print("Fragment {} removed from {}.".format(", ".join(args.fragmentname), args.confpath)) def do_disable_all_fragments(self, args): """ Disable all fragments in the local build configuration """
@@ -151,11 +154,11 @@ 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_enable_fragment.add_argument('fragmentname', help='The name of the fragment (use list-fragments to see them)') + 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) 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') + parser_disable_fragment.add_argument('fragmentname', help='The name of the fragment', nargs='+') 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))
Signature · 1 line
2.47.1