From e43cf68f083f17293546a2e9c7ffb4a9638e98da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 20 Mar 2024 14:30:09 +0100 Subject: [PATCH] kiwibuild: Add support for type, type attr and bundle format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a very basic support. Whatever users specify in the new option will be passed to the koji task. Related: https://bugzilla.redhat.com/show_bug.cgi?id=2270197 Related: https://pagure.io/koji/pull-request/4157 Signed-off-by: Lubomír Sedlář --- doc/configuration.rst | 13 +++++++++++ pungi/checks.py | 6 +++++ pungi/phases/kiwibuild.py | 8 +++++++ tests/test_kiwibuildphase.py | 44 +++++++++++++++++++++++++++++++++++- 4 files changed, 70 insertions(+), 1 deletion(-) diff --git a/doc/configuration.rst b/doc/configuration.rst index 9bbe2d2f..b0a6d5c3 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1566,6 +1566,10 @@ KiwiBuild Settings provided, all variant architectures will be built. * ``failable`` -- (*[str]*) List of architectures for which this deliverable is not release blocking. + * ``type`` -- (*str*) override default type from the bundle with this value. + * ``type_attr`` -- (*[str]*) override default attributes for the build type + from description. + * ``bundle_name_format`` -- (*str*) override default bundle format name. **kiwibuild_description_scm** (*str*) -- URL for scm containing the description files @@ -1573,6 +1577,15 @@ KiwiBuild Settings **kiwibuild_description_path** (*str*) -- path to a description file within the description scm +**kiwibuild_type** + (*str*) -- override default type from the bundle with this value. + +**kiwibuild_type_attr** + (*[str]*) -- override default attributes for the build type from description. + +**kiwibuild_bundle_name_format** + (*str*) -- override default bundle format name. + OSBuild Composer for building images ==================================== diff --git a/pungi/checks.py b/pungi/checks.py index cb816423..dae31f5e 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -1209,6 +1209,9 @@ def make_schema(): "repos": {"$ref": "#/definitions/list_of_strings"}, "failable": {"$ref": "#/definitions/list_of_strings"}, "subvariant": {"type": "string"}, + "type": {"type": "string"}, + "type_attr": {"$ref": "#/definitions/list_of_strings"}, + "bundle_name_format": {"type": "string"}, }, "required": [ # description_scm and description_path @@ -1227,6 +1230,9 @@ def make_schema(): "kiwibuild_description_path": {"type": "string"}, "kiwibuild_target": {"type": "string"}, "kiwibuild_release": {"$ref": "#/definitions/optional_string"}, + "kiwibuild_type": {"type": "string"}, + "kiwibuild_type_attr": {"$ref": "#/definitions/list_of_strings"}, + "kiwibuild_bundle_name_format": {"type": "string"}, "osbuild_target": {"type": "string"}, "osbuild_release": {"$ref": "#/definitions/optional_string"}, "osbuild_version": {"type": "string"}, diff --git a/pungi/phases/kiwibuild.py b/pungi/phases/kiwibuild.py index 2c06b3f1..fabcce5b 100644 --- a/pungi/phases/kiwibuild.py +++ b/pungi/phases/kiwibuild.py @@ -79,6 +79,11 @@ class KiwiBuildPhase( "target": self.get_config(image_conf, "target"), "descscm": self.get_config(image_conf, "description_scm"), "descpath": self.get_config(image_conf, "description_path"), + "type": self.get_config(image_conf, "type"), + "type_attr": self.get_config(image_conf, "type_attr"), + "bundle_name_format": self.get_config( + image_conf, "bundle_name_format" + ), } repo = self._get_repo(image_conf, variant) @@ -134,6 +139,9 @@ class RunKiwiBuildThread(WorkerThread): profile=config["kiwi_profile"], release=generics["release"], repos=repo, + type=generics["type"], + type_attr=generics["type_attr"], + result_bundle_name_format=generics["bundle_name_format"], # this ensures the task won't fail if only failable arches fail optional_arches=self.failable_arches, ) diff --git a/tests/test_kiwibuildphase.py b/tests/test_kiwibuildphase.py index a3a6f7f4..237dcafb 100644 --- a/tests/test_kiwibuildphase.py +++ b/tests/test_kiwibuildphase.py @@ -47,6 +47,9 @@ class TestKiwiBuildPhase(PungiTestCase): "target": "f40", "descscm": MINIMAL_CONF["description_scm"], "descpath": MINIMAL_CONF["description_path"], + "type": None, + "type_attr": None, + "bundle_name_format": None, }, [self.topdir + "/compose/Server/$arch/os"], [], # failable arches @@ -63,6 +66,9 @@ class TestKiwiBuildPhase(PungiTestCase): "repos": ["https://example.com/repo/", "Client"], "failable": ["*"], "subvariant": "Test", + "type": "custom", + "type_attr": ["foo", "bar"], + "bundle_name_format": "fmt", }, MINIMAL_CONF, ) @@ -86,6 +92,9 @@ class TestKiwiBuildPhase(PungiTestCase): "target": "f40", "descscm": MINIMAL_CONF["description_scm"], "descpath": MINIMAL_CONF["description_path"], + "type": "custom", + "type_attr": ["foo", "bar"], + "bundle_name_format": "fmt", }, [ "https://example.com/repo/", @@ -119,6 +128,9 @@ class TestKiwiBuildPhase(PungiTestCase): "target": "f40", "descscm": MINIMAL_CONF["description_scm"], "descpath": MINIMAL_CONF["description_path"], + "type": None, + "type_attr": None, + "bundle_name_format": None, }, [self.topdir + "/compose/Server/$arch/os"], ["x86_64"], # failable arches @@ -136,6 +148,9 @@ class TestKiwiBuildPhase(PungiTestCase): "kiwibuild_release": "1234", "kiwibuild_description_scm": "foo", "kiwibuild_description_path": "bar", + "kiwibuild_type": "custom", + "kiwibuild_type_attr": ["foo", "bar"], + "kiwibuild_bundle_name_format": "fmt", }, ) @@ -157,6 +172,9 @@ class TestKiwiBuildPhase(PungiTestCase): "target": "f40", "descscm": "foo", "descpath": "bar", + "type": "custom", + "type_attr": ["foo", "bar"], + "bundle_name_format": "fmt", }, [self.topdir + "/compose/Server/$arch/os"], [], # failable arches @@ -193,6 +211,9 @@ class TestKiwiBuildPhase(PungiTestCase): "target": "f40", "descscm": MINIMAL_CONF["description_scm"], "descpath": MINIMAL_CONF["description_path"], + "type": None, + "type_attr": None, + "bundle_name_format": None, }, [self.topdir + "/compose/Server/$arch/os"], [], # failable arches @@ -215,7 +236,13 @@ class TestKiwiBuildThread(PungiTestCase): def test_process(self, KojiWrapper, get_file_size, get_mtime, Linker): img_name = "FCBG.{arch}-Rawhide-1.6.vagrant.libvirt.box" self.repo = self.topdir + "/compose/Server/$arch/os" - compose = DummyCompose(self.topdir, {"koji_profile": "koji"}) + compose = DummyCompose( + self.topdir, + { + "koji_profile": "koji", + "kiwibuild_bundle_format": "%N-%P-40_Beta-%I.%A.%T", + }, + ) config = _merge({"subvariant": "Test"}, MINIMAL_CONF) pool = mock.Mock() @@ -248,6 +275,9 @@ class TestKiwiBuildThread(PungiTestCase): "target": "f40", "descscm": MINIMAL_CONF["description_scm"], "descpath": MINIMAL_CONF["description_path"], + "type": "t", + "type_attr": ["ta"], + "bundle_name_format": "fmt", }, [self.repo], [], @@ -264,6 +294,9 @@ class TestKiwiBuildThread(PungiTestCase): profile=MINIMAL_CONF["kiwi_profile"], release="1.6", repos=[self.repo], + type="t", + type_attr=["ta"], + result_bundle_name_format="fmt", optional_arches=[], ) ] @@ -326,6 +359,9 @@ class TestKiwiBuildThread(PungiTestCase): "target": "f40", "descscm": MINIMAL_CONF["description_scm"], "descpath": MINIMAL_CONF["description_path"], + "type": None, + "type_attr": None, + "bundle_name_format": None, }, [self.repo], [], @@ -374,6 +410,9 @@ class TestKiwiBuildThread(PungiTestCase): "target": "f40", "descscm": MINIMAL_CONF["description_scm"], "descpath": MINIMAL_CONF["description_path"], + "type": None, + "type_attr": None, + "bundle_name_format": None, }, [self.repo], ["amd64"], @@ -390,6 +429,9 @@ class TestKiwiBuildThread(PungiTestCase): profile=MINIMAL_CONF["kiwi_profile"], release="1.6", repos=[self.repo], + type=None, + type_attr=None, + result_bundle_name_format=None, optional_arches=["amd64"], ) ]