From: Daan De Meyer Date: Thu, 14 Dec 2023 15:01:22 +0000 (+0100) Subject: Don't unmount final tools tree X-Git-Tag: v20~64^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2177%2Fhead;p=thirdparty%2Fmkosi.git Don't unmount final tools tree Let's instead just rely on it getting unmounted by the mkosi process exiting and its mount namespace getting deleted. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 0d1ca6609..aefff3eab 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -3189,7 +3189,7 @@ def run_verb(args: MkosiArgs, images: Sequence[MkosiConfig]) -> None: with contextlib.ExitStack() as stack: if os.getuid() == 0 and args.verb != Verb.ssh: init_mount_namespace() - stack.enter_context(mount_usr(last.tools_tree)) + stack.enter_context(mount_usr(last.tools_tree, umount=False)) stack.enter_context(prepend_to_environ_path(last)) diff --git a/mkosi/mounts.py b/mkosi/mounts.py index 26497b589..191774ab4 100644 --- a/mkosi/mounts.py +++ b/mkosi/mounts.py @@ -40,6 +40,7 @@ def mount( type: Optional[str] = None, read_only: bool = False, lazy: bool = False, + umount: bool = True, ) -> Iterator[Path]: if not where.exists(): with umask(~0o755): @@ -65,7 +66,8 @@ def mount( run(cmd) yield where finally: - run(["umount", "--no-mtab", *(["--lazy"] if lazy else []), where]) + if umount: + run(["umount", "--no-mtab", *(["--lazy"] if lazy else []), where]) @contextlib.contextmanager @@ -119,7 +121,7 @@ def mount_overlay( @contextlib.contextmanager -def mount_usr(tree: Optional[Path]) -> Iterator[None]: +def mount_usr(tree: Optional[Path], umount: bool = True) -> Iterator[None]: if not tree: yield return @@ -141,6 +143,7 @@ def mount_usr(tree: Optional[Path]) -> Iterator[None]: operation="--bind", read_only=True, lazy=True, + umount=umount, ): yield finally: