From 6ec151cde266b6e12a03afdf98173ec1e86ab78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 11 Feb 2016 10:21:56 +0100 Subject: [PATCH] [live-media] Use install tree from another variant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lubomír Sedlář --- doc/configuration.rst | 1 + pungi/phases/livemedia_phase.py | 19 ++++++++++--- tests/test_livemediaphase.py | 49 ++++++++++++++++++++++++++++++++- 3 files changed, 64 insertions(+), 5 deletions(-) diff --git a/doc/configuration.rst b/doc/configuration.rst index 22517746..2c700e74 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -674,6 +674,7 @@ Live Media Settings * ``repo`` (*[str]*) -- external repo * ``repo_from`` (*[str]*) -- list of variants to take extra repos from * ``title`` (*str*) + * ``install_tree_from`` (*str*) -- variant to take install tree from Image Build Settings diff --git a/pungi/phases/livemedia_phase.py b/pungi/phases/livemedia_phase.py index ef544822..4a2476b2 100644 --- a/pungi/phases/livemedia_phase.py +++ b/pungi/phases/livemedia_phase.py @@ -65,6 +65,20 @@ class LiveMediaPhase(PhaseBase): return '%s.%s' % (self.compose.compose_date, self.compose.compose_respin) return image_conf.get('release', None) + def _get_install_tree(self, image_conf, variant): + if 'install_tree_from' in image_conf: + variant_uid = image_conf['install_tree_from'] + try: + variant = self.compose.variants[variant_uid] + except KeyError: + raise RuntimeError( + 'There is no variant %s to get repo from when building live media for %s.' + % (variant_uid, variant.uid)) + return translate_path( + self.compose, + self.compose.paths.compose.os_tree('$arch', variant) + ) + def run(self): for variant in self.compose.get_variants(): arches = set([x for x in variant.arches if x != 'src']) @@ -82,10 +96,7 @@ class LiveMediaPhase(PhaseBase): 'name': image_conf['name'], 'title': image_conf.get('title'), 'repo': self._get_repos(image_conf, variant), - 'install_tree': translate_path( - self.compose, - self.compose.paths.compose.os_tree('$arch', variant, create_dir=False) - ), + 'install_tree': self._get_install_tree(image_conf, variant), 'version': image_conf['version'], } self.pool.add(LiveMediaThread(self.pool)) diff --git a/tests/test_livemediaphase.py b/tests/test_livemediaphase.py index e844a5ad..384f3784 100755 --- a/tests/test_livemediaphase.py +++ b/tests/test_livemediaphase.py @@ -103,6 +103,52 @@ class TestLiveMediaPhase(unittest.TestCase): 'version': 'Rawhide', }))]) + @mock.patch('pungi.phases.livemedia_phase.ThreadPool') + def test_live_media_non_existing_install_tree(self, ThreadPool): + compose = _DummyCompose({ + 'live_media': { + '^Server$': [ + { + 'target': 'f24', + 'kickstart': 'file.ks', + 'ksurl': 'git://example.com/repo.git', + 'name': 'Fedora Server Live', + 'version': 'Rawhide', + 'install_tree_from': 'Missing', + } + ] + }, + 'koji_profile': 'koji', + }) + + phase = LiveMediaPhase(compose) + + with self.assertRaisesRegexp(RuntimeError, r'no.+Missing.+when building.+Server'): + phase.run() + + @mock.patch('pungi.phases.livemedia_phase.ThreadPool') + def test_live_media_non_existing_repo(self, ThreadPool): + compose = _DummyCompose({ + 'live_media': { + '^Server$': [ + { + 'target': 'f24', + 'kickstart': 'file.ks', + 'ksurl': 'git://example.com/repo.git', + 'name': 'Fedora Server Live', + 'version': 'Rawhide', + 'repo_from': 'Missing', + } + ] + }, + 'koji_profile': 'koji', + }) + + phase = LiveMediaPhase(compose) + + with self.assertRaisesRegexp(RuntimeError, r'no.+Missing.+when building.+Server'): + phase.run() + @mock.patch('pungi.phases.livemedia_phase.resolve_git_url') @mock.patch('pungi.phases.livemedia_phase.ThreadPool') def test_live_media_full(self, ThreadPool, resolve_git_url): @@ -123,6 +169,7 @@ class TestLiveMediaPhase(unittest.TestCase): 'ksversion': '24', 'release': None, 'version': 'Rawhide', + 'install_tree_from': 'Everything', } ] } @@ -151,7 +198,7 @@ class TestLiveMediaPhase(unittest.TestCase): 'skip_tag': True, 'target': 'f24', 'title': 'Custom Title', - 'install_tree': '/ostree/$arch/Server', + 'install_tree': '/ostree/$arch/Everything', 'version': 'Rawhide', }))])