From 53c273f025a563488ca138be78b87cbb91285e6a Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Thu, 19 Sep 2024 13:57:26 -0700 Subject: [PATCH] move osbuild/kiwi-specific EXTENSIONS to each phase The image-build phase's EXTENSIONS dict is meant to exactly mirror the 'formats' that exist in the context of the command `koji image-build`, which is driven by this phase. That nice association was lost, however, by adding a couple of items to it which exist for the purposes of the osbuild phase (and in the case of .iso, also the kiwibuild phase), which import this dict and uses it for image identification. To make the association 1:1 again and more clearly show what's going on here, let's move those entries out into the osbuild and kiwi phases. osbuild now has its own dict which starts out as a copy of the image-build one before being extended. And let's update the relevant comments. Signed-off-by: Adam Williamson (cherry picked from commit 5338d3098ccd614a8fd32f837a393aed78b471bd) --- pungi/phases/image_build.py | 8 +++++--- pungi/phases/kiwibuild.py | 4 ++++ pungi/phases/osbuild.py | 14 ++++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pungi/phases/image_build.py b/pungi/phases/image_build.py index cb76c1aa..cd034cd2 100644 --- a/pungi/phases/image_build.py +++ b/pungi/phases/image_build.py @@ -22,10 +22,13 @@ from productmd.rpms import Rpms # This is a mapping from formats to file extensions. The format is what koji # image-build command expects as argument, and the extension is what the file # name will be ending with. The extensions are used to filter out which task -# results will be pulled into the compose. +# results will be pulled into the compose. This dict is also used later in +# the process to set the image 'type' in productmd metadata terms - the type +# is set as the first key in this dict which has the file's extension in its +# values. This dict is imported and extended for similar purposes by other +# phases (at least osbuild and kiwibuild). EXTENSIONS = { "docker": ["tar.gz", "tar.xz"], - "iso": ["iso"], "liveimg-squashfs": ["liveimg.squashfs"], "qcow": ["qcow"], "qcow2": ["qcow2"], @@ -40,7 +43,6 @@ EXTENSIONS = { "vdi": ["vdi"], "vmdk": ["vmdk"], "vpc": ["vhd"], - "vhd-compressed": ["vhd.gz", "vhd.xz"], "vsphere-ova": ["vsphere.ova"], } diff --git a/pungi/phases/kiwibuild.py b/pungi/phases/kiwibuild.py index bb268125..15732cea 100644 --- a/pungi/phases/kiwibuild.py +++ b/pungi/phases/kiwibuild.py @@ -15,6 +15,10 @@ KIWIEXTENSIONS = [ ("vhd-compressed", ["vhdfixed.xz"], "vhd.xz"), ("vagrant-libvirt", ["vagrant.libvirt.box"], "vagrant-libvirt.box"), ("vagrant-virtualbox", ["vagrant.virtualbox.box"], "vagrant-virtualbox.box"), + # .iso images can be of many types - boot, cd, dvd, live... - + # so 'boot' is just a default guess. 'iso' is not a valid + # productmd image type + ("boot", [".iso"], "iso"), ] diff --git a/pungi/phases/osbuild.py b/pungi/phases/osbuild.py index 6c5b7e5a..a3b5c9b8 100644 --- a/pungi/phases/osbuild.py +++ b/pungi/phases/osbuild.py @@ -11,6 +11,16 @@ from ..linker import Linker from ..wrappers import kojiwrapper from .image_build import EXTENSIONS +# copy and modify EXTENSIONS with some that osbuild produces but which +# do not exist as `koji image-build` formats +OSBUILDEXTENSIONS = EXTENSIONS.copy() +OSBUILDEXTENSIONS.update( + { + "iso": ["iso"], + "vhd-compressed": ["vhd.gz", "vhd.xz"], + } +) + class OSBuildPhase( base.PhaseLoggerMixin, base.ImageConfigMixin, base.ConfigGuardedPhase @@ -203,7 +213,7 @@ class RunOSBuildThread(WorkerThread): # architecture, but we don't verify that. build_info = koji.koji_proxy.getBuild(build_id) for archive in koji.koji_proxy.listArchives(buildID=build_id): - if archive["type_name"] not in EXTENSIONS: + if archive["type_name"] not in OSBUILDEXTENSIONS: # Ignore values that are not of required types. continue @@ -241,7 +251,7 @@ class RunOSBuildThread(WorkerThread): linker.link(src_file, image_dest, link_type=compose.conf["link_type"]) - for suffix in EXTENSIONS[archive["type_name"]]: + for suffix in OSBUILDEXTENSIONS[archive["type_name"]]: if archive["filename"].endswith(suffix): break else: