From 5346e000f0859c6305c8ffbfb9517cfab8c6f710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 27 Aug 2018 12:55:34 +0200 Subject: [PATCH] Create non-bootable ISO for variant without buildinstall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the configuration specifically excludes a variant from buildinstall, but does not also disable ISO creation, we should just create a non-bootable ISO instead of reporting a warning. JIRA: COMPOSE-2887 Signed-off-by: Lubomír Sedlář --- pungi/phases/createiso.py | 4 +++ tests/test_createiso_phase.py | 63 +++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/pungi/phases/createiso.py b/pungi/phases/createiso.py index 328b543b..40ca27a0 100644 --- a/pungi/phases/createiso.py +++ b/pungi/phases/createiso.py @@ -59,6 +59,10 @@ class CreateisoPhase(PhaseLoggerMixin, PhaseBase): return False if variant.type != "variant": return False + skip = get_arch_variant_data(self.compose.conf, "buildinstall_skip", arch, variant) + if skip == [True]: + # Buildinstall is skipped for this tree. Can't create a bootable ISO. + return False return self.compose.conf["bootable"] def run(self): diff --git a/tests/test_createiso_phase.py b/tests/test_createiso_phase.py index c3597820..81a4d217 100644 --- a/tests/test_createiso_phase.py +++ b/tests/test_createiso_phase.py @@ -272,6 +272,69 @@ class CreateisoPhaseTest(helpers.PungiTestCase): 'src'))] ) + @mock.patch('pungi.createiso.write_script') + @mock.patch('pungi.phases.createiso.prepare_iso') + @mock.patch('pungi.phases.createiso.split_iso') + @mock.patch('pungi.phases.createiso.ThreadPool') + def test_bootable_product_but_not_variant( + self, ThreadPool, split_iso, prepare_iso, write_script + ): + compose = helpers.DummyCompose(self.topdir, { + 'release_short': 'test', + 'release_version': '1.0', + 'release_is_layered': False, + 'buildinstall_method': 'lorax', + 'bootable': True, + 'createiso_skip': [], + 'buildinstall_skip': [('Server', {'*': True})], + }) + helpers.touch(os.path.join( + compose.paths.compose.os_tree('x86_64', compose.variants['Server']), + 'dummy.rpm')) + disc_data = mock.Mock() + split_iso.return_value = [disc_data] + prepare_iso.return_value = 'dummy-graft-points' + + pool = ThreadPool.return_value + + mock_bi = mock.Mock(succeeded=lambda v, a: False) + + phase = createiso.CreateisoPhase(compose, mock_bi) + phase.logger = mock.Mock() + phase.run() + + self.maxDiff = None + self.assertItemsEqual( + prepare_iso.call_args_list, + [mock.call(compose, 'x86_64', compose.variants['Server'], + disc_count=1, disc_num=1, split_iso_data=disc_data)]) + self.assertItemsEqual( + split_iso.call_args_list, + [mock.call(compose, 'x86_64', compose.variants['Server'], no_split=False, logger=phase.logger)]) + self.assertEqual(len(pool.add.call_args_list), 1) + self.assertItemsEqual( + [x[0][0] for x in write_script.call_args_list], + [CreateIsoOpts(output_dir='%s/compose/Server/x86_64/iso' % self.topdir, + iso_name='image-name', + volid='test-1.0 Server.x86_64', + graft_points='dummy-graft-points', + arch='x86_64', + supported=True, + jigdo_dir='%s/compose/Server/x86_64/jigdo' % self.topdir, + os_tree='%s/compose/Server/x86_64/os' % self.topdir)]) + self.assertItemsEqual( + pool.queue_put.call_args_list, + [mock.call((compose, + {'iso_path': '%s/compose/Server/x86_64/iso/image-name' % self.topdir, + 'bootable': False, + 'cmd': ['bash', self.topdir + '/work/x86_64/tmp-Server/createiso-image-name.sh'], + 'label': '', + 'disc_num': 1, + 'disc_count': 1}, + compose.variants['Server'], + 'x86_64'))] + ) + class CreateisoThreadTest(helpers.PungiTestCase):