From d93b358959f70446a742ffe46ecbca1e40eddb1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 26 Aug 2024 08:53:10 +0200 Subject: [PATCH] kiwibuild: Add options for version and repo_releasever MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The version follows the same rules as versioning for live media etc. That means it's always going to be set. The precedence goes like this: * image specific option * `kiwibuild_version` * `global_version` * `release_version` or `_`. Signed-off-by: Lubomír Sedlář (cherry picked from commit d351773dab7b3aa8e6de82bbe23058b6b3448dd4) --- doc/configuration.rst | 13 +++++++++++++ pungi/checks.py | 4 ++++ pungi/phases/kiwibuild.py | 4 ++++ tests/test_kiwibuildphase.py | 25 +++++++++++++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/doc/configuration.rst b/doc/configuration.rst index b0a6d5c3..c6f936ab 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1570,6 +1570,13 @@ KiwiBuild Settings * ``type_attr`` -- (*[str]*) override default attributes for the build type from description. * ``bundle_name_format`` -- (*str*) override default bundle format name. + * ``version`` -- (*str*) override version. Follows the same rules as + described in :ref:`automatic versioning `. + * ``repo_releasever`` -- (*str*) Override default releasever of the output + image. + + The options can be set either for the specific image, or at the phase level + (see below). Version also falls back to ``global_version``. **kiwibuild_description_scm** (*str*) -- URL for scm containing the description files @@ -1586,6 +1593,12 @@ KiwiBuild Settings **kiwibuild_bundle_name_format** (*str*) -- override default bundle format name. +**kiwibuild_version** + (*str*) -- overide version for all kiwibuild tasks. + +**kiwibuild_repo_releasever** + (*str*) -- override releasever for all kiwibuild tasks. + OSBuild Composer for building images ==================================== diff --git a/pungi/checks.py b/pungi/checks.py index 4da799a9..2aaf01f3 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -1225,6 +1225,8 @@ def make_schema(): "type": {"type": "string"}, "type_attr": {"$ref": "#/definitions/list_of_strings"}, "bundle_name_format": {"type": "string"}, + "version": {"type": "string"}, + "repo_releasever": {"type": "string"}, }, "required": [ # description_scm and description_path @@ -1246,6 +1248,8 @@ def make_schema(): "kiwibuild_type": {"type": "string"}, "kiwibuild_type_attr": {"$ref": "#/definitions/list_of_strings"}, "kiwibuild_bundle_name_format": {"type": "string"}, + "kiwibuild_version": {"type": "string"}, + "kiwibuild_repo_releasever": {"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 fabcce5b..7ce3a54c 100644 --- a/pungi/phases/kiwibuild.py +++ b/pungi/phases/kiwibuild.py @@ -84,6 +84,8 @@ class KiwiBuildPhase( "bundle_name_format": self.get_config( image_conf, "bundle_name_format" ), + "version": self.get_version(image_conf), + "repo_releasever": self.get_config(image_conf, "repo_releasever"), } repo = self._get_repo(image_conf, variant) @@ -144,6 +146,8 @@ class RunKiwiBuildThread(WorkerThread): 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, + version=generics["version"], + repo_releasever=generics["repo_releasever"], ) koji.save_task_id(task_id) diff --git a/tests/test_kiwibuildphase.py b/tests/test_kiwibuildphase.py index 237dcafb..50116a20 100644 --- a/tests/test_kiwibuildphase.py +++ b/tests/test_kiwibuildphase.py @@ -50,6 +50,8 @@ class TestKiwiBuildPhase(PungiTestCase): "type": None, "type_attr": None, "bundle_name_format": None, + "version": compose.image_version, + "repo_releasever": None, }, [self.topdir + "/compose/Server/$arch/os"], [], # failable arches @@ -69,6 +71,8 @@ class TestKiwiBuildPhase(PungiTestCase): "type": "custom", "type_attr": ["foo", "bar"], "bundle_name_format": "fmt", + "version": "Rawhide", + "repo_releasever": "41", }, MINIMAL_CONF, ) @@ -95,6 +99,8 @@ class TestKiwiBuildPhase(PungiTestCase): "type": "custom", "type_attr": ["foo", "bar"], "bundle_name_format": "fmt", + "version": "Rawhide", + "repo_releasever": "41", }, [ "https://example.com/repo/", @@ -131,6 +137,8 @@ class TestKiwiBuildPhase(PungiTestCase): "type": None, "type_attr": None, "bundle_name_format": None, + "version": compose.image_version, + "repo_releasever": None, }, [self.topdir + "/compose/Server/$arch/os"], ["x86_64"], # failable arches @@ -151,6 +159,8 @@ class TestKiwiBuildPhase(PungiTestCase): "kiwibuild_type": "custom", "kiwibuild_type_attr": ["foo", "bar"], "kiwibuild_bundle_name_format": "fmt", + "kiwibuild_version": "Rawhide", + "kiwibuild_repo_releasever": "41", }, ) @@ -175,6 +185,8 @@ class TestKiwiBuildPhase(PungiTestCase): "type": "custom", "type_attr": ["foo", "bar"], "bundle_name_format": "fmt", + "version": "Rawhide", + "repo_releasever": "41", }, [self.topdir + "/compose/Server/$arch/os"], [], # failable arches @@ -190,6 +202,7 @@ class TestKiwiBuildPhase(PungiTestCase): "kiwibuild": {"^Server$": [cfg]}, "global_target": "f40", "global_release": "1234", + "global_version": "41", }, ) @@ -214,6 +227,8 @@ class TestKiwiBuildPhase(PungiTestCase): "type": None, "type_attr": None, "bundle_name_format": None, + "version": "41", + "repo_releasever": None, }, [self.topdir + "/compose/Server/$arch/os"], [], # failable arches @@ -278,6 +293,8 @@ class TestKiwiBuildThread(PungiTestCase): "type": "t", "type_attr": ["ta"], "bundle_name_format": "fmt", + "version": "v", + "repo_releasever": "r", }, [self.repo], [], @@ -298,6 +315,8 @@ class TestKiwiBuildThread(PungiTestCase): type_attr=["ta"], result_bundle_name_format="fmt", optional_arches=[], + version="v", + repo_releasever="r", ) ] @@ -362,6 +381,8 @@ class TestKiwiBuildThread(PungiTestCase): "type": None, "type_attr": None, "bundle_name_format": None, + "version": None, + "repo_releasever": None, }, [self.repo], [], @@ -413,6 +434,8 @@ class TestKiwiBuildThread(PungiTestCase): "type": None, "type_attr": None, "bundle_name_format": None, + "version": None, + "repo_releasever": None, }, [self.repo], ["amd64"], @@ -433,6 +456,8 @@ class TestKiwiBuildThread(PungiTestCase): type_attr=None, result_bundle_name_format=None, optional_arches=["amd64"], + version=None, + repo_releasever=None, ) ] assert get_image_paths.mock_calls == [mock.call(1234)]