[live-images] Automatically populate release with date and respin

This is the same feature that is already available for image-build and
live-media.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-02-22 08:38:19 +01:00
parent ec03a8685a
commit 7c81c5aa9c
2 changed files with 19 additions and 0 deletions

View File

@ -92,6 +92,12 @@ class LiveImagesPhase(PhaseBase):
return repo
def _get_release(self, image_conf):
"""If release is set explicitly to None, replace it with date and respin."""
if 'release' in image_conf and image_conf['release'] is None:
return '%s.%s' % (self.compose.compose_date, self.compose.compose_respin)
return image_conf.get('release', None)
def run(self):
symlink_isos_to = self.compose.conf.get("symlink_isos_to", None)
commands = []
@ -134,6 +140,7 @@ class LiveImagesPhase(PhaseBase):
cmd["version"] = data.get("version", None)
cmd['type'] = data.get('type', 'live')
cmd['release'] = self._get_release(data)
# Specfile (for images wrapped in rpm)
cmd["specfile"] = data.get("specfile", None)
@ -223,6 +230,7 @@ class CreateLiveImageThread(WorkerThread):
wait=True,
archive=archive,
specfile=cmd["specfile"],
release=cmd['release'],
ksurl=cmd['ksurl'])
# avoid race conditions?

View File

@ -17,6 +17,8 @@ from pungi.util import get_arch_variant_data
class _DummyCompose(object):
def __init__(self, config):
self.compose_id = 'Test-20151203.0.t'
self.compose_date = '20151203'
self.compose_respin = '0'
self.conf = config
self.paths = mock.Mock(
compose=mock.Mock(
@ -69,6 +71,7 @@ class TestLiveImagesPhase(unittest.TestCase):
'kickstart': 'test.ks',
'additional_repos': ['http://example.com/repo/'],
'repos_from': ['Everything'],
'release': None,
}
})
],
@ -97,6 +100,7 @@ class TestLiveImagesPhase(unittest.TestCase):
'specfile': None,
'sign': False,
'type': 'live',
'release': '20151203.0',
'ksurl': None},
compose.variants['Client'],
'amd64'))])
@ -142,6 +146,7 @@ class TestLiveImagesPhase(unittest.TestCase):
'specfile': None,
'sign': False,
'type': 'live',
'release': None,
'ksurl': None},
compose.variants['Client'],
'amd64')),
@ -160,6 +165,7 @@ class TestLiveImagesPhase(unittest.TestCase):
'specfile': None,
'sign': False,
'type': 'live',
'release': None,
'ksurl': None},
compose.variants['Client'],
'amd64'))])
@ -206,6 +212,7 @@ class TestLiveImagesPhase(unittest.TestCase):
'specfile': None,
'sign': False,
'type': 'appliance',
'release': None,
'ksurl': 'https://git.example.com/kickstarts.git?#CAFEBABE'},
compose.variants['Client'],
'amd64'))])
@ -236,6 +243,7 @@ class TestCreateLiveImageThread(unittest.TestCase):
'specfile': None,
'type': 'live',
'ksurl': 'https://git.example.com/kickstarts.git?#CAFEBABE',
'release': None,
}
koji_wrapper = KojiWrapper.return_value
@ -272,6 +280,7 @@ class TestCreateLiveImageThread(unittest.TestCase):
archive=False,
specfile=None,
wait=True,
release=None,
ksurl='https://git.example.com/kickstarts.git?#CAFEBABE')])
@mock.patch('shutil.copy2')
@ -295,6 +304,7 @@ class TestCreateLiveImageThread(unittest.TestCase):
'specfile': None,
'type': 'appliance',
'ksurl': None,
'release': None,
}
koji_wrapper = KojiWrapper.return_value
@ -331,6 +341,7 @@ class TestCreateLiveImageThread(unittest.TestCase):
archive=False,
specfile=None,
wait=True,
release=None,
ksurl=None)])
@mock.patch('shutil.copy2')