fixup! build: split NVIDIA rootfs into base-nvidia image + gpu addon

This commit is contained in:
Fabiano Fidêncio
2026-06-11 14:44:22 +02:00
parent 331af65a9d
commit b4949703f2
2 changed files with 42 additions and 8 deletions

View File

@@ -553,6 +553,38 @@ chisseled_veritysetup() {
cp -a "${stage_one}/${libdir}"/libcap.so.2* "${libdir}/."
}
# NVRC loads each addon's NVIDIA kernel modules from that addon's self-contained
# module tree via `modprobe --dirname <addon>` (a kmod feature). The base ships
# busybox, whose modprobe is built without long options and has no --dirname, so
# the base must carry the real kmod. This keeps modules composable: every
# module-bearing addon stays independent (its own modules.dep from depmod -b) and
# nothing has to shadow the read-only /lib/modules. kmod is a single multi-call
# binary that embeds libkmod (no libkmod2 to ship); modprobe/insmod/... are
# argv[0] symlinks to it. Runs inside ${ROOTFS_DIR}.
chisseled_kmod() {
echo "nvidia: chisseling kmod"
local libdir="lib/${machine_arch}-linux-gnu"
cp -a "${stage_one}/usr/bin/kmod" usr/bin/.
# kmod picks its applet from argv[0]. Expose the module tools as symlinks;
# /sbin/modprobe (NVRC's absolute path) shadows the busybox modprobe applet.
# Absolute targets so they resolve regardless of whether /sbin is a real dir
# or a usr-merge symlink.
local tool
for tool in modprobe insmod rmmod depmod lsmod; do
ln -sf /usr/bin/kmod "sbin/${tool}"
done
# kmod links libzstd/liblzma unconditionally (compressed-module support);
# our modules are uncompressed but the NEEDED entries must still resolve.
# libcrypto/libc are already present (libc from chisseled_compute, libcrypto
# from chisseled_veritysetup).
cp -a "${stage_one}/${libdir}"/libzstd.so.1* "${libdir}/."
cp -a "${stage_one}/${libdir}"/liblzma.so.5* "${libdir}/."
}
setup_nvidia_gpu_rootfs_stage_two() {
readonly stage_two="${ROOTFS_DIR:?}"
readonly stack="${NVIDIA_GPU_STACK:?}"
@@ -617,7 +649,7 @@ setup_nvidia_gpu_rootfs_stage_two() {
# Carve the freshly chiseled (monolith) tree into the requested layout.
# The monolith path is left untouched.
case "${layout}" in
base) partition_base; chisseled_veritysetup ;;
base) partition_base; chisseled_veritysetup; chisseled_kmod ;;
gpu-addon) partition_gpu_addon ;;
esac
fi

View File

@@ -564,14 +564,18 @@ CONFIG_FEATURE_DEFAULT_PASSWD_ALGO=""
# CONFIG_LSMOD is not set
# CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
# CONFIG_MODINFO is not set
CONFIG_MODPROBE=y
CONFIG_FEATURE_MODPROBE_BLACKLIST=y
# CONFIG_MODPROBE is not set
# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
# CONFIG_RMMOD is not set
#
# Options common to multiple modutils
#
CONFIG_FEATURE_CMDLINE_MODULE_OPTIONS=y
# The base-nvidia image ships the real kmod (modprobe/insmod/...) so that NVRC
# can load each addon's modules with `modprobe --dirname <addon>`; busybox's
# modprobe lacks long options (no --dirname), so all busybox modutils are
# disabled here to avoid a dead, conflicting applet shadowing kmod.
# CONFIG_FEATURE_CMDLINE_MODULE_OPTIONS is not set
# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
# CONFIG_FEATURE_2_4_MODULES is not set
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
@@ -581,10 +585,8 @@ CONFIG_FEATURE_CMDLINE_MODULE_OPTIONS=y
# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
# CONFIG_FEATURE_INSMOD_TRY_MMAP is not set
CONFIG_FEATURE_MODUTILS_ALIAS=y
CONFIG_FEATURE_MODUTILS_SYMBOLS=y
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
# CONFIG_FEATURE_MODUTILS_ALIAS is not set
# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
#
# Linux System Utilities