From a0a155ebcd09eccaa50adbb5da5bdb6fce9f0191 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Wed, 9 Oct 2024 16:08:06 -0700 Subject: [PATCH] Correct subvariant handling for ostree_container phase The image metadata construction code allows for subvariant to be set in the image config dict, but checks.py doesn't expect it; fix that. Also, when a subvariant is set, use it in the image name template rather than the variant; otherwise you can't build more than one subvariant in any variant (they will have identical names, which isn't alllowed). Signed-off-by: Adam Williamson (cherry picked from commit 391a5eaed5198e5ee2941dac4ae43a2fe057eedd) --- doc/configuration.rst | 4 ++++ pungi/checks.py | 1 + pungi/phases/ostree_container.py | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/configuration.rst b/doc/configuration.rst index ded479ed..90621bbc 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -1886,6 +1886,10 @@ will thus create a new OCI archive image *from scratch*. reference will not be created. * ``runroot_packages`` -- (*list*) A list of additional package names to be installed in the runroot environment in Koji. + * ``subvariant`` -- (*str*) The subvariant value to be used in the metadata + for the image. Also used in the image's filename. Defaults to being the + same as the variant. If building more than one ostree container in a + variant, each must have a unique subvariant. Example config -------------- diff --git a/pungi/checks.py b/pungi/checks.py index c3e05075..df9ff28e 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -1114,6 +1114,7 @@ def make_schema(): "runroot_packages": { "$ref": "#/definitions/list_of_strings", }, + "subvariant": {"type": "string"}, }, "required": [ "treefile", diff --git a/pungi/phases/ostree_container.py b/pungi/phases/ostree_container.py index 38a647ed..e1119985 100644 --- a/pungi/phases/ostree_container.py +++ b/pungi/phases/ostree_container.py @@ -119,12 +119,13 @@ class OSTreeContainerThread(WorkerThread): def _run_ostree_container_cmd( self, compose, variant, arch, config, config_repo, extra_config_file=None ): + subvariant = config.get("subvariant", variant.uid) target_dir = compose.paths.compose.image_dir(variant) % {"arch": arch} util.makedirs(target_dir) version = util.version_generator(compose, config.get("version")) archive_name = "%s-%s-%s" % ( compose.conf["release_short"], - variant.uid, + subvariant, version, ) @@ -177,7 +178,7 @@ class OSTreeContainerThread(WorkerThread): img.disc_number = 1 img.disc_count = 1 img.bootable = False - img.subvariant = config.get("subvariant", variant.uid) + img.subvariant = subvariant setattr(img, "can_fail", self.can_fail) setattr(img, "deliverable", "ostree-container") compose.im.add(variant=variant.uid, arch=arch, image=img)