def chroot_cmd(root: Path, *, options: Sequence[PathString] = ()) -> list[PathString]:
cmdline: list[PathString] = [
+ # No exec here because we need to clean up the /work directory afterwards.
+ "sh", "-c", f"mkdir --mode=777 {root / 'work'} && $0 \"$@\" && rm -rf {root / 'work'}",
"bwrap",
"--dev-bind", root, "/",
"--setenv", "container", "mkosi",
cmdline += [
"--ro-bind", "/etc/resolv.conf", Path("/") / resolve,
*options,
- # No exec here because we need to clean up the /work directory afterwards.
- "sh", "-c", f"$0 \"$@\" && rm -rf {root / 'work'}",
]
return apivfs_cmd(root) + cmdline