Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Joshua Watt <jpewhacker@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Joshua Watt <JPEWhacker@gmail.com>
Subject: [OE-core][PATCH 2/2] lib: configfragements: enable/disable multiple fragements at once
Date: Fri, 20 Dec 2024 13:41:45 -0700	[thread overview]
Message-ID: <20241220204145.2636370-2-JPEWhacker@gmail.com> (raw)
In-Reply-To: <20241220204145.2636370-1-JPEWhacker@gmail.com>

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



      reply	other threads:[~2024-12-20 20:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241220204145.2636370-2-JPEWhacker@gmail.com \
    --to=jpewhacker@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox