# Ensure /etc exists in the package manager tree
(context.pkgmngr / "etc").mkdir(exist_ok=True)
+ # Backwards compatibility symlink.
+ (context.pkgmngr / "etc/mtab").symlink_to("../proc/self/mounts")
+
# Required to be able to access certificates in the sandbox when running from nix.
if Path("/etc/static").is_symlink():
(context.pkgmngr / "etc/static").symlink_to(Path("/etc/static").readlink())
devices=devices,
scripts=scripts,
mounts=[
- # These mounts are writable so bubblewrap can create extra directories or symlinks inside of it as
- # needed. This isn't a problem as the package manager directory is created by mkosi and thrown away
- # when the build finishes.
- *[
- Mount(self.pkgmngr / "etc" / p.name, f"/etc/{p.name}")
- for p in (self.pkgmngr / "etc").iterdir()
- ],
- *mounts,
+ # This mount is writable so bubblewrap can create extra directories or symlinks inside of it as needed.
+ # This isn't a problem as the package manager directory is created by mkosi and thrown away when the
+ # build finishes.
+ Mount(self.pkgmngr / "etc", "/etc"),
Mount(self.pkgmngr / "var/log", "/var/log"),
*([Mount(p, p, ro=True)] if (p := self.pkgmngr / "usr").exists() else []),
+ *mounts,
],
options=[
"--uid", "0",
cmdline += ["--setenv", "PATH", f"/scripts:{path}", *options]
- if not relaxed:
- cmdline += ["--symlink", "../proc/self/mounts", "/etc/mtab"]
-
# If we're using /usr from a tools tree, we have to use /etc/alternatives from the tools tree as well if it
# exists since that points directly back to /usr. Apply this after the options so the caller can mount
# something else to /etc without overriding this mount. In relaxed mode, we only do this if /etc/alternatives
cmdline += finalize_mounts(mounts)
+ if not any(Path(m.dst) == Path("/etc") for m in mounts):
+ cmdline += ["--symlink", "../proc/self/mounts", "/etc/mtab"]
+
# bubblewrap creates everything with a restricted mode so relax stuff as needed.
ops = []
if not devices and not relaxed: