Files
tailscale/kernel/linux/scripts/ubuntu-headers.sh
Brad Fitzpatrick af92b849a7 kernel/linux/src: fork WireGuard as the out-of-tree tswg module
Copy upstream/drivers/net/wireguard into src and rename only the
user-visible identifiers: the module (and thus the rtnl link kind and
device type, which come from KBUILD_MODNAME) is now tswg, and the
genetlink family is "tswg". The uapi header moves to
src/include/uapi/linux/tswg.h so it can't collide with the kernel's.
Internal wg_ symbols keep their names to keep upstream merges easy; they
aren't exported, so tswg.ko can coexist with wireguard.ko.

Add an out-of-tree Kbuild and top-level Makefile, plus
scripts/ubuntu-headers.sh, which fetches and unpacks an Ubuntu kernel's
headers so we can build for the natlab Ubuntu guest without installing
anything.

This still only builds against 7.4-era kernels; compat shims follow.

Updates #426

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: Ia36ef82a53efbbcdb301ed069785162372efda55
2026-11-06 20:55:25 +00:00

44 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# ubuntu-headers.sh fetches and unpacks (without installing) the Ubuntu
# kernel headers for the given kernel release, such as 6.8.0-106-generic,
# and prints the resulting kernel build directory to stdout.
#
# It uses "apt-get download", so the host's apt sources must carry that
# kernel version. Results are cached in $TSLINUX_CACHE (default
# ~/.cache/tslinux).
set -eu
if [ $# -ne 1 ]; then
echo "usage: $0 <kernel-release, e.g. 6.8.0-106-generic>" >&2
exit 2
fi
kver=$1
flavor=${kver##*-} # generic
base=${kver%-"$flavor"} # 6.8.0-106
cache=${TSLINUX_CACHE:-$HOME/.cache/tslinux}
root=$cache/headers/$kver
build=$root/usr/src/linux-headers-$kver
if [ -f "$build/Makefile" ]; then
echo "$build"
exit 0
fi
debs=$cache/debs
mkdir -p "$debs"
(cd "$debs" && apt-get download -q "linux-headers-$kver" "linux-headers-$base" >&2)
tmp=$root.tmp
rm -rf "$tmp"
mkdir -p "$tmp"
for deb in "$debs"/linux-headers-"$kver"_*.deb "$debs"/linux-headers-"$base"_*.deb; do
dpkg-deb -x "$deb" "$tmp"
done
rm -rf "$root"
mv "$tmp" "$root"
echo "$build"