diff --git a/bin/pungi-config-validate b/bin/pungi-config-validate index 597222af..815d14fe 100755 --- a/bin/pungi-config-validate +++ b/bin/pungi-config-validate @@ -103,7 +103,7 @@ def run(config, topdir, has_old): pungi.phases.GatherPhase(compose, pkgset_phase), pungi.phases.ExtraFilesPhase(compose, pkgset_phase), pungi.phases.CreaterepoPhase(compose), - pungi.phases.OstreeInstallerPhase(compose), + pungi.phases.OstreeInstallerPhase(compose, buildinstall_phase), pungi.phases.OSTreePhase(compose), pungi.phases.ProductimgPhase(compose, pkgset_phase), pungi.phases.CreateisoPhase(compose, buildinstall_phase), diff --git a/bin/pungi-koji b/bin/pungi-koji index 00ab6064..75b7fc6b 100755 --- a/bin/pungi-koji +++ b/bin/pungi-koji @@ -290,7 +290,7 @@ def run_compose(compose, create_latest_link=True, latest_link_status=None): gather_phase = pungi.phases.GatherPhase(compose, pkgset_phase) extrafiles_phase = pungi.phases.ExtraFilesPhase(compose, pkgset_phase) createrepo_phase = pungi.phases.CreaterepoPhase(compose) - ostree_installer_phase = pungi.phases.OstreeInstallerPhase(compose) + ostree_installer_phase = pungi.phases.OstreeInstallerPhase(compose, buildinstall_phase) ostree_phase = pungi.phases.OSTreePhase(compose) productimg_phase = pungi.phases.ProductimgPhase(compose, pkgset_phase) createiso_phase = pungi.phases.CreateisoPhase(compose, buildinstall_phase) diff --git a/pungi/phases/ostree_installer.py b/pungi/phases/ostree_installer.py index 190e3fe4..adf5bc9f 100644 --- a/pungi/phases/ostree_installer.py +++ b/pungi/phases/ostree_installer.py @@ -16,9 +16,10 @@ from ..wrappers import kojiwrapper, iso, lorax, scm class OstreeInstallerPhase(PhaseLoggerMixin, ConfigGuardedPhase): name = 'ostree_installer' - def __init__(self, compose): + def __init__(self, compose, buildinstall_phase): super(OstreeInstallerPhase, self).__init__(compose) self.pool = ThreadPool(logger=self.logger) + self.bi = buildinstall_phase def validate(self): errors = [] @@ -27,14 +28,15 @@ class OstreeInstallerPhase(PhaseLoggerMixin, ConfigGuardedPhase): except ValueError as exc: errors = exc.message.split('\n') - for variant in self.compose.get_variants(): - for arch in variant.arches: - conf = util.get_arch_variant_data(self.compose.conf, self.name, - arch, variant) - if conf and not variant.is_empty: - errors.append('Can not generate ostree installer for %s.%s: ' - 'it has buildinstall running already and the ' - 'files would clash.' % (variant.uid, arch)) + if not self.bi._skipped: + for variant in self.compose.get_variants(): + for arch in variant.arches: + conf = util.get_arch_variant_data(self.compose.conf, self.name, + arch, variant) + if conf and not variant.is_empty: + errors.append('Can not generate ostree installer for %s.%s: ' + 'it has buildinstall running already and the ' + 'files would clash.' % (variant.uid, arch)) if errors: raise ValueError('\n'.join(errors)) diff --git a/tests/test_ostree_installer_phase.py b/tests/test_ostree_installer_phase.py index e9b58006..cc0fbdf8 100644 --- a/tests/test_ostree_installer_phase.py +++ b/tests/test_ostree_installer_phase.py @@ -33,7 +33,7 @@ class OstreeInstallerPhaseTest(helpers.PungiTestCase): pool = ThreadPool.return_value - phase = ostree.OstreeInstallerPhase(compose) + phase = ostree.OstreeInstallerPhase(compose, mock.Mock()) phase.run() self.assertEqual(len(pool.add.call_args_list), 1) @@ -45,9 +45,35 @@ class OstreeInstallerPhaseTest(helpers.PungiTestCase): compose = helpers.DummyCompose(self.topdir, {}) compose.just_phases = None compose.skip_phases = [] - phase = ostree.OstreeInstallerPhase(compose) + phase = ostree.OstreeInstallerPhase(compose, mock.Mock()) self.assertTrue(phase.skip()) + def test_validate_conflict_with_buildinstall(self): + compose = helpers.DummyCompose(self.topdir, { + 'ostree_installer': [ + ('^Server$', {'x86_64': mock.Mock()}) + ], + }) + + phase = ostree.OstreeInstallerPhase(compose, mock.Mock(_skipped=False)) + with self.assertRaises(ValueError) as ctx: + phase.validate() + + self.assertEqual(str(ctx.exception), + 'Can not generate ostree installer for Server.x86_64:' + ' it has buildinstall running already and the files' + ' would clash.') + + def test_validate_buildinstall_skipped(self): + compose = helpers.DummyCompose(self.topdir, { + 'ostree_installer': [ + ('^Server$', {'x86_64': mock.Mock()}) + ], + }) + + phase = ostree.OstreeInstallerPhase(compose, mock.Mock(_skipped=True)) + phase.validate() + class OstreeThreadTest(helpers.PungiTestCase):