From 9a3d04c305bea1d759a07c4a17500376dbb01265 Mon Sep 17 00:00:00 2001 From: Pavel Holica Date: Thu, 29 Jun 2017 12:46:57 +0200 Subject: [PATCH] comps_filter: Filter environments by arch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the environment has arch attribute, the environment should be removed from the file on all other arches. This mirrors similar behaviour for groups and packages. Signed-off-by: Lubomír Sedlář --- bin/comps_filter | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/comps_filter b/bin/comps_filter index 0195a5e4..0a678eed 100755 --- a/bin/comps_filter +++ b/bin/comps_filter @@ -52,6 +52,14 @@ class CompsFilter(object): """ self._filter_elements_by_arch("/comps/group", arch, only_arch) + def filter_environments(self, arch, only_arch=False): + """ + Filter environments according to arch. + If only_arch is set, then only environments for the specified arch are preserved. + Multiple arches separated by comma can be specified in the XML. + """ + self._filter_elements_by_arch("/comps/environment", arch, only_arch) + def filter_category_groups(self): """ Remove undefined groups from categories. @@ -158,6 +166,8 @@ def main(): help="keep only arch groups, remove the rest") parser.add_argument("--arch-only-packages", default=False, action="store_true", help="keep only arch packages, remove the rest") + parser.add_argument("--arch-only-environments", default=False, action="store_true", + help="keep only arch environments, remove the rest") parser.add_argument("--remove-categories", default=False, action="store_true", help="remove all categories") parser.add_argument("--remove-langpacks", default=False, action="store_true", @@ -183,6 +193,7 @@ def main(): f = CompsFilter(file_obj, reindent=not opts.no_reindent) f.filter_packages(opts.arch, opts.arch_only_packages) f.filter_groups(opts.arch, opts.arch_only_groups) + f.filter_environments(opts.arch, opts.arch_only_environments) if not opts.no_cleanup: f.remove_empty_groups(keep_empty=opts.keep_empty_group)