pungi/0010-buildinstall-Add-option-to-disable-it.patch
2018-03-16 14:52:42 +01:00

124 lines
4.4 KiB
Diff

From 1e6a0c19e78be15e2398bd1a462b5c8b41168155 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= <lsedlar@redhat.com>
Date: Tue, 13 Mar 2018 15:54:52 +0100
Subject: [PATCH 10/12] buildinstall: Add option to disable it
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes: https://pagure.io/pungi/issue/854
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
---
doc/configuration.rst | 12 ++++++++++++
pungi/checks.py | 1 +
pungi/phases/buildinstall.py | 8 ++++++++
tests/test_buildinstall.py | 27 +++++++++++++++++++++++++++
4 files changed, 48 insertions(+)
diff --git a/doc/configuration.rst b/doc/configuration.rst
index dbe5ba08..e5f1e9e0 100644
--- a/doc/configuration.rst
+++ b/doc/configuration.rst
@@ -504,6 +504,11 @@ Options
task using HTTP and set the output directory for this task to
``buildinstall_topdir``. Once the runroot task finishes, Pungi will copy
the results of runroot tasks to the compose working directory.
+**buildinstall_skip**
+ (*list*) -- mapping that defines which variants and arches to skip during
+ buildinstall; format: ``[(variant_uid_regex, {arch|*: True})]``. This is
+ only supported for lorax.
+
Example
-------
@@ -525,6 +530,13 @@ Example
})
]
+ # Don't run buildinstall phase for Modular variant
+ buildinstall_skip = [
+ ('^Modular', {
+ '*': True
+ })
+ ]
+
.. note::
diff --git a/pungi/checks.py b/pungi/checks.py
index 9b317ab6..2ff4f697 100644
--- a/pungi/checks.py
+++ b/pungi/checks.py
@@ -727,6 +727,7 @@ def make_schema():
"buildinstall_topdir": {"type": "string"},
"buildinstall_kickstart": {"$ref": "#/definitions/str_or_scm_dict"},
"buildinstall_use_guestmount": {"type": "boolean", "default": True},
+ "buildinstall_skip": _variant_arch_mapping({"type": "boolean"}),
"global_ksurl": {"type": "string"},
"global_version": {"type": "string"},
diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py
index 69813c2a..3ec523bf 100644
--- a/pungi/phases/buildinstall.py
+++ b/pungi/phases/buildinstall.py
@@ -134,10 +134,18 @@ class BuildinstallPhase(PhaseBase):
repo_baseurl = translate_path(self.compose, repo_baseurl)
if self.buildinstall_method == "lorax":
+
buildarch = get_valid_arches(arch)[0]
for variant in self.compose.get_variants(arch=arch, types=['variant']):
if variant.is_empty:
continue
+
+ skip = get_arch_variant_data(self.compose.conf, "buildinstall_skip", arch, variant)
+ if skip == [True]:
+ self.compose.log_info(
+ 'Skipping buildinstall for %s.%s due to config option' % (variant, arch))
+ continue
+
volid = get_volid(self.compose, arch, variant=variant, disc_type=disc_type)
commands.append(
(variant,
diff --git a/tests/test_buildinstall.py b/tests/test_buildinstall.py
index 335b0d2d..aa8f527b 100644
--- a/tests/test_buildinstall.py
+++ b/tests/test_buildinstall.py
@@ -43,6 +43,33 @@ class TestBuildinstallPhase(PungiTestCase):
self.assertTrue(phase.skip())
+ @mock.patch('pungi.phases.buildinstall.ThreadPool')
+ @mock.patch('pungi.phases.buildinstall.LoraxWrapper')
+ @mock.patch('pungi.phases.buildinstall.get_volid')
+ def test_skip_option(self, get_volid, loraxCls, poolCls):
+ compose = BuildInstallCompose(self.topdir, {
+ 'bootable': True,
+ 'buildinstall_method': 'lorax',
+ 'buildinstall_skip': [
+ ('^Server$', {
+ 'amd64': True
+ }),
+ ('^Client$', {
+ '*': True,
+ }),
+ ]
+ })
+
+ get_volid.return_value = 'vol_id'
+ loraxCls.return_value.get_lorax_cmd.return_value = ['lorax', '...']
+
+ phase = BuildinstallPhase(compose)
+
+ phase.run()
+
+ pool = poolCls.return_value
+ self.assertEqual(1, len(pool.queue_put.mock_calls))
+
def test_does_not_skip_on_bootable(self):
compose = BuildInstallCompose(self.topdir, {'bootable': True})
compose.just_phases = None
--
2.13.6