kiwibuild: Add options for version and repo_releasever

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 `<release_version>_<label_milestone>`.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
(cherry picked from commit d351773dab7b3aa8e6de82bbe23058b6b3448dd4)
This commit is contained in:
Lubomír Sedlář 2024-08-26 08:53:10 +02:00 committed by Stepan Oksanichenko
parent d2fc85437b
commit d93b358959
4 changed files with 46 additions and 0 deletions

View File

@ -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 <auto-version>`.
* ``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
====================================

View File

@ -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"},

View File

@ -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)

View File

@ -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)]