Files
Brad Fitzpatrick 309157b88f kernel/linux/scripts: build tswg.ko for gokrazy kernels
The natlab gokrazy image runs a recent upstream kernel (7.2.8 today) that
gokrazy rebuilds and tailscale.com bumps regularly, which makes it a
better primary test target than a distro kernel: it keeps us honest
against new kernel APIs, and gokrazy has no userspace tools, as in the
end state where tailscaled drives the kernel entirely.

gokrazy kernels are kernel.org releases plus the patches in
_build/series, built with an embedded config and without MODVERSIONS or
module signing. gokrazy-kdir.sh downloads the release, applies the
patches, installs the config pulled out of vmlinuz with the kernel's
extract-ikconfig (vendored), and runs modules_prepare, caching the
result by release and config hash. It takes about 20 seconds the first
time. The only config differences after olddefconfig with the host's gcc
13 (gokrazy uses Debian 12's gcc 12) are toolchain capability bits.

Factor the generic part of build-for-ubuntu.sh into build.sh, which now
copies only sources (not objects from an in-place build in src/), and
sets KBUILD_MODPOST_WARN=1 for trees without a Module.symvers. Add
build-for-gokrazy.sh.

Updates #426

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: Id28d9c013bdfaa7cec28aeff846f7f6087e25518
2026-11-06 21:44:29 +00:00

39 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# build.sh builds tswg.ko against the kernel build directory KDIR in a
# private copy of src/ under OUTDIR, and prints the path of the resulting
# tswg.ko to stdout. All build output goes to stderr.
#
# usage: build.sh KDIR OUTDIR
set -eu
if [ $# -ne 2 ]; then
echo "usage: $0 KDIR OUTDIR" >&2
exit 2
fi
kdir=$1
out=$2
top=$(cd "$(dirname "$0")/.." && pwd)
# Copy only sources, not any objects from an in-place build in src/.
mkdir -p "$out"
rm -rf "$out/src"
tar -C "$top" -cf - \
--exclude='*.o' --exclude='*.ko' --exclude='*.mod' --exclude='*.mod.c' \
--exclude='*.cmd' --exclude='*.o.d' --exclude=modules.order \
--exclude=Module.symvers --exclude=generated/autoconf.h \
src | tar -C "$out" -xf -
# A tree prepared with "make modules_prepare" (as for gokrazy kernels) has
# no Module.symvers, so modpost can't resolve the kernel's exports. That's
# fine without MODVERSIONS; unresolved symbols then show up at load time.
modpost_warn=
if [ ! -f "$kdir/Module.symvers" ]; then
modpost_warn=KBUILD_MODPOST_WARN=1
fi
make -C "$top" KDIR="$kdir" SRC="$out/src" $modpost_warn >&2
echo "$out/src/tswg.ko"