diff options
author | Joshua Watt <jpewhacker@gmail.com> | 2024-12-20 13:41:45 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-01-08 12:37:20 +0000 |
commit | 5cef6cbe2d95d8ead8122bfea4d12ccf3c43dceb (patch) | |
tree | 935d935095cbb6a4a63a63c7955984573fe7094f | |
parent | 9054345fb8d20bd7859a936ef96fd16c17bf1caa (diff) | |
download | poky-5cef6cbe2d95d8ead8122bfea4d12ccf3c43dceb.tar.gz |
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
(From OE-Core rev: 50c3cdb3a3b9c7daa55ff26d302d95e5f350e4d2)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/bbconfigbuild/configfragments.py | 31 |
1 files 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): | |||
103 | """ Enable a fragment in the local build configuration """ | 103 | """ Enable a fragment in the local build configuration """ |
104 | def enable_helper(varname, origvalue, op, newlines): | 104 | def enable_helper(varname, origvalue, op, newlines): |
105 | enabled_fragments = origvalue.split() | 105 | enabled_fragments = origvalue.split() |
106 | if args.fragmentname in enabled_fragments: | 106 | for f in args.fragmentname: |
107 | print("Fragment {} already included in {}".format(args.fragmentname, args.confpath)) | 107 | if f in enabled_fragments: |
108 | else: | 108 | print("Fragment {} already included in {}".format(f, args.confpath)) |
109 | enabled_fragments.append(args.fragmentname) | 109 | else: |
110 | enabled_fragments.append(f) | ||
110 | return " ".join(enabled_fragments), None, 0, True | 111 | return " ".join(enabled_fragments), None, 0, True |
111 | 112 | ||
112 | if not self.fragment_exists(args.fragmentname): | 113 | for f in args.fragmentname: |
113 | raise Exception("Fragment {} does not exist; use 'list-fragments' to see the full list.".format(args.fragmentname)) | 114 | if not self.fragment_exists(f): |
115 | raise Exception("Fragment {} does not exist; use 'list-fragments' to see the full list.".format(f)) | ||
114 | 116 | ||
115 | self.create_conf(args.confpath) | 117 | self.create_conf(args.confpath) |
116 | modified = bb.utils.edit_metadata_file(args.confpath, ["OE_FRAGMENTS"], enable_helper) | 118 | modified = bb.utils.edit_metadata_file(args.confpath, ["OE_FRAGMENTS"], enable_helper) |
117 | if modified: | 119 | if modified: |
118 | print("Fragment {} added to {}.".format(args.fragmentname, args.confpath)) | 120 | print("Fragment {} added to {}.".format(", ".join(args.fragmentname), args.confpath)) |
119 | 121 | ||
120 | def do_disable_fragment(self, args): | 122 | def do_disable_fragment(self, args): |
121 | """ Disable a fragment in the local build configuration """ | 123 | """ Disable a fragment in the local build configuration """ |
122 | def disable_helper(varname, origvalue, op, newlines): | 124 | def disable_helper(varname, origvalue, op, newlines): |
123 | enabled_fragments = origvalue.split() | 125 | enabled_fragments = origvalue.split() |
124 | if args.fragmentname in enabled_fragments: | 126 | for f in args.fragmentname: |
125 | enabled_fragments.remove(args.fragmentname) | 127 | if f in enabled_fragments: |
126 | else: | 128 | enabled_fragments.remove(f) |
127 | print("Fragment {} not currently enabled in {}".format(args.fragmentname, args.confpath)) | 129 | else: |
130 | print("Fragment {} not currently enabled in {}".format(f, args.confpath)) | ||
128 | return " ".join(enabled_fragments), None, 0, True | 131 | return " ".join(enabled_fragments), None, 0, True |
129 | 132 | ||
130 | self.create_conf(args.confpath) | 133 | self.create_conf(args.confpath) |
131 | modified = bb.utils.edit_metadata_file(args.confpath, ["OE_FRAGMENTS"], disable_helper) | 134 | modified = bb.utils.edit_metadata_file(args.confpath, ["OE_FRAGMENTS"], disable_helper) |
132 | if modified: | 135 | if modified: |
133 | print("Fragment {} removed from {}.".format(args.fragmentname, args.confpath)) | 136 | print("Fragment {} removed from {}.".format(", ".join(args.fragmentname), args.confpath)) |
134 | 137 | ||
135 | def do_disable_all_fragments(self, args): | 138 | def do_disable_all_fragments(self, args): |
136 | """ Disable all fragments in the local build configuration """ | 139 | """ Disable all fragments in the local build configuration """ |
@@ -151,11 +154,11 @@ class ConfigFragmentsPlugin(LayerPlugin): | |||
151 | 154 | ||
152 | parser_enable_fragment = self.add_command(sp, 'enable-fragment', self.do_enable_fragment, parserecipes=False) | 155 | parser_enable_fragment = self.add_command(sp, 'enable-fragment', self.do_enable_fragment, parserecipes=False) |
153 | parser_enable_fragment.add_argument("--confpath", default=default_confpath, help='Configuration file which contains a list of enabled fragments (default is {}).'.format(default_confpath)) | 156 | parser_enable_fragment.add_argument("--confpath", default=default_confpath, help='Configuration file which contains a list of enabled fragments (default is {}).'.format(default_confpath)) |
154 | parser_enable_fragment.add_argument('fragmentname', help='The name of the fragment (use list-fragments to see them)') | 157 | parser_enable_fragment.add_argument('fragmentname', help='The name of the fragment (use list-fragments to see them)', nargs='+') |
155 | 158 | ||
156 | parser_disable_fragment = self.add_command(sp, 'disable-fragment', self.do_disable_fragment, parserecipes=False) | 159 | parser_disable_fragment = self.add_command(sp, 'disable-fragment', self.do_disable_fragment, parserecipes=False) |
157 | parser_disable_fragment.add_argument("--confpath", default=default_confpath, help='Configuration file which contains a list of enabled fragments (default is {}).'.format(default_confpath)) | 160 | parser_disable_fragment.add_argument("--confpath", default=default_confpath, help='Configuration file which contains a list of enabled fragments (default is {}).'.format(default_confpath)) |
158 | parser_disable_fragment.add_argument('fragmentname', help='The name of the fragment') | 161 | parser_disable_fragment.add_argument('fragmentname', help='The name of the fragment', nargs='+') |
159 | 162 | ||
160 | parser_disable_all = self.add_command(sp, 'disable-all-fragments', self.do_disable_all_fragments, parserecipes=False) | 163 | parser_disable_all = self.add_command(sp, 'disable-all-fragments', self.do_disable_all_fragments, parserecipes=False) |
161 | parser_disable_all.add_argument("--confpath", default=default_confpath, help='Configuration file which contains a list of enabled fragments (default is {}).'.format(default_confpath)) | 164 | parser_disable_all.add_argument("--confpath", default=default_confpath, help='Configuration file which contains a list of enabled fragments (default is {}).'.format(default_confpath)) |