image-build: Use install_tree from parent for nested variants
Buildinstall only runs for top-level variants. Addons, optionals and integrated layered products must reuse install tree from their parent, because otherwise there would be no boot.iso. Fixes: #472 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
c338219ef0
commit
721932a573
@ -530,10 +530,6 @@ class ComposePaths(object):
|
|||||||
@param symlink_to=None
|
@param symlink_to=None
|
||||||
@param relative=False
|
@param relative=False
|
||||||
"""
|
"""
|
||||||
# skip optional and addons
|
|
||||||
if variant.type != "variant":
|
|
||||||
return None
|
|
||||||
|
|
||||||
path = os.path.join(self.topdir('%(arch)s', variant, create_dir=False, relative=relative),
|
path = os.path.join(self.topdir('%(arch)s', variant, create_dir=False, relative=relative),
|
||||||
"images")
|
"images")
|
||||||
if symlink_to:
|
if symlink_to:
|
||||||
|
@ -28,6 +28,11 @@ class ImageBuildPhase(base.PhaseLoggerMixin, base.ImageConfigMixin, base.ConfigG
|
|||||||
current variant. If the config is set, it will be removed from the
|
current variant. If the config is set, it will be removed from the
|
||||||
dict.
|
dict.
|
||||||
"""
|
"""
|
||||||
|
if variant.type != 'variant':
|
||||||
|
# Buildinstall only runs for top-level variants. Nested variants
|
||||||
|
# need to re-use install tree from parent.
|
||||||
|
variant = variant.parent
|
||||||
|
|
||||||
install_tree_from = image_conf.pop('install_tree_from', variant.uid)
|
install_tree_from = image_conf.pop('install_tree_from', variant.uid)
|
||||||
if '://' in install_tree_from:
|
if '://' in install_tree_from:
|
||||||
return install_tree_from
|
return install_tree_from
|
||||||
|
@ -89,8 +89,8 @@ class DummyCompose(object):
|
|||||||
|
|
||||||
def setup_optional(self):
|
def setup_optional(self):
|
||||||
self.all_variants['Server-optional'] = MockVariant(
|
self.all_variants['Server-optional'] = MockVariant(
|
||||||
uid='Server-optional', arches=['x86_64'], type='optional', is_empty=False,
|
uid='Server-optional', arches=['x86_64'], type='optional', is_empty=False)
|
||||||
parent=self.variants['Server'])
|
self.all_variants['Server-optional'].parent = self.variants['Server']
|
||||||
self.variants['Server'].variants = {'optional': self.all_variants['Server-optional']}
|
self.variants['Server'].variants = {'optional': self.all_variants['Server-optional']}
|
||||||
|
|
||||||
def get_variants(self, arch=None, types=None):
|
def get_variants(self, arch=None, types=None):
|
||||||
|
@ -564,6 +564,66 @@ class TestImageBuildPhase(PungiTestCase):
|
|||||||
self.assertEqual(args[0][1]['image_conf'].get('image-build', {}).get('ksurl'),
|
self.assertEqual(args[0][1]['image_conf'].get('image-build', {}).get('ksurl'),
|
||||||
resolve_git_url.return_value)
|
resolve_git_url.return_value)
|
||||||
|
|
||||||
|
@mock.patch('pungi.phases.image_build.ThreadPool')
|
||||||
|
def test_image_build_optional(self, ThreadPool):
|
||||||
|
compose = DummyCompose(self.topdir, {
|
||||||
|
'image_build': {
|
||||||
|
'^Server-optional$': [
|
||||||
|
{
|
||||||
|
'image-build': {
|
||||||
|
'format': [('docker', 'tar.xz')],
|
||||||
|
'name': 'Fedora-Docker-Base',
|
||||||
|
'target': 'f24',
|
||||||
|
'version': 'Rawhide',
|
||||||
|
'ksurl': 'git://git.fedorahosted.org/git/spin-kickstarts.git',
|
||||||
|
'kickstart': "fedora-docker-base.ks",
|
||||||
|
'distro': 'Fedora-20',
|
||||||
|
'disk_size': 3,
|
||||||
|
'failable': ['x86_64'],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
'koji_profile': 'koji',
|
||||||
|
})
|
||||||
|
compose.setup_optional()
|
||||||
|
|
||||||
|
self.assertValidConfig(compose.conf)
|
||||||
|
|
||||||
|
phase = ImageBuildPhase(compose)
|
||||||
|
|
||||||
|
phase.run()
|
||||||
|
|
||||||
|
# assert at least one thread was started
|
||||||
|
self.assertTrue(phase.pool.add.called)
|
||||||
|
server_args = {
|
||||||
|
"format": [('docker', 'tar.xz')],
|
||||||
|
"image_conf": {
|
||||||
|
'image-build': {
|
||||||
|
'install_tree': self.topdir + '/compose/Server/$arch/os',
|
||||||
|
'kickstart': 'fedora-docker-base.ks',
|
||||||
|
'format': 'docker',
|
||||||
|
'repo': self.topdir + '/compose/Server-optional/$arch/os',
|
||||||
|
'variant': compose.all_variants['Server-optional'],
|
||||||
|
'target': 'f24',
|
||||||
|
'disk_size': 3,
|
||||||
|
'name': 'Fedora-Docker-Base',
|
||||||
|
'arches': 'x86_64',
|
||||||
|
'version': 'Rawhide',
|
||||||
|
'ksurl': 'git://git.fedorahosted.org/git/spin-kickstarts.git',
|
||||||
|
'distro': 'Fedora-20',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"conf_file": self.topdir + '/work/image-build/Server-optional/docker_Fedora-Docker-Base.cfg',
|
||||||
|
"image_dir": self.topdir + '/compose/Server-optional/%(arch)s/images',
|
||||||
|
"relative_image_dir": 'Server-optional/%(arch)s/images',
|
||||||
|
"link_type": 'hardlink-or-copy',
|
||||||
|
"scratch": False,
|
||||||
|
"failable_arches": ['x86_64'],
|
||||||
|
}
|
||||||
|
self.assertItemsEqual(phase.pool.queue_put.mock_calls,
|
||||||
|
[mock.call((compose, server_args))])
|
||||||
|
|
||||||
|
|
||||||
class TestCreateImageBuildThread(PungiTestCase):
|
class TestCreateImageBuildThread(PungiTestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user