ostree-installer: Work with skipped buildinstall
Fixes: https://pagure.io/pungi/issue/909 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
076be762ec
commit
543154d597
@ -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),
|
||||
|
@ -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)
|
||||
|
@ -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))
|
||||
|
@ -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):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user