From: Daan De Meyer Date: Sun, 2 Jul 2023 21:59:06 +0000 (+0200) Subject: Inline dissect_and_mount() X-Git-Tag: v15~92^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=072cab346b7d7a925d3d703d6b86946ad6b71ee6;p=thirdparty%2Fmkosi.git Inline dissect_and_mount() Only has one caller, so let's just inline it. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 43ab95045..8ec89c995 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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}") diff --git a/mkosi/mounts.py b/mkosi/mounts.py index 1725cc487..50af271ac 100644 --- a/mkosi/mounts.py +++ b/mkosi/mounts.py @@ -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])