]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Inline dissect_and_mount()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 2 Jul 2023 21:59:06 +0000 (23:59 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 3 Jul 2023 12:02:45 +0000 (14:02 +0200)
Only has one caller, so let's just inline it.

mkosi/__init__.py
mkosi/mounts.py

index 43ab95045b4e37d8cfd5d4423586f494dced43d9..8ec89c9952c0c76c54e8dcb7c07ccdfd7184a906 100644 (file)
@@ -33,7 +33,7 @@ from mkosi.config import (
 from mkosi.install import add_dropin_config_from_resource, copy_path, flock
 from mkosi.log import Style, color_error, complete_step, die, log_step
 from mkosi.manifest import Manifest
-from mkosi.mounts import dissect_and_mount, mount_overlay, scandir_recursive
+from mkosi.mounts import mount_overlay, scandir_recursive
 from mkosi.pager import page
 from mkosi.qemu import copy_ephemeral, machine_cid, run_qemu
 from mkosi.remove import unlink_try_hard
@@ -76,7 +76,8 @@ def mount_image(state: MkosiState) -> Iterator[None]:
                     shutil.unpack_archive(path, d)
                     bases += [d]
                 elif path.suffix == ".raw":
-                    stack.enter_context(dissect_and_mount(path, d))
+                    run(["systemd-dissect", "-M", path, d])
+                    stack.callback(lambda: run(["systemd-dissect", "-U", d]))
                     bases += [d]
                 else:
                     die(f"Unsupported base tree source {path}")
index 1725cc4870f7b3be2d59e7148e42a058b925770e..50af271ac4212256ea6eb227c4b308dc8749cbef 100644 (file)
@@ -107,10 +107,3 @@ def mount_overlay(
                 delete_whiteout_files(upperdir)
 
 
-@contextlib.contextmanager
-def dissect_and_mount(image: Path, where: Path) -> Iterator[Path]:
-    run(["systemd-dissect", "-M", image, where])
-    try:
-        yield where
-    finally:
-        run(["systemd-dissect", "-U", where])