Expand description
Extraction of prebuilt distro kernel packages (.rpm / .deb).
Given one or more downloaded/local kernel packages, this module
materializes the filesystem tree they carry into a destination
directory and locates the artifacts ktstr needs to boot a VM:
the bootable image, module tree, kernel config, System.map, and
(from a debuginfo package) vmlinux.
§Package shapes
- Fedora / RHEL:
kernel-corecarriesvmlinuz,config,System.map, andmodules.builtinunder/lib/modules/<release>/; the loadable.ko.xzmodules live in separatekernel-modules-core/kernel-modulesrpms (verified against Fedora 44 packages). Akernel-debuginforpm carriesvmlinuxunder/usr/lib/debug/. - Ubuntu / Debian: the image lives in
linux-image-*(under/boot/) and the modules inlinux-modules-*(under/lib/modules/, or/usr/lib/modules/on usrmerge packages); the two debs merge into one tree. A-dbgsymddeb contributesvmlinux. - Arch / SteamOS: a pacman
.pkg.tar.zstis a plain zstd-compressed tarball;linux-neptune-*carriesvmlinuzand the module tree under/usr/lib/modules/<release>/(usrmerge) with the package arch in the.PKGINFOmember’sarch =field (verified against a live jupiter-3.8 package). No kernel.configis shipped and there is no debuginfo package.
None of these distros ship modules.dep in the package — depmod
generates it at install time — so extraction synthesizes it in
process from each module’s .modinfo section (see
ensure_modules_dep), without relying on a host depmod.
§Compression
The rpm crate parses package headers; the raw cpio payload is
decompressed here with the already-vendored xz2/zstd/flate2 stack
(Fedora kernels ship xz payloads, newer ones zstd) rather than
pulling rpm’s own liblzma backend. deb data.tar[.xz|.zst|.gz]
members are streamed through the same vendored decoders.
§Hardening
Every archive entry path is sanitized before it touches disk:
.. components are a hard error and absolute anchors are stripped
so a payload path like /lib/modules/... lands under the
destination rather than at the filesystem root. Symlinks whose
target would resolve outside the destination tree are skipped
rather than created. This mirrors the tarball-extraction rigor in
crate::fetch and crate::cgroup.
Structs§
- Extracted
Kernel - The artifacts recovered from one or more kernel packages.
Functions§
- ensure_
arch_ matches_ host - Error unless
pkg_archmatches the compile-time host architecture (seecrate::fetch::arch_info). - extract_
kernel_ packages - Extract one or more kernel packages into
destand locate the bootable artifacts. - extract_
vmlinux - Extract debuginfo package(s) into
dest— merging onto a kernel tree already materialized there byextract_kernel_packages— and return thevmlinuxpath they carry, if any. - module_
closure - Resolve the transitive
.kodependency closure forwantedmodules, in load order (dependencies first). - package_
arch - Package architecture as spelled by the package itself
(
x86_64/aarch64for rpm,amd64/arm64for deb).