for tree in state.config.package_manager_trees:
install_tree(state, tree.source, state.workspace / "pkgmngr", tree.target)
+ # Ensure /etc exists in the package manager tree
+ (state.pkgmngr / "etc").mkdir(exist_ok=True)
+
def install_extra_trees(state: MkosiState) -> None:
if not state.config.extra_trees:
for p in state.config.extra_search_paths:
cmd += ["--tools", p]
- for d in ("etc/kernel", "usr/lib/kernel"):
- uki_config = state.pkgmngr / d / "uki.conf"
- if uki_config.exists():
- cmd += ["--config", uki_config]
-
if state.config.secure_boot:
assert state.config.secure_boot_key
assert state.config.secure_boot_certificate
def finalize_mounts(state: MkosiState) -> list[str]:
mounts = [
- (state.pkgmngr / subdir, Path("/") / subdir, True)
- for subdir in (
- Path("etc/apt"),
- Path("etc/rpm"),
- Path("etc/dnf"),
- Path("etc/pacman.conf"),
- Path("etc/pacman.d"),
- Path("etc/zypp"),
- Path("etc/yum.repos.d"),
- )
- if (state.pkgmngr / subdir).exists()
- ]
-
- dirs = [
- "/var/log/apt",
- "/var/lib/dnf",
- ]
-
- mounts += [
((state.config.tools_tree or Path("/")) / subdir, Path("/") / subdir, True)
for subdir in (
Path("etc/pki"),
["--ro-bind" if readonly else "--bind", os.fspath(src), os.fspath(target)]
for src, target, readonly
in sorted(set(mounts), key=lambda s: s[1])
- ) + flatten(["--dir", d] for d in dirs)
+ )
def bwrap(
"bwrap",
"--ro-bind", "/usr", "/usr",
"--ro-bind-try", "/nix/store", "/nix/store",
+ # This mount is writable so bwrap 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.
+ "--bind", state.pkgmngr / "etc", "/etc",
"--bind", "/var/tmp", "/var/tmp",
"--bind", "/tmp", "/tmp",
"--bind", Path.cwd(), Path.cwd(),
"-o", f"Dir::State={state.cache_dir / 'apt'}",
"-o", f"Dir::State::Status={state.root / 'var/lib/dpkg/status'}",
"-o", f"Dir::Etc::Trusted={trustedkeys}",
+ "-o", f"Dir::Log={state.workspace}",
"-o", f"Dir::Bin::DPkg={shutil.which('dpkg')}",
"-o", "Debug::NoLocking=true",
"-o", f"DPkg::Options::=--root={state.root}",
the default kernel commandline embedded in the kernel
and any previous `-append` specifications.
-`mkosi` builds a Unified Kernel Image (UKI).
-Further customization, e.g. a splash image, can be applied using a configuration
-for `ukify` in `/etc/kernel/uki.conf` inside the skeleton tree.
-`ukify` is run from the same working directory as mkosi itself.
-
The UKI is also copied into the output directory and may be booted directly:
```console
$ mkosi qemu -kernel mkosi.output/fedora~38/image.efi