return [
"--tmpfs", root / "run",
"--tmpfs", root / "tmp",
- "--bind", "/var/tmp", root / "var/tmp",
"--proc", root / "proc",
"--dev", root / "dev",
# Nudge gpg to create its sockets in /run by making sure /run/user/0 exists.
"python3" if tools or not exe.is_relative_to("/usr") else exe, "-SI", "/sandbox.py",
"--bind", "/", "/",
"--same-dir",
+ "--bind", "/var/tmp", "/buildroot/var/tmp",
*apivfs_options(),
*options,
"--",
]
-def chroot_options(*, network: bool = False) -> list[PathString]:
+def chroot_options() -> list[PathString]:
return [
# Let's always run as (fake) root when we chroot inside the image as tools executed within the image could
# have builtin assumptions about files being owned by root.
"--setenv", "container", "mkosi",
"--setenv", "HOME", "/",
"--setenv", "PATH", "/usr/bin:/usr/sbin",
- *(["--ro-bind-try", "/etc/resolv.conf", "/etc/resolv.conf"] if network else []),
"--setenv", "BUILDROOT", "/",
]
"--unsetenv", "TMPDIR",
*network_options(network=network),
*apivfs_options(root=Path("/")),
- *chroot_options(network=network),
+ *chroot_options(),
]
if network and Path("/etc/resolv.conf").exists():
return [
"python3" if tools or not exe.is_relative_to("/usr") else exe, "-SI", "/sandbox.py",
"--bind", "/buildroot", "/",
+ "--bind", "/var/tmp", "/var/tmp",
*apivfs_options(root=Path("/")),
- *chroot_options(network=network),
+ *chroot_options(),
*(["--bind", "/work", "/work", "--chdir", "/work/src"] if work else []),
+ *(["--ro-bind-try", "/etc/resolv.conf", "/etc/resolv.conf"] if network else []),
"--",
]