From 8bc65a8be5ac1f41eb1e32ab03814112e84a1970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Tue, 21 Feb 2017 15:34:04 +0100 Subject: [PATCH] comps: Filter comps groups for optional variants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The optional variant can defined by just adding has_optional=True into variant xml. In such case it has no comps groups and Pungi would copy the original file unmodified. This leads to extra packages being pulled into the optional variant. In this case the correct solution is to filter the comps and remove all groups. Signed-off-by: Lubomír Sedlář --- pungi/phases/init.py | 9 +++++++-- tests/test_initphase.py | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pungi/phases/init.py b/pungi/phases/init.py index 44fc87b8..1b5c2d5f 100644 --- a/pungi/phases/init.py +++ b/pungi/phases/init.py @@ -46,8 +46,11 @@ class InitPhase(PhaseBase): # write variant comps for variant in self.compose.get_variants(): for arch in variant.arches: - if variant.groups: - # The variant lists only some groups, run filter. + if variant.groups or variant.type == 'optional': + # The variant lists only some groups, run filter. Other + # option is that it's optional variant, in which case + # we want to filter everything (unless there was + # explicit list in which case it will be used). write_variant_comps(self.compose, arch, variant) else: # The variant does not mention any groups, copy @@ -127,6 +130,8 @@ def write_variant_comps(compose, arch, variant): def copy_variant_comps(compose, arch, variant): global_comps = compose.paths.work.comps(arch="global") comps_file = compose.paths.work.comps(arch=arch, variant=variant) + msg = "Copying original comps file (arch: %s, variant: %s): %s" % (arch, variant, comps_file) + compose.log_debug(msg) shutil.copy(global_comps, comps_file) diff --git a/tests/test_initphase.py b/tests/test_initphase.py index e7f4eff3..c5faf258 100644 --- a/tests/test_initphase.py +++ b/tests/test_initphase.py @@ -24,6 +24,7 @@ class TestInitPhase(PungiTestCase): def test_run(self, write_prepopulate, write_variant, create_comps, write_arch, write_global): compose = DummyCompose(self.topdir, {}) compose.has_comps = True + compose.setup_optional() phase = init.InitPhase(compose) phase.run() @@ -38,7 +39,8 @@ class TestInitPhase(PungiTestCase): mock.call(compose, 'amd64', compose.variants['Server']), mock.call(compose, 'amd64', compose.variants['Client']), mock.call(compose, 'x86_64', compose.variants['Everything']), - mock.call(compose, 'amd64', compose.variants['Everything'])]) + mock.call(compose, 'amd64', compose.variants['Everything']), + mock.call(compose, 'x86_64', compose.all_variants['Server-optional'])]) @mock.patch('pungi.phases.init.copy_variant_comps') @mock.patch('pungi.phases.init.write_global_comps')