* [OE-core][PATCH 1/2] lib: configfragments: Restrict fragment file checking
@ 2024-12-20 20:41 Joshua Watt
2024-12-20 20:41 ` [OE-core][PATCH 2/2] lib: configfragements: enable/disable multiple fragements at once Joshua Watt
0 siblings, 1 reply; 2+ messages in thread
From: Joshua Watt @ 2024-12-20 20:41 UTC (permalink / raw)
To: openembedded-core; +Cc: Joshua Watt
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 <JPEWhacker@gmail.com>
---
meta/lib/bbconfigbuild/configfragments.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/meta/lib/bbconfigbuild/configfragments.py b/meta/lib/bbconfigbuild/configfragments.py
index 30cc5ece07..a0c3883399 100644
--- a/meta/lib/bbconfigbuild/configfragments.py
+++ b/meta/lib/bbconfigbuild/configfragments.py
@@ -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)
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [OE-core][PATCH 2/2] lib: configfragements: enable/disable multiple fragements at once
2024-12-20 20:41 [OE-core][PATCH 1/2] lib: configfragments: Restrict fragment file checking Joshua Watt
@ 2024-12-20 20:41 ` Joshua Watt
0 siblings, 0 replies; 2+ messages in thread
From: Joshua Watt @ 2024-12-20 20:41 UTC (permalink / raw)
To: openembedded-core; +Cc: Joshua Watt
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 <JPEWhacker@gmail.com>
---
meta/lib/bbconfigbuild/configfragments.py | 31 +++++++++++++----------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/meta/lib/bbconfigbuild/configfragments.py b/meta/lib/bbconfigbuild/configfragments.py
index a0c3883399..a4896cc734 100644
--- a/meta/lib/bbconfigbuild/configfragments.py
+++ b/meta/lib/bbconfigbuild/configfragments.py
@@ -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))
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-20 20:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-20 20:41 [OE-core][PATCH 1/2] lib: configfragments: Restrict fragment file checking Joshua Watt
2024-12-20 20:41 ` [OE-core][PATCH 2/2] lib: configfragements: enable/disable multiple fragements at once Joshua Watt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox