env=env | config.environment,
sandbox=config.sandbox(
binary=None,
+ vartmp=True,
mounts=[*sources, Mount(script, "/work/configure", ro=True)],
options=["--dir", "/work/src", "--chdir", "/work/src"]
),
sandbox=context.sandbox(
binary=None,
network=True,
+ vartmp=True,
mounts=mounts,
options=["--dir", "/work/src", "--chdir", "/work/src"]
),
sandbox=context.sandbox(
binary=None,
network=True,
+ vartmp=True,
mounts=[
*sources,
Mount(script, "/work/prepare", ro=True),
sandbox=context.sandbox(
binary=None,
network=context.config.with_network,
+ vartmp=True,
mounts=[
*sources,
Mount(script, "/work/build-script", ro=True),
sandbox=context.sandbox(
binary=None,
network=context.config.with_network,
+ vartmp=True,
mounts=[
*sources,
Mount(script, "/work/postinst", ro=True),
sandbox=context.sandbox(
binary=None,
network=context.config.with_network,
+ vartmp=True,
mounts=[
*sources,
Mount(script, "/work/finalize", ro=True),
env=env | context.config.environment,
sandbox=context.sandbox(
binary=None,
+ vartmp=True,
mounts=[
*sources,
Mount(script, "/work/postoutput", ro=True),
not context.config.repart_offline or
context.config.verity_key_source.type != KeySource.Type.file
),
+ vartmp=True,
mounts=mounts,
),
).stdout
not context.config.repart_offline or
context.config.verity_key_source.type != KeySource.Type.file
),
+ vartmp=True,
mounts=mounts,
),
).stdout
def sandbox(
*,
binary: Optional[PathString],
+ vartmp: bool = False,
mounts: Sequence[Mount] = (),
extra: Sequence[PathString] = (),
) -> AbstractContextManager[list[PathString]]:
- return context.sandbox(binary=binary, mounts=[*mounts, *exclude], extra=extra)
+ return context.sandbox(binary=binary, vartmp=vartmp, mounts=[*mounts, *exclude], extra=extra)
copy_tree(
src, dst,
binary="systemd-repart",
network=True,
devices=True,
+ vartmp=True,
mounts=[Mount(fname, fname)],
),
)
env=env | config.environment,
sandbox=config.sandbox(
binary=None,
+ vartmp=True,
tools=False,
mounts=[
*sources,
binary: Optional[PathString],
network: bool = False,
devices: bool = False,
+ vartmp: bool = False,
relaxed: bool = False,
tools: bool = True,
scripts: Optional[Path] = None,
return sandbox_cmd(
network=network,
devices=devices,
+ vartmp=vartmp,
relaxed=relaxed,
scripts=scripts,
tools=self.tools() if tools else Path("/"),
binary: Optional[PathString],
network: bool = False,
devices: bool = False,
+ vartmp: bool = False,
scripts: Optional[Path] = None,
mounts: Sequence[Mount] = (),
options: Sequence[PathString] = (),
binary=binary,
network=network,
devices=devices,
+ vartmp=vartmp,
scripts=scripts,
mounts=[
# This mount is writable so bubblewrap can create extra directories or symlinks inside of it as needed.
context.sandbox(
binary="apt-get",
network=True,
+ vartmp=True,
mounts=[Mount(context.root, "/buildroot"), *cls.mounts(context), *sources, *mounts],
options=["--dir", "/work/src", "--chdir", "/work/src"],
extra=apivfs_cmd() if apivfs else []
context.sandbox(
binary=cls.executable(context.config),
network=True,
+ vartmp=True,
mounts=[Mount(context.root, "/buildroot"), *cls.mounts(context), *sources],
options=["--dir", "/work/src", "--chdir", "/work/src"],
extra=apivfs_cmd() if apivfs else [],
context.sandbox(
binary="pacman",
network=True,
+ vartmp=True,
mounts=[Mount(context.root, "/buildroot"), *cls.mounts(context), *sources],
options=["--dir", "/work/src", "--chdir", "/work/src"],
extra=apivfs_cmd() if apivfs else [],
context.sandbox(
binary="zypper",
network=True,
+ vartmp=True,
mounts=[Mount(context.root, "/buildroot"), *cls.mounts(context), *sources],
options=["--dir", "/work/src", "--chdir", "/work/src"],
extra=apivfs_cmd() if apivfs else [],
],
sandbox=config.sandbox(
binary="systemd-repart",
+ vartmp=True,
mounts=[Mount(fname.parent, fname.parent), Mount(src, src, ro=True)],
),
)
self,
*,
binary: Optional[PathString],
+ vartmp: bool = False,
mounts: Sequence[Mount] = (),
extra: Sequence[PathString] = (),
) -> AbstractContextManager[list[PathString]]: ...
def nosandbox(
*,
binary: Optional[PathString],
+ vartmp: bool = False,
mounts: Sequence[Mount] = (),
extra: Sequence[PathString] = (),
) -> AbstractContextManager[list[PathString]]:
*,
network: bool = False,
devices: bool = False,
+ vartmp: bool = False,
scripts: Optional[Path] = None,
tools: Path = Path("/"),
relaxed: bool = False,
cmdline: list[PathString] = []
mounts = list(mounts)
- if not relaxed:
+ if vartmp and not relaxed:
# We want to use an empty subdirectory in the host's temporary directory as the sandbox's /var/tmp.
vartmpdir = Path(os.getenv("TMPDIR", "/var/tmp")) / f"mkosi-var-tmp-{uuid.uuid4().hex[:16]}"
else:
if relaxed:
mounts += [Mount("/tmp", "/tmp")]
else:
- cmdline += ["--dir", "/tmp", "--unshare-ipc"]
+ cmdline += ["--dir", "/tmp", "--dir", "/var/tmp", "--unshare-ipc"]
if (tools / "nix/store").exists():
mounts += [Mount(tools / "nix/store", "/nix/store")]