diff --git a/iso/builder/Dockerfile b/iso/builder/Dockerfile index 48a16ae..13c6f8a 100644 --- a/iso/builder/Dockerfile +++ b/iso/builder/Dockerfile @@ -1,7 +1,6 @@ FROM debian:12 ARG GO_VERSION=1.24.0 -ARG DEBIAN_KERNEL_ABI=6.1.0-43 ENV DEBIAN_FRONTEND=noninteractive @@ -24,7 +23,7 @@ RUN apt-get update -qq && apt-get install -y \ gcc \ make \ perl \ - "linux-headers-${DEBIAN_KERNEL_ABI}-amd64" \ + linux-headers-amd64 \ && rm -rf /var/lib/apt/lists/* RUN arch="$(dpkg --print-architecture)" \ diff --git a/iso/builder/build-in-container.sh b/iso/builder/build-in-container.sh index 4e0769d..26940bc 100755 --- a/iso/builder/build-in-container.sh +++ b/iso/builder/build-in-container.sh @@ -59,7 +59,6 @@ IMAGE_REF="${IMAGE_TAG}:debian${DEBIAN_VERSION}" if [ "$REBUILD_IMAGE" = "1" ] || ! "$CONTAINER_TOOL" image inspect "${IMAGE_REF}" >/dev/null 2>&1; then "$CONTAINER_TOOL" build \ --build-arg GO_VERSION="${GO_VERSION}" \ - --build-arg DEBIAN_KERNEL_ABI="${DEBIAN_KERNEL_ABI}" \ -t "${IMAGE_REF}" \ "${BUILDER_DIR}" else diff --git a/iso/builder/build.sh b/iso/builder/build.sh index e8e5a0d..e79fbe1 100755 --- a/iso/builder/build.sh +++ b/iso/builder/build.sh @@ -34,18 +34,27 @@ mkdir -p "${CACHE_ROOT}" : "${GOMODCACHE:=${CACHE_ROOT}/go-mod}" export GOCACHE GOMODCACHE -# Auto-detect kernel ABI from apt when not pinned explicitly. +# Auto-detect kernel ABI: refresh apt index, then query current linux-image-amd64 dependency. +# If headers for the detected ABI are not yet installed (kernel updated since image build), +# install them on the fly so NVIDIA modules and ISO kernel always match. if [ -z "${DEBIAN_KERNEL_ABI}" ] || [ "${DEBIAN_KERNEL_ABI}" = "auto" ]; then + echo "=== refreshing apt index to detect current kernel ABI ===" + apt-get update -qq DEBIAN_KERNEL_ABI=$(apt-cache depends linux-image-amd64 2>/dev/null \ | awk '/Depends:.*linux-image-[0-9]/{print $2}' \ | grep -oE '[0-9]+\.[0-9]+\.[0-9]+-[0-9]+' \ | head -1) if [ -z "${DEBIAN_KERNEL_ABI}" ]; then echo "ERROR: could not auto-detect kernel ABI from apt-cache" >&2 - echo " Run: apt-cache depends linux-image-amd64" >&2 exit 1 fi - echo "=== kernel ABI auto-detected: ${DEBIAN_KERNEL_ABI} ===" + echo "=== kernel ABI: ${DEBIAN_KERNEL_ABI} ===" +fi + +KVER="${DEBIAN_KERNEL_ABI}-amd64" +if [ ! -d "/usr/src/linux-headers-${KVER}" ]; then + echo "=== installing linux-headers-${KVER} (kernel updated since image build) ===" + apt-get install -y "linux-headers-${KVER}" fi echo "=== bee ISO build ==="