kiwibuild: Allow setting metadata type explicitly

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ář <lsedlar@redhat.com>
(cherry picked from commit cd2ae81e3c63316997b9617ff2e30e3148af14f2)
This commit is contained in:
Lubomír Sedlář 2024-08-29 08:21:35 +02:00 committed by Stepan Oksanichenko
parent 6576ab9b32
commit c586c0b03b
4 changed files with 12 additions and 5 deletions

View File

@ -1574,6 +1574,9 @@ KiwiBuild Settings
described in :ref:`automatic versioning <auto-version>`. described in :ref:`automatic versioning <auto-version>`.
* ``repo_releasever`` -- (*str*) Override default releasever of the output * ``repo_releasever`` -- (*str*) Override default releasever of the output
image. 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 The options can be set either for the specific image, or at the phase level
(see below). Version also falls back to ``global_version``. (see below). Version also falls back to ``global_version``.

View File

@ -1227,6 +1227,7 @@ def make_schema():
"bundle_name_format": {"type": "string"}, "bundle_name_format": {"type": "string"},
"version": {"type": "string"}, "version": {"type": "string"},
"repo_releasever": {"type": "string"}, "repo_releasever": {"type": "string"},
"manifest_type": {"type": "string"},
}, },
"required": [ "required": [
# description_scm and description_path # description_scm and description_path

View File

@ -211,9 +211,9 @@ class RunKiwiBuildThread(WorkerThread):
# Update image manifest # Update image manifest
img = Image(compose.im) img = Image(compose.im)
# Get the manifest type from the config if supplied, otherwise we # If user configured exact type, use it, otherwise try to
# determine the manifest type based on the koji output # figure it out based on the koji output.
img.type = type_ img.type = config.get("manifest_type", type_)
img.format = format_ img.format = format_
img.path = os.path.join(rel_image_dir, filename) img.path = os.path.join(rel_image_dir, filename)
img.mtime = util.get_mtime(image_dest) img.mtime = util.get_mtime(image_dest)

View File

@ -73,6 +73,7 @@ class TestKiwiBuildPhase(PungiTestCase):
"bundle_name_format": "fmt", "bundle_name_format": "fmt",
"version": "Rawhide", "version": "Rawhide",
"repo_releasever": "41", "repo_releasever": "41",
"manifest_type": "live-kiwi",
}, },
MINIMAL_CONF, MINIMAL_CONF,
) )
@ -366,7 +367,9 @@ class TestKiwiBuildThread(PungiTestCase):
"kiwibuild_bundle_format": "%N-%P-40_Beta-%I.%A.%T", "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() pool = mock.Mock()
get_image_paths = KojiWrapper.return_value.get_image_paths get_image_paths = KojiWrapper.return_value.get_image_paths
@ -459,7 +462,7 @@ class TestKiwiBuildThread(PungiTestCase):
assert kwargs["arch"] == image.arch assert kwargs["arch"] == image.arch
assert image.path == expected_path assert image.path == expected_path
assert "iso" == image.format assert "iso" == image.format
assert "iso" == image.type assert "live-kiwi" == image.type
assert image.bootable assert image.bootable
assert "Test" == image.subvariant assert "Test" == image.subvariant