kiwibuild: Process images same as image-build

Getting the images from task is less hacky then matching on filenames.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2024-02-29 10:48:26 +01:00
parent bcd937d16d
commit b032425f30
2 changed files with 45 additions and 54 deletions

View File

@ -169,19 +169,14 @@ class RunKiwiBuildThread(WorkerThread):
# Process all images in the build. There should be one for each # Process all images in the build. There should be one for each
# architecture, but we don't verify that. # architecture, but we don't verify that.
build_info = koji.koji_proxy.listBuilds(taskID=task_id)[0] paths = koji.get_image_paths(task_id)
for archive in koji.koji_proxy.listArchives(buildID=build_info["build_id"]):
if archive["type_name"] not in EXTENSIONS:
# Ignore values that are not of required types.
continue
# HACK: there's no metadata telling which image is for which for arch, paths in paths.items():
# architecture, so we need to check the filename. for path in paths:
for arch in arches: type_, suffix = _find_suffix(path)
if arch in archive["filename"]: if not suffix:
break # Path doesn't match any know type.
else: continue
raise RuntimeError("Image doesn't have any architecture!")
# image_dir is absolute path to which the image should be copied. # image_dir is absolute path to which the image should be copied.
# We also need the same path as relative to compose directory for # We also need the same path as relative to compose directory for
@ -192,35 +187,22 @@ class RunKiwiBuildThread(WorkerThread):
) % {"arch": arch} ) % {"arch": arch}
util.makedirs(image_dir) util.makedirs(image_dir)
image_dest = os.path.join(image_dir, archive["filename"]) filename = os.path.basename(path)
src_file = compose.koji_downloader.get_file( image_dest = os.path.join(image_dir, filename)
os.path.join(
koji.koji_module.pathinfo.imagebuild(build_info), src_file = compose.koji_downloader.get_file(path)
archive["filename"],
),
)
linker.link(src_file, image_dest, link_type=compose.conf["link_type"]) linker.link(src_file, image_dest, link_type=compose.conf["link_type"])
for suffix in EXTENSIONS[archive["type_name"]]:
if archive["filename"].endswith(suffix):
break
else:
# No suffix matched.
raise RuntimeError(
"Failed to generate metadata. Format %s doesn't match type %s"
% (suffix, archive["type_name"])
)
# 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 # Get the manifest type from the config if supplied, otherwise we
# determine the manifest type based on the koji output # determine the manifest type based on the koji output
img.type = archive["type_name"] img.type = type_
img.format = suffix img.format = suffix
img.path = os.path.join(rel_image_dir, archive["filename"]) img.path = os.path.join(rel_image_dir, filename)
img.mtime = util.get_mtime(image_dest) img.mtime = util.get_mtime(image_dest)
img.size = util.get_file_size(image_dest) img.size = util.get_file_size(image_dest)
img.arch = arch img.arch = arch
@ -229,7 +211,15 @@ class RunKiwiBuildThread(WorkerThread):
img.bootable = False img.bootable = False
img.subvariant = config.get("subvariant", variant.uid) img.subvariant = config.get("subvariant", variant.uid)
setattr(img, "can_fail", self.can_fail) setattr(img, "can_fail", self.can_fail)
setattr(img, "deliverable", "image-build") setattr(img, "deliverable", "kiwibuild")
compose.im.add(variant=variant.uid, arch=arch, image=img) compose.im.add(variant=variant.uid, arch=arch, image=img)
self.pool.log_info("[DONE ] %s (task id: %s)" % (msg, task_id)) self.pool.log_info("[DONE ] %s (task id: %s)" % (msg, task_id))
def _find_suffix(path):
for type_, suffixes in EXTENSIONS.items():
for suffix in suffixes:
if path.endswith(suffix):
return type_, suffix
return None, None

View File

@ -612,6 +612,7 @@ class KojiWrapper(object):
"createImage", "createImage",
"createLiveMedia", "createLiveMedia",
"createAppliance", "createAppliance",
"createKiwiImage",
]: ]:
continue continue