From ef7363f53cfe15c18d497952460b8ad9b94d6494 Mon Sep 17 00:00:00 2001 From: Jan De Landtsheer Date: Tue, 19 Aug 2025 18:27:32 +0200 Subject: [PATCH] Add chroot depmod for proper module dependencies in initramfs - Added chroot + depmod -a step in setup-initramfs.sh before cpio creation - Generates module dependencies within the actual initramfs environment - Includes bind mounting of /proc, /sys, /dev for proper chroot operation - Ensures TUN module and all network modules have correct dependencies - Complements existing build-time depmod in install-firmware-minimal.sh --- scripts/setup-initramfs.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/setup-initramfs.sh b/scripts/setup-initramfs.sh index 7c8a801..2b359d0 100755 --- a/scripts/setup-initramfs.sh +++ b/scripts/setup-initramfs.sh @@ -270,6 +270,30 @@ rm -rf run ln -sf ../run run || true cd "$INITRAMFS_ROOT" +# Generate module dependencies within the initramfs environment +echo " Generating module dependencies in chroot environment..." +KERNEL_VERSION=$(cat /build/configs/kernel-version) +if [ -d "$INITRAMFS_ROOT/lib/modules/${KERNEL_VERSION}-Zero-OS" ]; then + # Bind mount necessary filesystems for chroot + mount --bind /proc "$INITRAMFS_ROOT/proc" 2>/dev/null || true + mount --bind /sys "$INITRAMFS_ROOT/sys" 2>/dev/null || true + mount --bind /dev "$INITRAMFS_ROOT/dev" 2>/dev/null || true + + # Run depmod in chroot to generate dependencies + if chroot "$INITRAMFS_ROOT" /sbin/depmod -a "${KERNEL_VERSION}-Zero-OS" 2>/dev/null; then + echo " ✓ Module dependencies generated successfully" + else + echo " Warning: Failed to generate module dependencies in chroot" + fi + + # Cleanup bind mounts + umount "$INITRAMFS_ROOT/proc" 2>/dev/null || true + umount "$INITRAMFS_ROOT/sys" 2>/dev/null || true + umount "$INITRAMFS_ROOT/dev" 2>/dev/null || true +else + echo " Warning: No kernel modules directory found, skipping depmod" +fi + # Create initramfs archive echo "[+] Creating initramfs archive..." cd "$INITRAMFS_ROOT"