#!/bin/bash # Compiles the kernel and stages all artifacts into /out/staging. # Runs inside Docker; kernel source is bind-mounted at /src. set -e # Clean host-built tool artifacts that may reference wrong include paths make -C tools/objtool clean 2>/dev/null || true make olddefconfig make -j"$(nproc)" bzImage modules # Stage all artifacts so downstream packagers don't need to run make echo "=== Staging build artifacts ===" rm -rf /out/staging mkdir -p /out/staging/boot cp arch/x86/boot/bzImage /out/staging/boot/ cp System.map /out/staging/ cp .config /out/staging/ make modules_install INSTALL_MOD_PATH=/out/staging INSTALL_MOD_STRIP=1 # Remove dangling symlinks back into the source tree KVER=$(make -s kernelrelease) rm -f "/out/staging/lib/modules/$KVER/build" \ "/out/staging/lib/modules/$KVER/source" echo "=== Build artifacts staged in /out/staging ==="