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')