From c586c0b03b3f6f6af24be9f886593c6849461b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 29 Aug 2024 08:21:35 +0200 Subject: [PATCH] kiwibuild: Allow setting metadata type explicitly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is not possible to reliably detect what the type for an image should be in the metadata. This commit adds an option for user to explicitly provide it. It can only be configured on the specific image, not globally. Signed-off-by: Lubomír Sedlář (cherry picked from commit cd2ae81e3c63316997b9617ff2e30e3148af14f2) --- doc/configuration.rst | 3 +++ pungi/checks.py | 1 + pungi/phases/kiwibuild.py | 6 +++--- tests/test_kiwibuildphase.py | 7 +++++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/configuration.rst b/doc/configuration.rst index c6f936ab..ded479ed 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1574,6 +1574,9 @@ KiwiBuild Settings described in :ref:`automatic versioning `. * ``repo_releasever`` -- (*str*) Override default releasever of the output image. + * ``manifest_type`` -- the image type that is put into the manifest by + pungi. If not supplied, an autodetected value will be provided. It may or + may not make sense. The options can be set either for the specific image, or at the phase level (see below). Version also falls back to ``global_version``. diff --git a/pungi/checks.py b/pungi/checks.py index 2aaf01f3..c3e05075 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -1227,6 +1227,7 @@ def make_schema(): "bundle_name_format": {"type": "string"}, "version": {"type": "string"}, "repo_releasever": {"type": "string"}, + "manifest_type": {"type": "string"}, }, "required": [ # description_scm and description_path diff --git a/pungi/phases/kiwibuild.py b/pungi/phases/kiwibuild.py index 12ec26dd..bb268125 100644 --- a/pungi/phases/kiwibuild.py +++ b/pungi/phases/kiwibuild.py @@ -211,9 +211,9 @@ class RunKiwiBuildThread(WorkerThread): # Update image manifest img = Image(compose.im) - # Get the manifest type from the config if supplied, otherwise we - # determine the manifest type based on the koji output - img.type = type_ + # If user configured exact type, use it, otherwise try to + # figure it out based on the koji output. + img.type = config.get("manifest_type", type_) img.format = format_ img.path = os.path.join(rel_image_dir, filename) img.mtime = util.get_mtime(image_dest) diff --git a/tests/test_kiwibuildphase.py b/tests/test_kiwibuildphase.py index 491dbf33..e3ccdb72 100644 --- a/tests/test_kiwibuildphase.py +++ b/tests/test_kiwibuildphase.py @@ -73,6 +73,7 @@ class TestKiwiBuildPhase(PungiTestCase): "bundle_name_format": "fmt", "version": "Rawhide", "repo_releasever": "41", + "manifest_type": "live-kiwi", }, MINIMAL_CONF, ) @@ -366,7 +367,9 @@ class TestKiwiBuildThread(PungiTestCase): "kiwibuild_bundle_format": "%N-%P-40_Beta-%I.%A.%T", }, ) - config = _merge({"subvariant": "Test"}, MINIMAL_CONF) + config = _merge( + {"subvariant": "Test", "manifest_type": "live-kiwi"}, MINIMAL_CONF + ) pool = mock.Mock() get_image_paths = KojiWrapper.return_value.get_image_paths @@ -459,7 +462,7 @@ class TestKiwiBuildThread(PungiTestCase): assert kwargs["arch"] == image.arch assert image.path == expected_path assert "iso" == image.format - assert "iso" == image.type + assert "live-kiwi" == image.type assert image.bootable assert "Test" == image.subvariant