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:
parent
bcd937d16d
commit
b032425f30
@ -169,19 +169,14 @@ class RunKiwiBuildThread(WorkerThread):
|
||||
|
||||
# Process all images in the build. There should be one for each
|
||||
# architecture, but we don't verify that.
|
||||
build_info = koji.koji_proxy.listBuilds(taskID=task_id)[0]
|
||||
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
|
||||
paths = koji.get_image_paths(task_id)
|
||||
|
||||
# HACK: there's no metadata telling which image is for which
|
||||
# architecture, so we need to check the filename.
|
||||
for arch in arches:
|
||||
if arch in archive["filename"]:
|
||||
break
|
||||
else:
|
||||
raise RuntimeError("Image doesn't have any architecture!")
|
||||
for arch, paths in paths.items():
|
||||
for path in paths:
|
||||
type_, suffix = _find_suffix(path)
|
||||
if not suffix:
|
||||
# Path doesn't match any know type.
|
||||
continue
|
||||
|
||||
# image_dir is absolute path to which the image should be copied.
|
||||
# We also need the same path as relative to compose directory for
|
||||
@ -192,35 +187,22 @@ class RunKiwiBuildThread(WorkerThread):
|
||||
) % {"arch": arch}
|
||||
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(
|
||||
os.path.join(
|
||||
koji.koji_module.pathinfo.imagebuild(build_info),
|
||||
archive["filename"],
|
||||
),
|
||||
)
|
||||
image_dest = os.path.join(image_dir, filename)
|
||||
|
||||
src_file = compose.koji_downloader.get_file(path)
|
||||
|
||||
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
|
||||
img = Image(compose.im)
|
||||
|
||||
# Get the manifest type from the config if supplied, otherwise we
|
||||
# determine the manifest type based on the koji output
|
||||
img.type = archive["type_name"]
|
||||
img.type = type_
|
||||
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.size = util.get_file_size(image_dest)
|
||||
img.arch = arch
|
||||
@ -229,7 +211,15 @@ class RunKiwiBuildThread(WorkerThread):
|
||||
img.bootable = False
|
||||
img.subvariant = config.get("subvariant", variant.uid)
|
||||
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)
|
||||
|
||||
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
|
||||
|
@ -612,6 +612,7 @@ class KojiWrapper(object):
|
||||
"createImage",
|
||||
"createLiveMedia",
|
||||
"createAppliance",
|
||||
"createKiwiImage",
|
||||
]:
|
||||
continue
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user