From 23d8199e60cf9bc782640885f0158c20060b9726 Mon Sep 17 00:00:00 2001 From: Josh Schmelzle Date: Tue, 29 Sep 2026 17:11:24 -0400 Subject: [PATCH 1/3] headers package: build module-ready tree, drop uapi headers, depend on kernel --- AGENTS.md | 2 +- build-kernel.sh | 40 +++++++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d14c7a3..a58c5a5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -41,7 +41,7 @@ Pi 4 (BCM2711) uses 4KB pages; Pi 5 (BCM2712) uses 16KB pages — they are binar | `wlanpi-kernel-trixie-2712` | Pi 5 kernel only | Pi 5-only deployments | | `wlanpi-kernel-trixie` | Both kernels | wlanpi2-full (32GB+ SD, boots either hardware) | -Plus separate `wlanpi-kernel-headers-trixie-v8` and `wlanpi-kernel-headers-trixie-2712` packages. +Plus separate `wlanpi-kernel-headers-trixie-v8` and `wlanpi-kernel-headers-trixie-2712` packages for out-of-tree module builds. They hold the tree `scripts/package/install-extmod-build` collects (the same as `make bindeb-pkg`) and own `/lib/modules//build`; the kernel packages don't ship `build` or `source`. No `/usr/include` uapi headers: those belong to `linux-libc-dev`. Each headers package depends on its kernel package, or the dual package, at the exact same version. Package version is `-` (UTC build hour, e.g. `7.2.0-v8-wlanpi-2026092514`); the dual package uses the v8 kernelrelease. The hour lets several builds ship on one day; two builds in the same hour collide and packagecloud rejects the second push. diff --git a/build-kernel.sh b/build-kernel.sh index f2dcfb8..dc18cd2 100755 --- a/build-kernel.sh +++ b/build-kernel.sh @@ -295,6 +295,9 @@ build_kernel_variant() { echo "Installing modules to $MODULES_OUTPUT_DIR/$KERNEL_VERSION..." make INSTALL_MOD_PATH="$OUTPUT_PATH" modules_install + # modules_install links build/source to this tree (a CI runner path). + # The headers package owns build; the kernel package must not ship them. + rm -f "$MODULES_OUTPUT_DIR/$KERNEL_VERSION/build" "$MODULES_OUTPUT_DIR/$KERNEL_VERSION/source" echo "Building Device Tree Blobs (DTBs)..." make -j"$NUM_CORES" dtbs @@ -317,21 +320,25 @@ build_kernel_variant() { find arch/arm64/boot/dts/overlays/ -name '*.dtbo' -exec cp {} "$DTBO_OUTPUT_DIR" \; || true fi - # Prepare kernel headers + # Prepare kernel headers: the tree an out-of-tree module build needs + # (Makefile, arch/arm64, include/generated, Module.symvers, scripts), + # collected by the kernel's own helper as `make bindeb-pkg` does. + # No headers_install: those uapi headers belong to linux-libc-dev. echo "Preparing kernel headers for $KERNEL_VERSION..." local VARIANT_HEADERS_DIR="$HEADERS_OUTPUT_DIR/$KERNEL_VERSION" - mkdir -p "$VARIANT_HEADERS_DIR/usr/src/linux-headers-$KERNEL_VERSION" + local HEADERS_SRC_DIR="$VARIANT_HEADERS_DIR/usr/src/linux-headers-$KERNEL_VERSION" + rm -rf "$VARIANT_HEADERS_DIR" mkdir -p "$VARIANT_HEADERS_DIR/lib/modules/$KERNEL_VERSION" - - make ARCH="$ARCH" CROSS_COMPILE="$CROSS_COMPILE" \ - INSTALL_HDR_PATH="$VARIANT_HEADERS_DIR/usr" \ - headers_install - - cp -a "include" "$VARIANT_HEADERS_DIR/usr/src/linux-headers-$KERNEL_VERSION/" - cp -a "arch/$ARCH/include" "$VARIANT_HEADERS_DIR/usr/src/linux-headers-$KERNEL_VERSION/arch/" - cp Makefile "$VARIANT_HEADERS_DIR/usr/src/linux-headers-$KERNEL_VERSION/" - cp .config "$VARIANT_HEADERS_DIR/usr/src/linux-headers-$KERNEL_VERSION/" - cp -a scripts "$VARIANT_HEADERS_DIR/usr/src/linux-headers-$KERNEL_VERSION/" + # fixdep/modpost run on the Pi. Rebuild them with the target compiler + # only when cross-compiling from a non-arm64 host (needs arm64 libc, + # e.g. crossbuild-essential-arm64); on arm64 the host build already fits. + local EXTMOD_CC='$(CC)' + if [ "$(uname -m)" = aarch64 ]; then + EXTMOD_CC='$(HOSTCC)' + fi + make run-command \ + KBUILD_RUN_COMMAND="CC=$EXTMOD_CC \$(srctree)/scripts/package/install-extmod-build $HEADERS_SRC_DIR" + cp .config "$HEADERS_SRC_DIR/" # Create build symlink ln -sf "/usr/src/linux-headers-$KERNEL_VERSION" \ @@ -690,12 +697,19 @@ for KVER in "${HEADER_VERSIONS[@]}"; do cp -r "$HEADERS_OUTPUT_DIR/$KVER"/* "$HEADERS_PKG_DIR/" # Determine variant name and corresponding kernel package + # Headers only work with the exact kernel they were built with: that + # variant's package or the dual package from the same build. if [[ "$KVER" == *"v8-wlanpi"* ]]; then VARIANT_NAME="v8" VARIANT_PKG_VERSION="$PACKAGE_VERSION_V8" + KERNEL_DEP="$PACKAGE_NAME_V8 (= $PACKAGE_VERSION_V8) | $PACKAGE_NAME_DUAL (= $PACKAGE_VERSION_DUAL)" else VARIANT_NAME="2712" VARIANT_PKG_VERSION="$PACKAGE_VERSION_2712" + KERNEL_DEP="$PACKAGE_NAME_2712 (= $PACKAGE_VERSION_2712)" + if [ "$BUILD_PI4" = true ]; then + KERNEL_DEP="$KERNEL_DEP | $PACKAGE_NAME_DUAL (= $PACKAGE_VERSION_DUAL)" + fi fi # Create control file @@ -706,7 +720,7 @@ Section: kernel Priority: optional Architecture: arm64 Maintainer: Josh Schmelzle -Depends: gcc, make, perl +Depends: gcc, make, perl, $KERNEL_DEP Description: Linux kernel headers for WLAN Pi Raspberry Pi $VARIANT_NAME kernel Kernel header files and scripts for WLAN Pi custom kernel development ($VARIANT_NAME variant). Version: $KVER From 0af976b7b95796c99fad5e5a32d432c58049aff1 Mon Sep 17 00:00:00 2001 From: Josh Schmelzle Date: Tue, 29 Sep 2026 18:04:00 -0400 Subject: [PATCH 2/3] headers package: Replaces the kernel packages that shipped build --- AGENTS.md | 2 +- build-kernel.sh | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a58c5a5..5ec1934 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -41,7 +41,7 @@ Pi 4 (BCM2711) uses 4KB pages; Pi 5 (BCM2712) uses 16KB pages — they are binar | `wlanpi-kernel-trixie-2712` | Pi 5 kernel only | Pi 5-only deployments | | `wlanpi-kernel-trixie` | Both kernels | wlanpi2-full (32GB+ SD, boots either hardware) | -Plus separate `wlanpi-kernel-headers-trixie-v8` and `wlanpi-kernel-headers-trixie-2712` packages for out-of-tree module builds. They hold the tree `scripts/package/install-extmod-build` collects (the same as `make bindeb-pkg`) and own `/lib/modules//build`; the kernel packages don't ship `build` or `source`. No `/usr/include` uapi headers: those belong to `linux-libc-dev`. Each headers package depends on its kernel package, or the dual package, at the exact same version. +Plus separate `wlanpi-kernel-headers-trixie-v8` and `wlanpi-kernel-headers-trixie-2712` packages for out-of-tree module builds. They hold the tree `scripts/package/install-extmod-build` collects (the same as `make bindeb-pkg`) and own `/lib/modules//build`; the kernel packages don't ship `build` or `source`. No `/usr/include` uapi headers: those belong to `linux-libc-dev`. Each headers package depends on its own kernel package at the same version, or on the dual package from the same build (v8 headers always; 2712 headers only when the build also made the dual package, whose version is v8-based). Both `Replace` the kernel packages, which shipped `build` before. Package version is `-` (UTC build hour, e.g. `7.2.0-v8-wlanpi-2026092514`); the dual package uses the v8 kernelrelease. The hour lets several builds ship on one day; two builds in the same hour collide and packagecloud rejects the second push. diff --git a/build-kernel.sh b/build-kernel.sh index dc18cd2..5400884 100755 --- a/build-kernel.sh +++ b/build-kernel.sh @@ -698,15 +698,18 @@ for KVER in "${HEADER_VERSIONS[@]}"; do # Determine variant name and corresponding kernel package # Headers only work with the exact kernel they were built with: that - # variant's package or the dual package from the same build. + # variant's package or the dual package from the same build. Replaces: + # older kernel packages shipped /lib/modules//build themselves. if [[ "$KVER" == *"v8-wlanpi"* ]]; then VARIANT_NAME="v8" VARIANT_PKG_VERSION="$PACKAGE_VERSION_V8" KERNEL_DEP="$PACKAGE_NAME_V8 (= $PACKAGE_VERSION_V8) | $PACKAGE_NAME_DUAL (= $PACKAGE_VERSION_DUAL)" + KERNEL_REPLACES="$PACKAGE_NAME_V8, $PACKAGE_NAME_DUAL" else VARIANT_NAME="2712" VARIANT_PKG_VERSION="$PACKAGE_VERSION_2712" KERNEL_DEP="$PACKAGE_NAME_2712 (= $PACKAGE_VERSION_2712)" + KERNEL_REPLACES="$PACKAGE_NAME_2712, $PACKAGE_NAME_DUAL" if [ "$BUILD_PI4" = true ]; then KERNEL_DEP="$KERNEL_DEP | $PACKAGE_NAME_DUAL (= $PACKAGE_VERSION_DUAL)" fi @@ -721,6 +724,7 @@ Priority: optional Architecture: arm64 Maintainer: Josh Schmelzle Depends: gcc, make, perl, $KERNEL_DEP +Replaces: $KERNEL_REPLACES Description: Linux kernel headers for WLAN Pi Raspberry Pi $VARIANT_NAME kernel Kernel header files and scripts for WLAN Pi custom kernel development ($VARIANT_NAME variant). Version: $KVER From 74136beab85dceb7f7bd956b110a89c474982eb9 Mon Sep 17 00:00:00 2001 From: Josh Schmelzle Date: Tue, 29 Sep 2026 18:30:00 -0400 Subject: [PATCH 3/3] headers package: AGENTS.md wording --- AGENTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 5ec1934..1c731e7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -41,7 +41,7 @@ Pi 4 (BCM2711) uses 4KB pages; Pi 5 (BCM2712) uses 16KB pages — they are binar | `wlanpi-kernel-trixie-2712` | Pi 5 kernel only | Pi 5-only deployments | | `wlanpi-kernel-trixie` | Both kernels | wlanpi2-full (32GB+ SD, boots either hardware) | -Plus separate `wlanpi-kernel-headers-trixie-v8` and `wlanpi-kernel-headers-trixie-2712` packages for out-of-tree module builds. They hold the tree `scripts/package/install-extmod-build` collects (the same as `make bindeb-pkg`) and own `/lib/modules//build`; the kernel packages don't ship `build` or `source`. No `/usr/include` uapi headers: those belong to `linux-libc-dev`. Each headers package depends on its own kernel package at the same version, or on the dual package from the same build (v8 headers always; 2712 headers only when the build also made the dual package, whose version is v8-based). Both `Replace` the kernel packages, which shipped `build` before. +Plus separate `wlanpi-kernel-headers-trixie-v8` and `wlanpi-kernel-headers-trixie-2712` packages for out-of-tree module builds. They hold the tree `scripts/package/install-extmod-build` collects (the same as `make bindeb-pkg`) and own `/lib/modules//build`; the kernel packages don't ship `build` or `source`. No `/usr/include` uapi headers: those belong to `linux-libc-dev`. Each headers package depends on its own kernel package at the same version, or on the dual package from the same build (v8 headers always; 2712 headers only when the build also made the dual package, whose version is v8-based). Both declare `Replaces` on those kernel packages, which shipped `build` before. Package version is `-` (UTC build hour, e.g. `7.2.0-v8-wlanpi-2026092514`); the dual package uses the v8 kernelrelease. The hour lets several builds ship on one day; two builds in the same hour collide and packagecloud rejects the second push.