Distribute kernel via Gitea Debian apt repo; track stable not mainline

- Publish .deb packages to Gitea's built-in Debian registry (apt source)
  instead of Releases; CI uploads to pool/stable/main and stops creating
  Releases. One apt source line serves amd64 and arm64.
- Add linux-image-bbrv3 meta-package so `apt upgrade` tracks the latest
  stable kernel while older kernels stay installed for fallback. Its
  dependency is the actual built image package name (immune to localversion
  drift).
- Add bbrv3-config package shipping the BBR+CAKE+ECN sysctl drop-in as a
  conffile (applied via postinst), replacing the installer's sysctl write.
- Rewrite install.sh to add the apt source + signing key and install the
  meta package; keep the OS-version gate, status check and uninstall menu,
  plus an apt-mark hold escape hatch.
- select-stable-kernel.sh: pick the highest stable point release whose
  series is below mainline and has a matching BBRv3 patch, so a freshly-cut
  series (latest stable == mainline, e.g. 7.1) is not built. Currently 7.0.12.
- Exclude linux-libc-dev (clashes with the distro's headers) and drop the
  "by Joey" MODULE_DESCRIPTION step and release branding.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-06-17 18:26:05 +08:00
parent d888a9700e
commit b8ccd431ea
7 changed files with 521 additions and 407 deletions
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# Build the bbrv3-config package (Architecture: all): ships the BBR + CAKE + ECN
# sysctl drop-in so installing the kernel configures the network stack with no
# installer script. The meta-package depends on it.
set -euo pipefail
out_dir=${1:?usage: build-config-package.sh <output_dir> [version]}
version=${2:-1.0}
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
pkgdir="$work/bbrv3-config"
mkdir -p "$pkgdir/DEBIAN" "$pkgdir/etc/sysctl.d"
cat > "$pkgdir/etc/sysctl.d/99-bbrv3.conf" <<'EOF'
# Managed by the bbrv3-config package (linux-kernel-bbrv3).
# BBR congestion control + CAKE default qdisc + ECN.
net.core.default_qdisc = cake
net.ipv4.tcp_congestion_control = bbr
net.ipv4.tcp_ecn = 1
EOF
# conffile: dpkg preserves local edits to the drop-in across upgrades.
echo "/etc/sysctl.d/99-bbrv3.conf" > "$pkgdir/DEBIAN/conffiles"
cat > "$pkgdir/DEBIAN/control" <<EOF
Package: bbrv3-config
Version: $version
Architecture: all
Maintainer: linux-kernel-bbrv3
Depends: procps
Section: net
Priority: optional
Description: Default network stack (BBR + CAKE + ECN) for BBRv3 kernels
Ships /etc/sysctl.d/99-bbrv3.conf so the BBRv3 kernel boots with BBR
congestion control, the CAKE default qdisc and ECN enabled.
EOF
cat > "$pkgdir/DEBIAN/postinst" <<'EOF'
#!/bin/sh
set -e
if [ "$1" = "configure" ]; then
# Applies now if the running kernel supports it; otherwise the settings take
# effect on the next boot into the BBRv3 kernel (sch_cake is built in there).
sysctl --system >/dev/null 2>&1 || true
fi
EOF
chmod 0755 "$pkgdir/DEBIAN/postinst"
mkdir -p "$out_dir"
dpkg-deb --build --root-owner-group "$pkgdir" \
"$out_dir/bbrv3-config_${version}_all.deb"
echo "Built $out_dir/bbrv3-config_${version}_all.deb"
+38
View File
@@ -0,0 +1,38 @@
#!/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.
#
# 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.
set -euo pipefail
meta_version=${1:?usage: build-meta-package.sh <meta_version> <deb_arch> <depends_pkg> <out_dir>}
arch=${2:?missing deb arch (amd64|arm64)}
depends_pkg=${3:?missing kernel image package name to depend on}
out_dir=${4:?missing output dir}
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
pkgdir="$work/meta"
mkdir -p "$pkgdir/DEBIAN"
cat > "$pkgdir/DEBIAN/control" <<EOF
Package: linux-image-bbrv3
Version: $meta_version
Architecture: $arch
Maintainer: linux-kernel-bbrv3
Depends: $depends_pkg, bbrv3-config
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.
EOF
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"
+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# Print the kernel version this project should build.
#
# We track an established *stable* series, never the bleeding edge. Right after a
# new series N.M is released, kernel.org's "latest stable version" flips to "N.M"
# and equals "latest mainline version" — that is mainline, not a baked stable.
# So we select the highest three-component point release (X.Y.Z) whose series X.Y
# is strictly below mainline AND has a matching BBRv3 patch in this repo:
# - three components exclude the freshly-cut top series (shown as "N.M");
# - the "< mainline" test excludes a series that still equals mainline;
# - the patch gate excludes series we cannot port BBRv3 onto (e.g. LTS 6.x).
# The series advances automatically once the next one matures and mainline moves on.
set -euo pipefail
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
repo_root=$(cd -- "$script_dir/.." && pwd)
FINGER_URL="${FINGER_URL:-https://www.kernel.org/finger_banner}"
banner=$(curl -fsSL "$FINGER_URL")
if [ -z "$banner" ]; then
echo "Failed to fetch $FINGER_URL" >&2
exit 1
fi
# Mainline major.minor, stripping any -rcN suffix: "7.1" or "7.2-rc1" -> "7.1"/"7.2".
mainline_mm=$(printf '%s\n' "$banner" \
| grep -i 'latest mainline version' \
| grep -oE '[0-9]+\.[0-9]+' | head -n1)
if [ -z "$mainline_mm" ]; then
echo "Could not parse mainline version from finger_banner." >&2
exit 1
fi
# Every three-component point release mentioned in the banner (stable + longterm),
# ascending and de-duplicated. Two-component entries like a just-released "7.1"
# are intentionally not matched here.
mapfile -t candidates < <(printf '%s\n' "$banner" \
| grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | sort -V -u)
# strictly_less A B -> true when A < B under version sort.
strictly_less() {
[ "$1" != "$2" ] && [ "$(printf '%s\n%s\n' "$1" "$2" | sort -V | head -n1)" = "$1" ]
}
target=""
for v in "${candidates[@]}"; do
mm=${v%.*} # 7.0.12 -> 7.0
strictly_less "$mm" "$mainline_mm" || continue
[ -f "$repo_root/patches/bbrv3-linux-$mm.patch" ] || continue
target="$v" # candidates ascending: keep highest match
done
if [ -z "$target" ]; then
echo "No stable series below mainline $mainline_mm has a BBRv3 patch in patches/." >&2
echo "Point releases seen: ${candidates[*]:-none}" >&2
exit 1
fi
printf '%s\n' "$target"