From 2e48c9a56fbf923940903fc1a501c8d324a5dcbf Mon Sep 17 00:00:00 2001 From: soksanichenko Date: Fri, 12 Feb 2021 13:48:40 +0200 Subject: [PATCH] LU-2195 Change path to sources and iso when generating repositories - We should add the images to the compose if they will be used only as netinstall image. E.g. *-boot.iso. - And we shouldn't add if the images will be modified in phase `extra_isos`. E.g. *-minimal.iso Change-Id: I9095cfd87414ecca46b1213553589731c82dd2e2 --- pungi.spec | 1 + pungi/checks.py | 8 ++++++++ pungi/phases/buildinstall.py | 9 ++++++++- tests/test_buildinstall.py | 26 +++++++++++++++++++------- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/pungi.spec b/pungi.spec index 395820e3..0a761ff7 100644 --- a/pungi.spec +++ b/pungi.spec @@ -17,6 +17,7 @@ BuildRequires: python3-productmd >= 1.23 BuildRequires: python3-kobo-rpmlib >= 0.18.0 BuildRequires: createrepo_c BuildRequires: python3-lxml +BuildRequires: python3-ddt BuildRequires: python3-kickstart BuildRequires: python3-rpm BuildRequires: python3-dnf diff --git a/pungi/checks.py b/pungi/checks.py index 94a40b77..9cbddd20 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -773,6 +773,14 @@ def make_schema(): "type": "string", "enum": ["lorax", "buildinstall"], }, + # In phase `buildinstall` we should add to compose only the + # images that will be used only as netinstall + "netinstall_variants": { + "$ref": "#/definitions/list_of_strings", + "default": [ + "BaseOS", + ], + }, "buildinstall_topdir": {"type": "string"}, "buildinstall_kickstart": {"$ref": "#/definitions/str_or_scm_dict"}, "buildinstall_use_guestmount": {"type": "boolean", "default": True}, diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py index 0eba8fad..8d833364 100644 --- a/pungi/phases/buildinstall.py +++ b/pungi/phases/buildinstall.py @@ -518,7 +518,14 @@ def link_boot_iso(compose, arch, variant, can_fail): img.volume_id = iso.get_volume_id(new_boot_iso_path) except RuntimeError: pass - compose.im.add(variant.uid, arch, img) + # In this phase we should add to compose only the images that + # will be used only as netinstall. + # On this step lorax generates environment + # for creating isos and create them. + # On step `extra_isos` we overwrite the not needed iso `boot Minimal` by + # new iso. It already contains necessary packages from incldued variants. + if variant.uid in compose.conf['netinstall_variants']: + compose.im.add(variant.uid, arch, img) compose.log_info("[DONE ] %s" % msg) diff --git a/tests/test_buildinstall.py b/tests/test_buildinstall.py index e9d27de9..cbad3c14 100644 --- a/tests/test_buildinstall.py +++ b/tests/test_buildinstall.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- - try: import unittest2 as unittest except ImportError: import unittest -import mock +from unittest import mock import six from copy import copy from six.moves import StringIO +from ddt import ddt, data import os @@ -2000,6 +2000,7 @@ class BuildinstallThreadTestCase(PungiTestCase): self.assertEqual(ret, None) +@ddt class TestSymlinkIso(PungiTestCase): def setUp(self): super(TestSymlinkIso, self).setUp() @@ -2015,8 +2016,13 @@ class TestSymlinkIso(PungiTestCase): @mock.patch("pungi.phases.buildinstall.get_file_size") @mock.patch("pungi.phases.buildinstall.iso") @mock.patch("pungi.phases.buildinstall.run") - def test_hardlink(self, run, iso, get_file_size, get_mtime, ImageCls): - self.compose.conf = {"buildinstall_symlink": False, "disc_types": {}} + @data(['Server'], ['BaseOS']) + def test_hardlink(self, netinstall_variants, run, iso, get_file_size, get_mtime, ImageCls): + self.compose.conf = { + "buildinstall_symlink": False, + "disc_types": {}, + "netinstall_variants": netinstall_variants, + } get_file_size.return_value = 1024 get_mtime.return_value = 13579 @@ -2066,9 +2072,14 @@ class TestSymlinkIso(PungiTestCase): self.assertEqual(image.bootable, True) self.assertEqual(image.implant_md5, iso.get_implanted_md5.return_value) self.assertEqual(image.can_fail, False) - self.assertEqual( - self.compose.im.add.mock_calls, [mock.call("Server", "x86_64", image)] - ) + if 'Server' in netinstall_variants: + self.assertEqual( + self.compose.im.add.mock_calls, [mock.call("Server", "x86_64", image)] + ) + else: + self.assertEqual( + self.compose.im.add.mock_calls, [] + ) @mock.patch("pungi.phases.buildinstall.Image") @mock.patch("pungi.phases.buildinstall.get_mtime") @@ -2081,6 +2092,7 @@ class TestSymlinkIso(PungiTestCase): self.compose.conf = { "buildinstall_symlink": False, "disc_types": {"boot": "netinst"}, + "netinstall_variants": ['Server'], } get_file_size.return_value = 1024 get_mtime.return_value = 13579