diff --git a/inputs/org.osbuild.containers b/inputs/org.osbuild.containers index c50006c7..d1e642ed 100755 --- a/inputs/org.osbuild.containers +++ b/inputs/org.osbuild.containers @@ -21,6 +21,7 @@ import os import sys from osbuild import inputs +from osbuild.util.mnt import MountGuard SCHEMA = r""" "definitions": { @@ -159,15 +160,22 @@ SCHEMA = r""" class ContainersInput(inputs.InputService): - @staticmethod - def map_source_ref(source, ref, _data, target): - cache_dir = os.path.join(source, ref) - os.link(os.path.join(cache_dir, "container-image.tar"), os.path.join(target, ref)) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.mg = MountGuard() - return ref, "docker-archive" + def map_source_ref(self, source, ref, target): + source_archive = os.path.join(source, ref, "image") + dest = os.path.join(target, ref) + + # bind mount the input directory to the destination + os.makedirs(dest) + self.mg.mount(source_archive, dest) + + return ref, "dir" @staticmethod - def map_pipeline_ref(store, ref, _data, target): + def map_pipeline_ref(store, ref, target): # prepare the mount point os.makedirs(target, exist_ok=True) print("target", target) @@ -188,9 +196,9 @@ class ContainersInput(inputs.InputService): for ref, data in refs.items(): if origin == "org.osbuild.source": - ref, container_format = self.map_source_ref(source, ref, data, target) + ref, container_format = self.map_source_ref(source, ref, target) else: - ref, container_format = self.map_pipeline_ref(store, ref, data, target) + ref, container_format = self.map_pipeline_ref(store, ref, target) images[ref] = { "format": container_format, @@ -206,6 +214,9 @@ class ContainersInput(inputs.InputService): } return reply + def unmap(self): + self.mg.umount() + def main(): service = ContainersInput.from_args(sys.argv[1:]) diff --git a/stages/org.osbuild.skopeo b/stages/org.osbuild.skopeo index 0ed5e027..33233715 100755 --- a/stages/org.osbuild.skopeo +++ b/stages/org.osbuild.skopeo @@ -85,8 +85,8 @@ def main(inputs, output, options): linkname = os.path.join(tmpdir, "image.tar") os.symlink(source, linkname) - if container_format == "docker-archive": - source = f"docker-archive:{linkname}" + if container_format == "dir": + source = f"dir:{linkname}" elif container_format == "oci-archive": source = f"oci-archive:{linkname}" else: