[live-media] Use install tree from another variant

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-02-11 10:21:56 +01:00
parent 0c4bd42f80
commit 6ec151cde2
3 changed files with 64 additions and 5 deletions

View File

@ -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

View File

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

View File

@ -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',
}))])