From 7c81c5aa9c9395ff97fb1ef3344540166141a4c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 22 Feb 2016 08:38:19 +0100 Subject: [PATCH] [live-images] Automatically populate release with date and respin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the same feature that is already available for image-build and live-media. Signed-off-by: Lubomír Sedlář --- pungi/phases/live_images.py | 8 ++++++++ tests/test_liveimagesphase.py | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/pungi/phases/live_images.py b/pungi/phases/live_images.py index 31480322..9b3cbde0 100644 --- a/pungi/phases/live_images.py +++ b/pungi/phases/live_images.py @@ -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? diff --git a/tests/test_liveimagesphase.py b/tests/test_liveimagesphase.py index b18dec3c..709dd544 100755 --- a/tests/test_liveimagesphase.py +++ b/tests/test_liveimagesphase.py @@ -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')