make the rootfs tarball the main artifact for Containers

This commit is contained in:
Neil Hanlon 2024-05-08 16:47:32 -04:00
parent 1d75180a86
commit 163cd9ef66
Signed by: neil
GPG Key ID: 705BC21EC3C70F34

View File

@ -130,6 +130,10 @@ class KiwiBackend(BackendInterface):
source = utils.remove_first_directory(source) source = utils.remove_first_directory(source)
dest = f"{self.ctx.outdir}/{self.ctx.outname}.{filetype}" dest = f"{self.ctx.outdir}/{self.ctx.outname}.{filetype}"
# NOTE(neil): only because we are preparing the 'final' image in clean step...
if self.ctx.image_type == 'Container':
dest = f"{self.ctx.outdir}/{self.ctx.outname}.oci"
try: try:
shutil.move(source, dest) shutil.move(source, dest)
except Exception as e: except Exception as e:
@ -145,6 +149,15 @@ class KiwiBackend(BackendInterface):
raise e raise e
def clean(self): def clean(self):
# TODO(neil): refactor
if self.ctx.image_type == 'Container':
# need to do this before we remove it, otherwise we have to extract from the OCI tarball
root = f"/builddir{self.ctx.outdir}"
builddir = f"{root}/build/image-root"
ret, out, err = self.run_mock_command(["--shell", "--", "tar", "-C", builddir, "-cJf", f"{root}/{self.ctx.outname}.tar.xz", "."])
if ret > 0:
raise Exception(err)
ret, out, err = self.run_mock_command(["--shell", "rm", "-fr", f"/builddir/{self.ctx.outdir}/build/"]) ret, out, err = self.run_mock_command(["--shell", "rm", "-fr", f"/builddir/{self.ctx.outdir}/build/"])
return ret return ret