From 1d6ec630d636067d802de522638396132989923a Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sat, 7 Nov 2026 07:50:06 +0000 Subject: Kernel: T9591: add VyOS internal revision to the kernel release string Rebuilding the same upstream kernel with additional patches, e.g. urgent security fixes, produced the exact same release string and package name as the previous build. A patched image could not be told apart from an unpatched one. A new kernel_revision default is now placed between the upstream version and the flavor, so 6.18.60-vyos becomes 6.18.60-1-vyos. It ends up in uname -r, the module directory, the linux-image package name and its Debian version; out-of-tree modules follow automatically. Bump it on every patched rebuild of the same upstream version and reset it to 1 on an upstream bump. The kernel and all module packages must be rebuilt and published along with this change, otherwise the image build cannot find the new linux-image package. --- scripts/package-build/linux-kernel/README.md | 5 +++++ scripts/package-build/linux-kernel/build-kernel.sh | 11 +++++++++-- scripts/package-build/linux-kernel/build.py | 14 +++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) (limited to 'scripts/package-build/linux-kernel') diff --git a/scripts/package-build/linux-kernel/README.md b/scripts/package-build/linux-kernel/README.md index 56ef649b..b1172f32 100644 --- a/scripts/package-build/linux-kernel/README.md +++ b/scripts/package-build/linux-kernel/README.md @@ -10,6 +10,11 @@ VyOS runs on a custom Linux Kernel. The version built is pinned by repository holds the build scripts used to build the custom Kernel for x86_64/amd64 and arm64, plus all required out-of-tree modules. +The resulting Kernel release is `--`, +e.g. `6.18.60-1-vyos`. `kernel_revision` is a VyOS internal number: bump it when +rebuilding the same upstream version with additional patches (e.g. security +fixes) and reset it to 1 when `kernel_version` changes. + VyOS does not utilize the build in Intel Kernel drivers for its NICs as those Kernels sometimes lack features e.g. configurable receive-side-scaling queues. On the other hand we ship additional not mainlined features as WireGuard VPN. diff --git a/scripts/package-build/linux-kernel/build-kernel.sh b/scripts/package-build/linux-kernel/build-kernel.sh index dea71aa9..14817b06 100755 --- a/scripts/package-build/linux-kernel/build-kernel.sh +++ b/scripts/package-build/linux-kernel/build-kernel.sh @@ -27,8 +27,15 @@ if [ -z "${KERNEL_FLAVOR}" ]; then exit 1 fi +if [ -z "${KERNEL_REVISION}" ]; then + echo "E: KERNEL_REVISION is not set, run via ./build.py so it can be passed from data/defaults.toml" + exit 1 +fi + KERNEL_VERSION=$(make kernelversion) -KERNEL_SUFFIX=-${KERNEL_FLAVOR} +# VyOS internal revision, e.g. 6.18.60-1-vyos - bumped when rebuilding the same +# upstream version with additional patches +KERNEL_SUFFIX=-${KERNEL_REVISION}-${KERNEL_FLAVOR} echo "I: Generate Kernel config" ARCH=$(dpkg --print-architecture) @@ -131,7 +138,7 @@ EOF echo "I: Build Debian Kernel package" touch .scmversion -make bindeb-pkg BUILD_TOOLS=1 LOCALVERSION=${KERNEL_SUFFIX} KDEB_PKGVERSION=${KERNEL_VERSION}-1 -j $(getconf _NPROCESSORS_ONLN) +make bindeb-pkg BUILD_TOOLS=1 LOCALVERSION=${KERNEL_SUFFIX} KDEB_PKGVERSION=${KERNEL_VERSION}-${KERNEL_REVISION} -j $(getconf _NPROCESSORS_ONLN) # Back to the old Kernel build-scripts directory cd $CWD diff --git a/scripts/package-build/linux-kernel/build.py b/scripts/package-build/linux-kernel/build.py index 295f44b9..fa19b97d 100755 --- a/scripts/package-build/linux-kernel/build.py +++ b/scripts/package-build/linux-kernel/build.py @@ -137,7 +137,8 @@ def build_package(package: dict, dependencies: list, # Execute the build command if package['build_cmd'] == 'build_kernel': - source_dir = build_kernel(package['kernel_version'], package['kernel_flavor']) + source_dir = build_kernel(package['kernel_version'], package['kernel_revision'], + package['kernel_flavor']) if linux_kernel_tarball is not None: linux_kernel_tarball.clear() linux_kernel_tarball['package_name'] = package['name'] @@ -191,7 +192,7 @@ def merge_dicts(defaults, package): return {**defaults, **package} -def build_kernel(kernel_version, kernel_flavor) -> str: +def build_kernel(kernel_version, kernel_revision, kernel_flavor) -> str: """Build the Linux kernel""" source_dir = 'linux' # Git source repo name - preferred over TAR if not os.path.exists(source_dir): @@ -205,9 +206,12 @@ def build_kernel(kernel_version, kernel_flavor) -> str: source_dir = f'linux-{kernel_version}' os.symlink(source_dir, 'linux') - # kernel_flavor is only known here (merged from data/defaults.toml); pass it down - # via the environment so build-kernel.sh doesn't need to re-read defaults.toml itself. - run(['./build-kernel.sh'], check=True, env={**os.environ, 'KERNEL_FLAVOR': kernel_flavor}) + # kernel_revision and kernel_flavor are only known here (merged from data/defaults.toml); + # pass them down via the environment so build-kernel.sh doesn't need to re-read + # defaults.toml itself. + run(['./build-kernel.sh'], check=True, env={**os.environ, + 'KERNEL_REVISION': kernel_revision, + 'KERNEL_FLAVOR': kernel_flavor}) return(source_dir) -- cgit v1.2.3