inputs/containers: change archive format to dir
The format so far was assumed to be `docker-archive` if the container was coming from a source and `oci-archive` if it was coming from a pipeline. The source format will now be changed to `dir` instead of `docker-archive`. The pipeline format remains `oci-archive`. With the new archive format being `dir`, the source can't be linked into the build root and is bind mounted instead with the use of a MountGuard created with the instance of the service, and torn down when the service is stopped. The _data field is removed from the map functions. It was unused and these functions aren't part of the abstract class so they don't need to have consistent signatures. Update the skopeo stage with support for the newly supported `dir` format.
This commit is contained in:
parent
998f640387
commit
5f76ec03a7
2 changed files with 21 additions and 10 deletions
|
|
@ -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:])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue