Let's instead just rely on it getting unmounted by the mkosi process
exiting and its mount namespace getting deleted.
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))
type: Optional[str] = None,
read_only: bool = False,
lazy: bool = False,
+ umount: bool = True,
) -> Iterator[Path]:
if not where.exists():
with umask(~0o755):
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
@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
operation="--bind",
read_only=True,
lazy=True,
+ umount=umount,
):
yield
finally: