Module extract

Module extract 

Source
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-core carries vmlinuz, config, System.map, and modules.builtin under /lib/modules/<release>/; the loadable .ko.xz modules live in separate kernel-modules-core / kernel-modules rpms (verified against Fedora 44 packages). A kernel-debuginfo rpm carries vmlinux under /usr/lib/debug/.
  • Ubuntu / Debian: the image lives in linux-image-* (under /boot/) and the modules in linux-modules-* (under /lib/modules/, or /usr/lib/modules/ on usrmerge packages); the two debs merge into one tree. A -dbgsym ddeb contributes vmlinux.
  • Arch / SteamOS: a pacman .pkg.tar.zst is a plain zstd-compressed tarball; linux-neptune-* carries vmlinuz and the module tree under /usr/lib/modules/<release>/ (usrmerge) with the package arch in the .PKGINFO member’s arch = field (verified against a live jupiter-3.8 package). No kernel .config is 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§

ExtractedKernel
The artifacts recovered from one or more kernel packages.

Functions§

ensure_arch_matches_host
Error unless pkg_arch matches the compile-time host architecture (see crate::fetch::arch_info).
extract_kernel_packages
Extract one or more kernel packages into dest and locate the bootable artifacts.
extract_vmlinux
Extract debuginfo package(s) into dest — merging onto a kernel tree already materialized there by extract_kernel_packages — and return the vmlinux path they carry, if any.
module_closure
Resolve the transitive .ko dependency closure for wanted modules, in load order (dependencies first).
package_arch
Package architecture as spelled by the package itself (x86_64/aarch64 for rpm, amd64/arm64 for deb).