Add linux-headers-bbrv3 meta so DKMS builds and ZFS-root boots

The kernel shipped image-only: install.sh installed just linux-image-bbrv3,
which pulled no headers, so DKMS (zfs-dkms) had no build tree and never built
zfs.ko for the new kernel. On a ZFS-on-root box that left zfs out of the
initramfs -> root could not be mounted -> the machine failed to boot
(hit live on baguette; maple/wunder are ext4-root so they booted but ran
docker on an unimported, empty rpool).

Permanent fix:
- build-meta-package.sh now also builds a linux-headers-bbrv3 meta (amd64) and
  makes linux-image-bbrv3 Depend on it, so headers always install in the same
  apt transaction as the kernel and DKMS rebuilds on every upgrade (mirrors
  Debian's linux-image-amd64 / linux-headers-amd64 pair). arm64 ships no headers
  (nokernelheaders cross build), so the dep and meta are amd64-only.
- build.yml derives the headers package name and passes it to the meta builder.
- registry-has-all.sh counts the headers meta as part of a complete publish.
- install.sh installs linux-headers-bbrv3 alongside the image (latest path) and
  the matching versioned headers in the specific-version path.

Also bundles pre-existing WIP: docs/README notes on the two-stage (Cloudflare
edge + origin nginx) upload body-limit, and setup_apt_source key-download
HTTP-status error handling.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-06-18 12:43:57 +08:00
parent cedc6b914e
commit f2ee3f905e
6 changed files with 150 additions and 56 deletions
+59 -21
View File
@@ -1,38 +1,76 @@
#!/usr/bin/env bash
# Build the linux-image-bbrv3 meta-package. It depends on a specific built kernel
# package plus bbrv3-config, so `apt upgrade` tracks the newest BBRv3 kernel while
# previously installed kernels stay around for fallback.
# Build the BBRv3 meta-packages that track the newest stable build:
#
# The dependency is the *actual* produced package name (passed in), not a guessed
# one, so any localversion/suffix drift from the kernel build can't break it.
# linux-image-bbrv3 Depends on the freshly built kernel image + bbrv3-config,
# and (amd64) on linux-headers-bbrv3 so a kernel build tree
# is ALWAYS installed alongside the image. Without the headers
# dependency the kernel installs image-only and DKMS modules
# (e.g. ZFS) silently can't build for the new kernel -> on a
# ZFS-on-root box the initramfs has no zfs.ko, root won't mount
# and the machine fails to boot. The dependency makes apt pull
# headers in the same transaction so DKMS rebuilds on every
# kernel upgrade, exactly like Debian's stock linux-image-amd64
# / linux-headers-amd64 pair.
#
# linux-headers-bbrv3 Depends on the matching linux-headers-<version>-bbrv3.
# amd64 only: the arm64 cross build ships no headers
# (DEB_BUILD_PROFILES=pkg.linux-upstream.nokernelheaders), so
# there is nothing to track there and the meta is not built.
#
# Depending on the *actual* produced package names (passed in) keeps this immune to
# localversion/suffix drift from the kernel build.
set -euo pipefail
meta_version=${1:?usage: build-meta-package.sh <meta_version> <deb_arch> <depends_pkg> <out_dir>}
meta_version=${1:?usage: build-meta-package.sh <meta_version> <deb_arch> <image_pkg> <out_dir> [headers_pkg]}
arch=${2:?missing deb arch (amd64|arm64)}
depends_pkg=${3:?missing kernel image package name to depend on}
image_pkg=${3:?missing kernel image package name to depend on}
out_dir=${4:?missing output dir}
headers_pkg=${5:-} # empty on arm64 (no headers package is built there)
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
mkdir -p "$out_dir"
pkgdir="$work/meta"
mkdir -p "$pkgdir/DEBIAN"
cat > "$pkgdir/DEBIAN/control" <<EOF
Package: linux-image-bbrv3
# build_meta <package> <Depends:> <Description first line> <extended description body>
build_meta() {
local pkg=$1 depends=$2 short=$3 body=$4
local pkgdir="$work/$pkg"
mkdir -p "$pkgdir/DEBIAN"
cat > "$pkgdir/DEBIAN/control" <<EOF
Package: $pkg
Version: $meta_version
Architecture: $arch
Maintainer: linux-kernel-bbrv3
Depends: $depends_pkg, bbrv3-config
Depends: $depends
Section: kernel
Priority: optional
Description: BBRv3 kernel (tracks the latest stable build)
Meta-package pulling in the newest BBRv3 kernel built by this project
($depends_pkg) plus the bbrv3-config network defaults. Run
'apt-mark hold linux-image-bbrv3' to pin your kernel and stop auto-tracking.
Description: $short
$body
EOF
dpkg-deb --build --root-owner-group "$pkgdir" \
"$out_dir/${pkg}_${meta_version}_${arch}.deb"
echo "Built $out_dir/${pkg}_${meta_version}_${arch}.deb"
}
mkdir -p "$out_dir"
dpkg-deb --build --root-owner-group "$pkgdir" \
"$out_dir/linux-image-bbrv3_${meta_version}_${arch}.deb"
echo "Built $out_dir/linux-image-bbrv3_${meta_version}_${arch}.deb"
# linux-image-bbrv3 — on amd64 it also pulls linux-headers-bbrv3 (pinned to the same
# version) so DKMS has a build tree at install time and on every upgrade.
image_depends="$image_pkg, bbrv3-config"
if [ -n "$headers_pkg" ]; then
image_depends="$image_depends, linux-headers-bbrv3 (= $meta_version)"
fi
build_meta "linux-image-bbrv3" "$image_depends" \
"BBRv3 kernel (tracks the latest stable build)" \
" Meta-package pulling in the newest BBRv3 kernel built by this project
($image_pkg) plus the bbrv3-config network defaults. On amd64 it also pulls
linux-headers-bbrv3 so DKMS modules such as ZFS build for the kernel and the
machine stays bootable. Run 'apt-mark hold linux-image-bbrv3' to pin your
kernel and stop auto-tracking."
# linux-headers-bbrv3 — only where a headers package exists (amd64).
if [ -n "$headers_pkg" ]; then
build_meta "linux-headers-bbrv3" "$headers_pkg" \
"BBRv3 kernel headers (tracks the latest stable build)" \
" Meta-package pulling in the headers ($headers_pkg) for the newest BBRv3
kernel built by this project, so DKMS modules (e.g. ZFS) can build against it.
Installed automatically as a dependency of linux-image-bbrv3 on amd64."
fi
+3 -1
View File
@@ -9,6 +9,7 @@
# - linux-image-bbrv3 == <version> meta-package tracking THIS version
# - bbrv3-config Architecture: all sysctl defaults
# - linux-headers-<version>-bbrv3 amd64 only (arm64 cross build omits headers)
# - linux-headers-bbrv3 == <version> amd64 only: headers meta tracking THIS version
#
# Architecture: all packages (bbrv3-config) appear in every binary-<arch> index,
# so reading the single binary-<arch>/Packages file covers the whole set.
@@ -41,7 +42,8 @@ has_name "linux-image-$version-bbrv3" || missing+=("linux-image-$version-b
has_name_ver "linux-image-bbrv3" "$version" || missing+=("linux-image-bbrv3=$version")
has_name "bbrv3-config" || missing+=("bbrv3-config")
if [ "$arch" = "amd64" ]; then
has_name "linux-headers-$version-bbrv3" || missing+=("linux-headers-$version-bbrv3")
has_name "linux-headers-$version-bbrv3" || missing+=("linux-headers-$version-bbrv3")
has_name_ver "linux-headers-bbrv3" "$version" || missing+=("linux-headers-bbrv3=$version")
fi
if [ ${#missing[@]} -eq 0 ]; then