From 91119d7d170ea20d876d2fd421f8ddc1cc7ce358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 14 Apr 2016 11:05:18 +0200 Subject: [PATCH 1/3] [live-media] Add check for live_media_version option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was used, but the type was not validated. Signed-off-by: Lubomír Sedlář --- pungi/phases/livemedia_phase.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pungi/phases/livemedia_phase.py b/pungi/phases/livemedia_phase.py index 0e6b892b..6fad470b 100644 --- a/pungi/phases/livemedia_phase.py +++ b/pungi/phases/livemedia_phase.py @@ -37,7 +37,12 @@ class LiveMediaPhase(PhaseBase): "name": "live_media_release", "expected_types": [str, type(None)], "optional": True, - } + }, + { + "name": "live_media_version", + "expected_types": [str], + "optional": True, + }, ) def __init__(self, compose): From a8ff48ce922dc9b6b57f6b8735e68b2930057c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 14 Apr 2016 11:24:05 +0200 Subject: [PATCH 2/3] Remove duplicated and dead code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in checking whether a phase should be skipped. Signed-off-by: Lubomír Sedlář --- pungi/phases/image_build.py | 14 +++----------- pungi/phases/live_images.py | 20 ++++---------------- pungi/phases/livemedia_phase.py | 12 ++---------- 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/pungi/phases/image_build.py b/pungi/phases/image_build.py index dc856aeb..286c72b5 100644 --- a/pungi/phases/image_build.py +++ b/pungi/phases/image_build.py @@ -6,7 +6,7 @@ import time from kobo import shortcuts from pungi.util import get_variant_data, resolve_git_url, makedirs, get_mtime, get_file_size, failable -from pungi.phases.base import PhaseBase +from pungi.phases.base import ConfigGuardedPhase from pungi.linker import Linker from pungi.paths import translate_path from pungi.wrappers.kojiwrapper import KojiWrapper @@ -14,22 +14,14 @@ from kobo.threads import ThreadPool, WorkerThread from productmd.images import Image -class ImageBuildPhase(PhaseBase): +class ImageBuildPhase(ConfigGuardedPhase): """class for wrapping up koji image-build""" name = "image_build" def __init__(self, compose): - PhaseBase.__init__(self, compose) + super(ImageBuildPhase, self).__init__(compose) self.pool = ThreadPool(logger=self.compose._logger) - def skip(self): - if PhaseBase.skip(self): - return True - if not self.compose.conf.get(self.name): - self.compose.log_info("Config section '%s' was not found. Skipping" % self.name) - return True - return False - def _get_install_tree(self, image_conf, variant): """ Get a path to os tree for a variant specified in `install_tree_from` or diff --git a/pungi/phases/live_images.py b/pungi/phases/live_images.py index 43e7c24e..bcd04773 100644 --- a/pungi/phases/live_images.py +++ b/pungi/phases/live_images.py @@ -27,7 +27,7 @@ from productmd.images import Image from pungi.wrappers.kojiwrapper import KojiWrapper from pungi.wrappers.iso import IsoWrapper -from pungi.phases.base import PhaseBase +from pungi.phases.base import ConfigGuardedPhase from pungi.util import get_arch_variant_data, resolve_git_url, makedirs, get_mtime, get_file_size, failable from pungi.paths import translate_path @@ -38,8 +38,8 @@ if sys.version_info[0] == 3: return (a > b) - (a < b) -class LiveImagesPhase(PhaseBase): - name = "liveimages" +class LiveImagesPhase(ConfigGuardedPhase): + name = "live_images" config_options = ( { @@ -75,16 +75,9 @@ class LiveImagesPhase(PhaseBase): ) def __init__(self, compose): - PhaseBase.__init__(self, compose) + super(LiveImagesPhase, self).__init__(compose) self.pool = ThreadPool(logger=self.compose._logger) - def skip(self): - if PhaseBase.skip(self): - return True - if not self.compose.conf.get("live_images"): - return True - return False - def _get_extra_repos(self, arch, variant, extras): repo = [] for extra in extras: @@ -194,11 +187,6 @@ class LiveImagesPhase(PhaseBase): return self.compose.get_image_name(arch, variant, disc_type=disc_type, disc_num=None, format=format) - def stop(self, *args, **kwargs): - PhaseBase.stop(self, *args, **kwargs) - if self.skip(): - return - class CreateLiveImageThread(WorkerThread): EXTS = ('.iso', '.raw.xz') diff --git a/pungi/phases/livemedia_phase.py b/pungi/phases/livemedia_phase.py index 6fad470b..8d95bd72 100644 --- a/pungi/phases/livemedia_phase.py +++ b/pungi/phases/livemedia_phase.py @@ -5,7 +5,7 @@ import time from kobo import shortcuts from pungi.util import get_variant_data, resolve_git_url, makedirs, get_mtime, get_file_size, failable -from pungi.phases.base import PhaseBase +from pungi.phases.base import ConfigGuardedPhase from pungi.linker import Linker from pungi.paths import translate_path from pungi.wrappers.kojiwrapper import KojiWrapper @@ -13,7 +13,7 @@ from kobo.threads import ThreadPool, WorkerThread from productmd.images import Image -class LiveMediaPhase(PhaseBase): +class LiveMediaPhase(ConfigGuardedPhase): """class for wrapping up koji spin-livemedia""" name = 'live_media' @@ -50,14 +50,6 @@ class LiveMediaPhase(PhaseBase): self.pool = ThreadPool(logger=self.compose._logger) self._global_ksurl = None - def skip(self): - if super(LiveMediaPhase, self).skip(): - return True - if not self.compose.conf.get(self.name): - self.compose.log_info("Config section '%s' was not found. Skipping" % self.name) - return True - return False - def _get_repos(self, image_conf, variant): """ Get a comma separated list of repos. First included are those From 084994538bae1781e66ea0cfa1fb4a74945b4b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 14 Apr 2016 14:23:42 +0200 Subject: [PATCH 3/3] Add common global settings for images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The live_images, live_media and image_build phases have same options that need to be specified on each image. This leads to a lot of duplication in the config file. This patch adds global settings and phase-level settings that allow to significantly reduce duplication. Signed-off-by: Lubomír Sedlář --- doc/configuration.rst | 41 ++++++++++++ pungi/phases/base.py | 65 ++++++++++++++++++++ pungi/phases/image_build.py | 46 ++++++++++++-- pungi/phases/init.py | 21 +++++++ pungi/phases/live_images.py | 40 +++++++----- pungi/phases/livemedia_phase.py | 41 +++--------- tests/test_imagebuildphase.py | 61 +++++++++++++++++- tests/test_liveimagesphase.py | 106 +++++++++++++++++++++++++++++++- tests/test_livemediaphase.py | 102 +++++++++++++++++++++++++++++- tests/test_phase_base.py | 73 ++++++++++++++++++++++ 10 files changed, 534 insertions(+), 62 deletions(-) create mode 100644 tests/test_phase_base.py diff --git a/doc/configuration.rst b/doc/configuration.rst index 2d7e324e..bd628985 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -735,6 +735,47 @@ Example ] +Common options for Live Images, Live Media and Image Build +========================================================== + +All images can have ``ksurl``, ``version``, ``release`` and ``target`` +specified. Since this can create a lot of duplication, there are global options +that can be used instead. + +For each of the phases, if the option is not specified for a particular +deliverable, an option named ``_