From 29397efcecf3d17f55482373b77d3fe93631e337 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 18 Feb 2020 18:31:34 +0100 Subject: [PATCH] pipeline: implement get_buildtree like store.get Refactor `get_buildtree` to do input/output via `Object`, i.e. by creating a new `Object`, setting its base accordingly and then use its `read` and `write` methods. This is what `ObjectStore.get` does as well. In the case that there is no build pipeline, use the mount helpers of `objectstore` instead of the custom mount calls. --- osbuild/pipeline.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/osbuild/pipeline.py b/osbuild/pipeline.py index f10d7c11..58eb36a2 100644 --- a/osbuild/pipeline.py +++ b/osbuild/pipeline.py @@ -228,15 +228,17 @@ class Pipeline: @contextlib.contextmanager def get_buildtree(self, object_store): if self.build: - with object_store.get(self.build.tree_id) as tree: - yield tree + with object_store.new() as tree: + tree.base = self.build.tree_id + with tree.read() as path: + yield path else: - with tempfile.TemporaryDirectory(dir=object_store.store) as tmp: - subprocess.run(["mount", "--make-private", "-o", "bind,ro,mode=0755", "/", tmp], check=True) + with object_store.tempdir() as tmp: + objectstore.mount("/", tmp) try: yield tmp finally: - subprocess.run(["umount", "--lazy", tmp], check=True) + objectstore.umount(tmp) def run(self, store, interactive=False, libdir=None, secrets=None): os.makedirs("/run/osbuild", exist_ok=True)