]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Don't unmount final tools tree 2177/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 14 Dec 2023 15:01:22 +0000 (16:01 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 14 Dec 2023 15:34:11 +0000 (16:34 +0100)
Let's instead just rely on it getting unmounted by the mkosi process
exiting and its mount namespace getting deleted.

mkosi/__init__.py
mkosi/mounts.py

index 0d1ca660995759084ea5ca6542e4bb63e3297ad3..aefff3eabc2ef53de0a939126278451fcf1a331b 100644 (file)
@@ -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))
 
index 26497b589f8faf57f1e7db576e6a493732ebc2e0..191774ab411d072991029904b64a1b0640e2955f 100644 (file)
@@ -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: