eBPF-based security platform
testing: build and publish in-tree CI kernels
Andrea Lattuada958c5beca2e8
diff --git a/.github/scripts/build-test-kernel.sh b/.github/scripts/build-test-kernel.shnew file mode 100644index 00000000..de3445e1--- /dev/null+++ b/.github/scripts/build-test-kernel.sh@@ -0,0 +1,18 @@+#!/bin/bash+# SPDX-License-Identifier: BSD-2-Clause+# Copyright (c) 2026 Authors of shirudo++set -euo pipefail++sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc+sudo apt-get update+sudo apt-get install --no-install-recommends -y \+ bc bison build-essential clang-20 gnu-coreutils cpio debhelper dpkg-dev \+ fakeroot flex libelf-dev libncurses-dev libssl-dev lld-20 llvm-20-dev \+ lsb-release make pahole pkg-config python3 rsync xz-utils zstd++# Ubuntu 26.04's uutils install -D races under parallel dtbs_install.+mkdir -p "$RUNNER_TEMP/gnu-coreutils-bin"+ln -sf /usr/bin/gnuinstall "$RUNNER_TEMP/gnu-coreutils-bin/install"+PATH="$RUNNER_TEMP/gnu-coreutils-bin:$PATH" \+ testing/kernel/build-kernel.sh --llvm 20 --arch "$1"diff --git a/.github/scripts/publish-test-kernel.sh b/.github/scripts/publish-test-kernel.shnew file mode 100755index 00000000..ea33d1a0--- /dev/null+++ b/.github/scripts/publish-test-kernel.sh@@ -0,0 +1,119 @@+#!/bin/bash+# SPDX-License-Identifier: BSD-2-Clause+# Copyright (c) 2026 Authors of shirudo+# Publish both CI-profile bundles and their corresponding kernel source.++set -euo pipefail++die() {+ echo "$*" >&2+ exit 1+}++[[ "${RUN_ID:-}" =~ ^[0-9]+$ ]] || die "RUN_ID must be a numeric workflow run ID"++repo=shirudo-dev/shirudo+tag=test-kernel-$RUN_ID+run="repos/$repo/actions/runs/$RUN_ID"++metadata=$(gh api "$run" --jq '+ select(.path == ".github/workflows/build-kernel-packages.yml"+ and .head_branch == "main" and .head_repository.id == .repository.id+ and .event == "workflow_dispatch"+ and .conclusion == "success")+ | [.head_sha, .run_attempt] | @tsv')+IFS=$'\t' read -r producer_commit attempt <<<"$metadata"+[[ "$producer_commit" =~ ^[0-9a-f]{40}$ && "$attempt" =~ ^[0-9]+$ ]] ||+ die "Run $RUN_ID is not a successful kernel package build on main"++existing=$(gh api "repos/$repo/git/matching-refs/tags/$tag" \+ --jq ".[].ref | select(. == \"refs/tags/$tag\")")+if [[ -n "$existing" ]] || gh release view "$tag" --repo "$repo" >/dev/null 2>&1; then+ die "Tag or release $tag already exists"+fi++work=$(mktemp -d "${RUNNER_TEMP:?}/test-kernel.XXXXXX")+trap 'rm -rf "$work"' EXIT+cd "$work"++download_artifact() {+ local name=$1 metadata id digest+ metadata=$(gh api "$run/artifacts?name=$name" --jq '+ .artifacts | map(select(.expired == false))+ | select(length == 1) | .[0] | [.id, .digest] | @tsv')+ IFS=$'\t' read -r id digest <<<"$metadata"+ if [[ ! "$id" =~ ^[0-9]+$ || ! "$digest" =~ ^sha256:[0-9a-f]{64}$ ]]; then+ if [[ "$name" == kernel-ci-source ]]; then+ die "Run $RUN_ID lacks a matching kernel-ci-source artifact with a SHA-256 digest. Select a new build with CI source export enabled."+ fi+ die "Expected one available $name artifact with a SHA-256 digest in run $RUN_ID"+ fi+ gh api "repos/$repo/actions/artifacts/$id/zip" >"$name.zip"+ printf '%s %s\n' "${digest#sha256:}" "$name.zip" | sha256sum --check >&2+}++download_artifact kernel-ci-source+for arch in arm64 x86-64; do+ download_artifact "kernel-packages-$arch-ci"+done++upstream=$(python3 - "$RUN_ID" "$attempt" "$producer_commit" <<'PY'+import hashlib+import re+import shutil+import sys+import zipfile+from pathlib import PurePosixPath++run, attempt, producer = sys.argv[1:]+source_name = "kernel-ci-source.tar.zst"+with zipfile.ZipFile("kernel-ci-source.zip") as archive:+ if archive.namelist() != [source_name]:+ sys.exit(f"Expected only {source_name} in the kernel-ci-source artifact")+ with archive.open(source_name) as source, open(source_name, "wb") as output:+ shutil.copyfileobj(source, output)+with open(source_name, "rb") as source:+ source_sha256 = hashlib.file_digest(source, "sha256").hexdigest()++upstream, patched = None, None+for arch, deb_arch in (("arm64", "arm64"), ("x86-64", "amd64")):+ bundle = f"kernel-packages-{arch}-ci.zip"+ with zipfile.ZipFile(bundle) as archive:+ images = [PurePosixPath(name) for name in archive.namelist()+ if PurePosixPath(name).match(f"linux-image-*_{deb_arch}.deb")]+ if len(images) != 1:+ sys.exit(f"Expected one {deb_arch} kernel image in {bundle}")+ name = str(images[0].with_name("BUILD-INFO"))+ if archive.namelist().count(name) != 1:+ sys.exit(f"Expected one BUILD-INFO next to the kernel image in {bundle}")+ fields = {}+ for line in archive.read(name).decode().splitlines():+ key, sep, value = line.partition("=")+ if not sep or key in fields:+ sys.exit(f"Invalid BUILD-INFO in {bundle}")+ fields[key] = value++ expected = {+ "arch": arch, "profile": "ci", "producer_commit": producer,+ "run_id": run, "run_attempt": attempt, "source_sha256": source_sha256,+ }+ for key, value in expected.items():+ if fields.get(key) != value:+ sys.exit(f"Source provenance mismatch in {bundle}: {key}")+ commit = fields.get("commit", "")+ patched_commit = fields.get("patched_commit", "")+ if not all(re.fullmatch(r"[0-9a-f]{40}", rev) for rev in (commit, patched_commit)):+ sys.exit(f"Missing upstream or patched revision in {bundle}")+ if upstream is not None and (upstream, patched) != (commit, patched_commit):+ sys.exit(f"Source revisions disagree between the CI bundles in run {run}")+ upstream, patched = commit, patched_commit+print(upstream)+PY+)++assets=(kernel-packages-arm64-ci.zip kernel-packages-x86-64-ci.zip kernel-ci-source.tar.zst)+sha256sum "${assets[@]}" >SHA256SUMS+gh release create "$tag" --repo "$repo" --target "$producer_commit" --prerelease --latest=false \+ --title "Test kernel build $RUN_ID" \+ --notes "CI-profile kernels and corresponding source from bpf-next $upstream (build run $RUN_ID)." \+ "${assets[@]}" SHA256SUMSdiff --git a/.github/workflows/build-kernel-packages.yml b/.github/workflows/build-kernel-packages.ymlnew file mode 100644index 00000000..ab0ed9eb--- /dev/null+++ b/.github/workflows/build-kernel-packages.yml@@ -0,0 +1,48 @@+name: Build kernel packages++on:+ workflow_dispatch:+ workflow_call:++permissions:+ contents: read++jobs:+ build:+ name: CI ${{ matrix.arch }} kernel packages+ runs-on: ubuntu-26.04+ timeout-minutes: 120+ strategy:+ fail-fast: false+ matrix:+ arch: [x86-64, arm64]++ steps:+ - name: Check out kernel inputs+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false++ - name: Build CI kernel packages+ env:+ KERNEL_ARCH: ${{ matrix.arch }}+ run: bash .github/scripts/build-test-kernel.sh "$KERNEL_ARCH"++ - name: Upload packages and build metadata+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2+ with:+ name: kernel-packages-${{ matrix.arch }}-ci+ path: build/test-kernel/pkgs/${{ matrix.arch }}+ if-no-files-found: error+ compression-level: 0+ retention-days: 14++ - name: Upload corresponding kernel source+ if: github.event_name == 'workflow_dispatch' && matrix.arch == 'x86-64'+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2+ with:+ name: kernel-ci-source+ path: build/test-kernel/kernel-ci-source.tar.zst+ if-no-files-found: error+ compression-level: 0+ retention-days: 14diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.ymlindex 8153597a..28cec31b 100644--- a/.github/workflows/coverity.yml+++ b/.github/workflows/coverity.yml@@ -110,7 +110,7 @@ jobs:--form token="\$token" \--form email="${{ github.actor }}@users.noreply.github.com" \--form file=@build/cov-int.tgz \- --form version="\$(git describe --tags --always)" \+ --form version="\$(git describe --tags --always --exclude 'test-kernel-*')" \--form description="GitHub Actions ${{ github.sha }}" \https://scan.coverity.com/builds?project=shirudo-dev%2Fshirudorm -f build/coverity-tokendiff --git a/.github/workflows/packages.yml b/.github/workflows/packages.ymlindex 4e7952d0..089f96d1 100644--- a/.github/workflows/packages.yml+++ b/.github/workflows/packages.yml@@ -6,6 +6,7 @@ on:- maintags:- '*'+ - '!test-kernel-*'pull_request:workflow_dispatch:inputs:@@ -41,7 +42,7 @@ jobs:if [ "$REF_TYPE" = tag ]; thenversion=$REF_NAMEelse- version=$(git describe --tags --always --dirty)+ version=$(git describe --tags --always --dirty --exclude 'test-kernel-*')fimkdir -p buildprintf '%s\n' "$version" > build/ci-version@@ -249,7 +250,7 @@ jobs:if [ "$REF_TYPE" = tag ]; thenversion=$REF_NAMEelse- version=$(git describe --tags --always --dirty)+ version=$(git describe --tags --always --dirty --exclude 'test-kernel-*')fimkdir -p buildprintf '%s\n' "$version" > build/ci-versiondiff --git a/.github/workflows/publish-test-kernel.yml b/.github/workflows/publish-test-kernel.ymlnew file mode 100644index 00000000..54e5af14--- /dev/null+++ b/.github/workflows/publish-test-kernel.yml@@ -0,0 +1,35 @@+name: Publish test kernel++on:+ workflow_dispatch:+ inputs:+ run_id:+ description: Successful kernel package build run on main with CI source export+ required: true+ type: string++permissions: {}++concurrency:+ group: publish-test-kernel-${{ inputs.run_id }}+ cancel-in-progress: false++jobs:+ publish:+ if: github.repository == 'shirudo-dev/shirudo' && github.ref == 'refs/heads/main'+ runs-on: ubuntu-26.04+ timeout-minutes: 20+ permissions:+ contents: write+ actions: read+ steps:+ - name: Check out the publishing script+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ persist-credentials: false++ - name: Publish the selected CI bundles and source+ env:+ GH_TOKEN: ${{ github.token }}+ RUN_ID: ${{ inputs.run_id }}+ run: bash .github/scripts/publish-test-kernel.shdiff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rstindex c76dd549..e16eba1e 100644--- a/Documentation/contribute/testing/test-coverage.rst+++ b/Documentation/contribute/testing/test-coverage.rst@@ -94,6 +94,10 @@ signed config image.type on its line or the one above, a header's declaration that isno call, the calls that count and the definitions it leavesalone, and the tree itself+ * - ``t0010-publish-test-kernel``+ - The prerelease tag, assets, and repository token,+ and rejection of missing source, mismatched source and a bundle+ with the wrong checksum``build`` (1)~~~~~~~~~~~~~diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rstindex f0f39e48..609db6eb 100644--- a/Documentation/contribute/testing/testing.rst+++ b/Documentation/contribute/testing/testing.rst@@ -66,6 +66,17 @@ The kernel project owns the kernel source, configuration and patchapplication. Changes to those inputs need a successful kernel projectrun and an updated pin before CI can boot the series.+Publish a CI kernel prerelease+------------------------------++Dispatch ``Build kernel packages`` on shirudo's ``main``. It builds+x86-64 and arm64 from the bpf-next commit in+:src:`testing/kernel/bpf-next.commit` and the patches and configuration+in :src:`testing/kernel/`. Dispatch ``Publish test kernel`` with the+successful run ID. The prerelease ``test-kernel-<run-id>`` includes both+bundle ZIPs, their matching ``kernel-ci-source.tar.zst`` and+``SHA256SUMS``. Verify the public downloads against ``SHA256SUMS``.+Test tiers----------diff --git a/Documentation/reference/versions.rst b/Documentation/reference/versions.rstindex 30bc93ce..8718b681 100644--- a/Documentation/reference/versions.rst+++ b/Documentation/reference/versions.rst@@ -15,8 +15,8 @@ mixes of builds work together.Releases---------There is no shirudo release. ``main`` is the development branch, and no-stable branches are maintained. Every push to ``main`` builds the+There is no shirudo software release. ``main`` is the development branch,+and no stable branches are maintained. Every push to ``main`` builds thepackages in the ``Build packages`` workflow, where they are available asrun artifacts. Until a release, no format below carries a compatibilitypromise.@@ -40,7 +40,8 @@ Version string- ``git describe --tags --always --dirty`` of the build tree, orthe content of the :src:`VERSION` file, ``0.0.0-dev``, outside a gitcheckout. Without tags, describe prints the abbreviated commit,- with ``-dirty`` for uncommitted changes.+ with ``-dirty`` for uncommitted changes. The command excludes+ ``test-kernel-*`` tags.* - ``<extraversion>``- ``EXTRAVERSION`` in the top-level ``Makefile``, ``-rc0``.* - ``<release-name>``diff --git a/Makefile.version b/Makefile.versionindex c1a8382c..a59ea0c9 100644--- a/Makefile.version+++ b/Makefile.version@@ -4,4 +4,4 @@# Shared version-discovery command used by the top-level packaging flow and# the generated runtime version string in Makefile.shirudo.-SHIRUDO_GIT_DESCRIBE ?= git describe --tags --always --dirty+SHIRUDO_GIT_DESCRIBE ?= git describe --tags --always --dirty --exclude 'test-kernel-*'diff --git a/testing/ci-checks/t0010-publish-test-kernel.sh b/testing/ci-checks/t0010-publish-test-kernel.shnew file mode 100755index 00000000..6b16eecc--- /dev/null+++ b/testing/ci-checks/t0010-publish-test-kernel.sh@@ -0,0 +1,143 @@+#!/bin/sh+# SPDX-License-Identifier: BSD-2-Clause+# Copyright (c) 2026 Authors of shirudo+# shellcheck disable=SC2016,SC2329 # test_expect_success evaluates the body.++cd "$(dirname "$0")/.." || exit 1+# shellcheck source=testing/test-lib.sh+. ./test-lib.sh+for tool in bash jq python3 sha256sum zstd; do+ command -v "$tool" >/dev/null 2>&1 || test_skip_all "$tool is required"+done++publisher=$(cd .. && pwd)/.github/scripts/publish-test-kernel.sh+fixture=$(mktemp -d)+trap 'rm -rf "$fixture"' EXIT+export fixture+mkdir "$fixture/bin" "$fixture/source" "$fixture/source/linux"+printf 'VERSION = 7\n' >"$fixture/source/linux/Makefile"+tar -C "$fixture/source" -cf "$fixture/source.tar" linux+zstd -q "$fixture/source.tar" -o "$fixture/kernel-ci-source.tar.zst"++python3 - "$fixture" <<'PY'+import hashlib+import sys+import zipfile+from pathlib import Path++fixture = Path(sys.argv[1])+source_name = "kernel-ci-source.tar.zst"+source = (fixture / source_name).read_bytes()+with zipfile.ZipFile(fixture / "1.zip", "w") as archive:+ archive.writestr(source_name, source)+with zipfile.ZipFile(fixture / "4.zip", "w") as archive:+ archive.writestr(source_name, source + b"different source")++for artifact_id, arch, deb_arch in ((2, "arm64", "arm64"), (3, "x86-64", "amd64")):+ with zipfile.ZipFile(fixture / f"{artifact_id}.zip", "w") as archive:+ archive.writestr(f"7.4/linux-image-7.4_1_{deb_arch}.deb", b"package")+ archive.writestr(+ "7.4/BUILD-INFO",+ f"arch={arch}\n"+ "profile=ci\n"+ f"source_sha256={hashlib.sha256(source).hexdigest()}\n"+ f"producer_commit={'a' * 40}\n"+ f"commit={'b' * 40}\n"+ f"patched_commit={'c' * 40}\n"+ "run_id=42\n"+ "run_attempt=1\n",+ )+PY++cat >"$fixture/bin/gh" <<'SH'+#!/bin/sh+set -eu++case "$1/$2" in+api/repos/shirudo-dev/shirudo/*|release/*) test "$GH_TOKEN" = release-write ;;+*) exit 1 ;;+esac++case "$1/$2" in+api/repos/shirudo-dev/shirudo/actions/runs/42)+ jq -r "$4" <<'JSON'+{"path":".github/workflows/build-kernel-packages.yml","head_branch":"main",+ "head_repository":{"id":1},"repository":{"id":1},"event":"workflow_dispatch",+ "conclusion":"success","head_sha":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",+ "run_attempt":1}+JSON+ ;;+api/repos/shirudo-dev/shirudo/git/matching-refs/tags/test-kernel-42)+ echo '[]' | jq -r "$4"+ ;;+api/repos/shirudo-dev/shirudo/actions/runs/42/artifacts?name=*)+ case "${2##*=}" in+ kernel-ci-source)+ case "$MODE" in+ missing-source) echo '{"artifacts":[]}' | jq -r "$4"; exit ;;+ wrong-source) id=4 ;;+ *) id=1 ;;+ esac+ ;;+ kernel-packages-arm64-ci) id=2 ;;+ kernel-packages-x86-64-ci) id=3 ;;+ *) exit 1 ;;+ esac+ sum=$(sha256sum "$fixture/$id.zip")+ if [ "$MODE/$id" = bad-checksum/2 ]; then+ sum=$(sha256sum "$fixture/3.zip")+ fi+ printf '{"artifacts":[{"id":%s,"expired":false,"digest":"sha256:%s"}]}\n' \+ "$id" "${sum%% *}" | jq -r "$4"+ ;;+api/repos/shirudo-dev/shirudo/actions/artifacts/*/zip)+ id=${2%/zip}+ cat "$fixture/${id##*/}.zip"+ ;;+release/view) exit 1 ;;+release/create)+ printf '%s\n' "$@" >"$fixture/write"+ cmp "$fixture/2.zip" kernel-packages-arm64-ci.zip+ cmp "$fixture/3.zip" kernel-packages-x86-64-ci.zip+ cmp "$fixture/kernel-ci-source.tar.zst" kernel-ci-source.tar.zst+ sha256sum --check SHA256SUMS+ ;;+*) exit 1 ;;+esac+SH+chmod +x "$fixture/bin/gh"++publish() {+ rm -f "$fixture/write"+ env PATH="$fixture/bin:$PATH" MODE="$1" RUNNER_TEMP="$fixture" \+ GH_TOKEN=release-write RUN_ID=42 \+ bash "$publisher"+}++test_expect_success 'publish the original bundles and matching source as a shirudo prerelease' '+ publish valid &&+ grep -Fx test-kernel-42 "$fixture/write" &&+ grep -Fx shirudo-dev/shirudo "$fixture/write" &&+ grep -Fx aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "$fixture/write" &&+ grep -Fx -- --prerelease "$fixture/write"+'++test_expect_success 'refuse a run without a corresponding source artifact' '+ ! publish missing-source 2>"$fixture/error" &&+ test ! -e "$fixture/write" &&+ grep -F "lacks a matching kernel-ci-source artifact" "$fixture/error"+'++test_expect_success 'refuse a source artifact that disagrees with the bundle metadata' '+ ! publish wrong-source 2>"$fixture/error" &&+ test ! -e "$fixture/write" &&+ grep -F "Source provenance mismatch" "$fixture/error"+'++test_expect_success 'refuse a bundle that fails its Actions checksum' '+ ! publish bad-checksum 2>"$fixture/error" &&+ test ! -e "$fixture/write" &&+ grep -F "kernel-packages-arm64-ci.zip: FAILED" "$fixture/error"+'++test_donediff --git a/testing/kernel/bpf-next.commit b/testing/kernel/bpf-next.commitnew file mode 100644index 00000000..39a3f746--- /dev/null+++ b/testing/kernel/bpf-next.commit@@ -0,0 +1 @@+2bf3351c5f894697e8443eeef5333d4c4ce90cabdiff --git a/testing/kernel/build-kernel.sh b/testing/kernel/build-kernel.shindex 397a64d7..5f1dc7e7 100755--- a/testing/kernel/build-kernel.sh+++ b/testing/kernel/build-kernel.sh@@ -1,13 +1,7 @@#!/usr/bin/env bash# SPDX-License-Identifier: BSD-2-Clause# Copyright (c) 2026 Authors of shirudo-# build-kernel.sh: build kernel packages from upstream/bpf-next with the-# hardened full profile or the small CI VM-test profile.-#-# The source is checked out as a detached git worktree under build/src,-# patches/*.patch are applied on top, the configuration is assembled out-# of tree (build/obj-<arch>) and verified, and bindeb-pkg and/or-# binrpm-pkg produce the packages under build/pkgs/<arch>/<release>/.+# Build Debian packages from the pinned bpf-next source for the test VMs.set -euo pipefailREPO="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"@@ -16,35 +10,11 @@ usage() {cat <<USAGEusage: ${0##*/} [options]- -a, --arch ARCH x86-64 | arm64 | riscv64 (default: host arch)- -f, --format FORMAT deb | rpm | both (default: deb when dpkg-deb- exists, otherwise rpm)- -r, --ref REF git ref to build (default and, for now, the only- one supported: upstream/bpf-next, see patches/)- -o, --out DIR work and output directory (default: build/)+ -a, --arch ARCH x86-64 or arm64 (default: host arch)+ -o, --out DIR work and output directory (default: build/test-kernel/)-j, --jobs N parallel jobs (default: nproc)- -t, --toolchain TC llvm | gcc (default: llvm when clang and ld.lld- are installed, otherwise gcc)- -b, --base BASE defconfig (default) or a path to a .config to- start from instead of the arch defconfig- --profile PROFILE full (default) hardened packages or ci- (VM-test kernel for x86-64 or arm64)- --localversion S use S verbatim as CONFIG_LOCALVERSION instead of- the kernel.conf value plus -YYYYMMDD (build day)- --module-key PEM sign modules with this key+certificate PEM- (ML-DSA-87, see kernel.conf) instead of a key- generated in the object tree- --llvm VER LLVM version for --toolchain llvm, e.g. 20 for- clang-20, ld.lld-20 and llvm-config-20 (default:- the newest one installed completely, else the- unversioned tools)- --openssl DIR OpenSSL >= 3.5 prefix for key generation and- sign-file (bin/ and lib*/pkgconfig/ are used);- also read from \$OPENSSL_PREFIX- --config-only assemble and verify .config, then stop- --with-dbg also build the debug-symbol package- --no-patches do not apply patches/*.patch- --keep-src do not reset the source worktree to REF+ --llvm VER LLVM version (default: newest complete version on PATH)+ --config-only apply patches and verify .config, then stop-h, --helpEnvironment: CC/HOSTCC are not read; MAKEFLAGS is passed through.@@ -59,146 +29,48 @@ host_arch() {case "$(uname -m)" inx86_64) echo x86-64 ;;aarch64) echo arm64 ;;- riscv64) echo riscv64 ;;*) die "unsupported host architecture $(uname -m)" ;;esac}ARCH="$(host_arch)"-FORMAT=""-REF="upstream/bpf-next"-OUT="$REPO/build"+OUT="$(cd "$REPO/../.." && pwd)/build/test-kernel"JOBS="$(nproc)"-TOOLCHAIN=""-BASE="defconfig"-PROFILE="full"-LOCALVERSION=""-MODULE_KEY=""-OPENSSL_PREFIX="${OPENSSL_PREFIX:-}"LLVM_VER=""CONFIG_ONLY=0-WITH_DBG=0-APPLY_PATCHES=1-KEEP_SRC=0while [ $# -gt 0 ]; docase "$1" in-a|--arch) ARCH="$2"; shift 2 ;;- -f|--format) FORMAT="$2"; shift 2 ;;- -r|--ref) REF="$2"; shift 2 ;;-o|--out) OUT="$(mkdir -p "$2" && cd "$2" && pwd)"; shift 2 ;;-j|--jobs) JOBS="$2"; shift 2 ;;- -t|--toolchain) TOOLCHAIN="$2"; shift 2 ;;- -b|--base) BASE="$2"; shift 2 ;;- --profile) PROFILE="$2"; shift 2 ;;- --localversion) LOCALVERSION="$2"; shift 2 ;;- --module-key) MODULE_KEY="$(readlink -f "$2")"; shift 2 ;;- --openssl) OPENSSL_PREFIX="$2"; shift 2 ;;--llvm) LLVM_VER="$2"; shift 2 ;;--config-only) CONFIG_ONLY=1; shift ;;- --with-dbg) WITH_DBG=1; shift ;;- --no-patches) APPLY_PATCHES=0; shift ;;- --keep-src) KEEP_SRC=1; shift ;;-h|--help) usage; exit 0 ;;*) usage >&2; die "unknown argument: $1" ;;esacdone-# patches/ targets bpf-next, which also has the signed loader and the-# fmod_ret scan the configuration asks for; no other tree is built.-[ "$REF" = upstream/bpf-next ] ||- die "unsupported --ref $REF: patches/ targets upstream/bpf-next, the only tree supported for now"--# Architecture table: kernel ARCH, uname machine, Debian arch, GNU triplet-# prefix for a GCC cross build, the arch defconfig target.case "$ARCH" in-x86-64) KARCH=x86_64; UTS=x86_64; DEBARCH=amd64; CROSS=x86_64-linux-gnu- ;;-arm64) KARCH=arm64; UTS=aarch64; DEBARCH=arm64; CROSS=aarch64-linux-gnu- ;;-riscv64) KARCH=riscv; UTS=riscv64; DEBARCH=riscv64; CROSS=riscv64-linux-gnu- ;;-*) die "unsupported --arch $ARCH (x86-64, arm64, riscv64)" ;;+x86-64) KARCH=x86_64 ;;+arm64) KARCH=arm64 ;;+*) die "unsupported --arch $ARCH (x86-64, arm64)" ;;esac-DEFCONFIG=defconfig-if [ -z "$FORMAT" ]; then- if have dpkg-deb; then FORMAT=deb; elif have rpmbuild; then FORMAT=rpm;- else die "neither dpkg-deb nor rpmbuild found"; fi-fi-case "$FORMAT" in deb|rpm|both) ;; *) die "unsupported --format $FORMAT" ;; esac-[[ -z "$LLVM_VER" || "$LLVM_VER" =~ ^[0-9]+$ ]] || die "--llvm takes a version number such as 20, not $LLVM_VER"-[ "$FORMAT" = rpm ] || have dpkg-deb || die "dpkg-deb (dpkg-dev) is required for deb packages"-[ "$FORMAT" = rpm ] || have fakeroot || die "fakeroot is required for deb packages"-[ "$FORMAT" = rpm ] || have dh_listpackages || die "dh_listpackages (debhelper) is required for deb packages; install debhelper"-[ "$FORMAT" = deb ] || have rpmbuild || die "rpmbuild (rpm-build) is required for rpm packages"-for t in make flex bison bc pahole python3 cpio zstd xz pkg-config; do+[[ -z "$LLVM_VER" || "$LLVM_VER" =~ ^[0-9]+$ ]] || die "--llvm takes a version number"+for t in make flex bison bc pahole python3 cpio zstd xz pkg-config rsync; dohave "$t" || die "$t is required"done-have rsync || die "rsync is required (install rsync; Linux headers_install uses it)"-if [ -n "$OPENSSL_PREFIX" ]; then- [ -d "$OPENSSL_PREFIX" ] || die "--openssl prefix not found: $OPENSSL_PREFIX"- export PATH="$OPENSSL_PREFIX/bin:$PATH"- export PKG_CONFIG_PATH="$OPENSSL_PREFIX/lib64/pkgconfig:$OPENSSL_PREFIX/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"-fi-if [ -n "$MODULE_KEY" ]; then- [ -f "$MODULE_KEY" ] || die "module key not found: $MODULE_KEY"- grep -q "PRIVATE KEY-----" "$MODULE_KEY" && grep -q "BEGIN CERTIFICATE-----" "$MODULE_KEY" ||- die "module key must be one PEM file with the private key and its certificate: $MODULE_KEY"-fi--case "$PROFILE" in-full)- FRAGMENTS=("$REPO/kernel.conf" "$REPO/kernel.$ARCH.conf")- BLACKLIST="$REPO/blacklist.conf"- ;;-ci)- case "$ARCH" in- x86-64|arm64) ;;- *) die "--profile ci supports only --arch x86-64 or arm64" ;;- esac- [ "$BASE" = defconfig ] || die "--base cannot be combined with --profile ci"- FRAGMENTS=("$REPO/kernel-ci.conf" "$REPO/kernel-ci.$ARCH.conf")- BLACKLIST=""- ;;-*) die "unsupported --profile $PROFILE (full, ci)" ;;-esac-for f in "${FRAGMENTS[@]}"; do- [ -f "$f" ] || die "missing $f"-done-if [ -n "$BLACKLIST" ]; then- [ -f "$BLACKLIST" ] || die "missing $BLACKLIST"-fi-# An ML-DSA module signing key (kernel.conf) is only selectable when-# Kconfig's OPENSSL_SUPPORTS_ML_DSA probe finds an openssl CLI with-# ML-DSA on PATH, so this must hold before the configuration is assembled,-# with or without --module-key.-if grep -qE '^CONFIG_MODULE_SIG_KEY_TYPE_MLDSA_[0-9]+=y' "${FRAGMENTS[@]}" &&- ! openssl list -key-managers 2>/dev/null | grep -q 'ML-DSA-87'; then- die "$(command -v openssl || echo openssl) ($(openssl version 2>/dev/null || echo missing)) has no ML-DSA; the ML-DSA module signing key in kernel.conf needs OpenSSL >= 3.5 on PATH (use --openssl DIR or \$OPENSSL_PREFIX)"+if [ "$CONFIG_ONLY" = 0 ]; then+ for t in dpkg-deb fakeroot dh_listpackages; do+ have "$t" || die "$t is required for Debian packages"+ donefi--# Symbols a fragment may ask for that only some compilers (or, for the-# arch-dependent ones, some architectures) can provide. They are dropped-# with a warning instead of failing the build; everything else in the-# fragments must land in the final .config exactly as requested.-ALLOW_DROP=(- # clang only- CFI CFI_AUTO_DEFAULT SHADOW_CALL_STACK UNWIND_PATCH_PAC_INTO_SCS- # GCC plugin or clang >= 21- KSTACK_ERASE- # GCC plugin or clang >= 15- RANDSTRUCT_FULL- # needs HAVE_LIVEPATCH, absent on riscv- LIVEPATCH- # needs ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS- MSEAL_SYSTEM_MAPPINGS- # riscv: -fzero-call-used-regs, -fcf-protection and the Zabha assembler- # support arrive with clang 19 / binutils 2.42- ZERO_CALL_USED_REGS RISCV_USER_CFI RISCV_ISA_ZABHA-)+FRAGMENTS=("$REPO/kernel-ci.conf" "$REPO/kernel-ci.$ARCH.conf")# ---------------------------------------------------------------------------# Toolchain# ----------------------------------------------------------------------------HOST="$(host_arch)"# One LLVM version throughout: the unversioned tools for suffix "", or# clang-20, ld.lld-20 and so on for "-20". The newest complete versioned# install is the default because resolve_btfids's fmod_ret scan@@ -218,77 +90,44 @@ newest_llvm() {}[ -n "$LLVM_VER" ] || LLVM_VER="$(newest_llvm)"LLVM_SFX="${LLVM_VER:+-$LLVM_VER}"-if [ -z "$TOOLCHAIN" ]; then- if llvm_complete "$LLVM_SFX"; then TOOLCHAIN=llvm; else TOOLCHAIN=gcc; fi-fi-MAKE_TC=()-case "$TOOLCHAIN" in-llvm)- llvm_complete "$LLVM_SFX" ||- die "LLVM toolchain incomplete (clang$LLVM_SFX, ld.lld$LLVM_SFX, llvm-objcopy$LLVM_SFX, llvm-ar$LLVM_SFX, llvm-nm$LLVM_SFX)"- MAKE_TC=(LLVM="${LLVM_SFX:-1}")- OBJCOPY="llvm-objcopy$LLVM_SFX"- ;;-gcc)- if [ "$HOST" != "$ARCH" ]; then- have "${CROSS}gcc" || die "cross compiler ${CROSS}gcc not found (install it or use --toolchain llvm)"- MAKE_TC=(CROSS_COMPILE="$CROSS")- OBJCOPY="${CROSS}objcopy"- else- OBJCOPY=objcopy- fi- ;;-*) die "unsupported --toolchain $TOOLCHAIN (llvm, gcc)" ;;-esac+llvm_complete "$LLVM_SFX" || die "LLVM toolchain is incomplete ($LLVM_SFX)"+OBJCOPY="llvm-objcopy$LLVM_SFX"# ----------------------------------------------------------------------------# Source worktree at REF plus patches/+# Pinned source and carried patches# ----------------------------------------------------------------------------SHA="$(git -C "$REPO" rev-parse --verify --quiet "${REF}^{commit}")" ||- die "ref '$REF' not found in $REPO (git fetch torvalds/bpf/bpf-next first?)"+read -r SHA <"$REPO/bpf-next.commit"+[[ "$SHA" =~ ^[0-9a-f]{40}$ ]] || die "invalid bpf-next commit in bpf-next.commit"+UPSTREAM=https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.gitSRC="$OUT/src"OBJ="$OUT/obj-$ARCH"-mkdir -p "$OUT"--log "source: $REF = $SHA"-git -C "$REPO" worktree prune-if [ -e "$SRC/.git" ]; then- if [ "$KEEP_SRC" = 0 ]; then- git -C "$SRC" checkout --detach --quiet "$SHA"- git -C "$SRC" reset --hard --quiet- git -C "$SRC" clean -fdxq- fi-else- git -C "$REPO" worktree add --detach --quiet "$SRC" "$SHA"+if [ ! -d "$SRC/.git" ]; then+ git init -q "$SRC"fi--PATCHES=()-if [ "$APPLY_PATCHES" = 1 ] && [ "$KEEP_SRC" = 0 ]; then- while IFS= read -r p; do PATCHES+=("$p"); done < <(find "$REPO/patches" -maxdepth 1 -name '*.patch' -type f 2>/dev/null | sort)- # git am would record whoever runs this, and now, as committer of each- # patch commit, so HEAD, its describe string and the build timestamp- # taken from HEAD below would change on every run. Pin the committer- # to the build identity and the date of REF's commit instead.- AM_DATE="$(git -C "$REPO" log -1 --format=%cd --date=raw "$SHA")"- for p in "${PATCHES[@]}"; do- log "applying $(basename "$p")"- if ! GIT_COMMITTER_NAME=shirudo GIT_COMMITTER_EMAIL=shirudo@build-kernel \- GIT_COMMITTER_DATE="$AM_DATE" git -C "$SRC" am --quiet --3way "$p"; then- log "patch conflict details for $(basename "$p"):"- git -C "$SRC" status --short >&2- git -C "$SRC" diff --cc >&2- git -C "$SRC" am --abort || true- die "patch does not apply to $REF: $p"- fi- done+if ! git -C "$SRC" cat-file -e "$SHA^{commit}" 2>/dev/null; then+ # Three-way patch application also needs the patch preimage blobs.+ git -C "$SRC" fetch --no-tags --shallow-since=2026-09-06 "$UPSTREAM" "$SHA"fi+git -C "$SRC" checkout --detach --quiet "$SHA"+PATCHES=("$REPO"/patches/*.patch)+AM_DATE="$(git -C "$SRC" log -1 --format=%cd --date=raw "$SHA")"+for p in "${PATCHES[@]}"; do+ log "applying $(basename "$p")"+ if ! GIT_COMMITTER_NAME=shirudo GIT_COMMITTER_EMAIL=shirudo@build-kernel \+ GIT_COMMITTER_DATE="$AM_DATE" git -C "$SRC" -c core.hooksPath=/dev/null am --quiet --3way "$p"; then+ git -C "$SRC" status --short >&2+ git -C "$SRC" diff --cc >&2+ git -C "$SRC" am --abort || true+ die "patch does not apply to $SHA: $p"+ fi+doneSRC_DESC="$(git -C "$SRC" describe --tags --always HEAD 2>/dev/null || echo "$SHA")"# shirudo's signed-loader support (the bpf keyring, exclusive maps and the# BPF_PROG_LOAD signature check) ships with Linux 7.4; warn when the tree# predates it so nobody expects "shirudo init" to pass on this kernel.if [ ! -f "$SRC/kernel/bpf/keys.c" ]; then- log "warning: $REF has no kernel/bpf/keys.c: no bpf keyring, shirudo init will refuse this kernel (needs Linux 7.4 or the bpf-next branch)"+ log "warning: $SHA has no kernel/bpf/keys.c: no bpf keyring, shirudo init will refuse this kernel (needs Linux 7.4 or the bpf-next branch)"fi# ---------------------------------------------------------------------------@@ -301,29 +140,18 @@ grep -rhoE '^[[:space:]]*(menu)?config[[:space:]]+[A-Za-z0-9_]+' --include='Kconlint_file() {local f="$1" symwhile IFS= read -r sym; do- grep -qx "$sym" "$KNOWN" || log "lint: $(basename "$f"): CONFIG_$sym does not exist in $REF"+ grep -qx "$sym" "$KNOWN" || log "lint: $(basename "$f"): CONFIG_$sym does not exist in $SHA"done < <(sed -nE 's/^CONFIG_([A-Za-z0-9_]+)=.*/\1/p; s/^# CONFIG_([A-Za-z0-9_]+) is not set$/\1/p' "$f" | sort -u)}for f in "${FRAGMENTS[@]}"; do lint_file "$f"; done-[ -z "$BLACKLIST" ] || lint_file "$BLACKLIST"# ----------------------------------------------------------------------------# Configuration: base, fragments, blacklist, olddefconfig+# Configuration# ----------------------------------------------------------------------------kmake() { make -C "$SRC" O="$OBJ" ARCH="$KARCH" "${MAKE_TC[@]}" "$@"; }+kmake() { make -C "$SRC" O="$OBJ" ARCH="$KARCH" LLVM="${LLVM_SFX:-1}" "$@"; }-if [ "$PROFILE" = ci ]; then- log "base: $KARCH allnoconfig"- kmake -s allnoconfig-elif [ "$BASE" = defconfig ]; then- log "base: $KARCH $DEFCONFIG"- kmake -s "$DEFCONFIG"-else- [ -f "$BASE" ] || die "base config not found: $BASE"- log "base: $BASE"- cp "$BASE" "$OBJ/.config"- kmake -s olddefconfig-fi+log "base: $KARCH allnoconfig"+kmake -s allnoconfiglog "merging ${FRAGMENTS[*]##*/}"(cd "$SRC" && KCONFIG_CONFIG="$OBJ/.config" \@@ -331,27 +159,10 @@ log "merging ${FRAGMENTS[*]##*/}"{ cat "$OBJ/merge.log" >&2; die "merge_config.sh failed"; }grep -E 'Value of|redefined' "$OBJ/merge.log" | sed 's/^/merge: /' >&2 || true-# CONFIG_LOCALVERSION is the fragment's prefix plus the build day, so the-# release string says when a node's kernel was built; --localversion-# replaces the whole string. The "+" that setlocalversion appends to an-# untagged tree is suppressed (LOCALVERSION in the environment), the-# date and the package version carry that information.LV_BASE="$(sed -nE 's/^CONFIG_LOCALVERSION="(.*)"$/\1/p' "${FRAGMENTS[@]}" | tail -1)"-LV="${LOCALVERSION:-${LV_BASE}-$(date -u +%Y%m%d)}"+LV="$LV_BASE-$(date -u +%Y%m%d)""$SRC/scripts/config" --file "$OBJ/.config" --set-str LOCALVERSION "$LV"export LOCALVERSION=""-if [ -n "$MODULE_KEY" ]; then- "$SRC/scripts/config" --file "$OBJ/.config" --set-str MODULE_SIG_KEY "$MODULE_KEY"-fi--BLACKLISTED=()-if [ -n "$BLACKLIST" ]; then- log "applying $(basename "$BLACKLIST")"- while IFS= read -r sym; do BLACKLISTED+=("$sym"); done < <(sed -nE 's/^# CONFIG_([A-Za-z0-9_]+) is not set$/\1/p' "$BLACKLIST")- for sym in "${BLACKLISTED[@]}"; do- "$SRC/scripts/config" --file "$OBJ/.config" --disable "$sym"- done-filog "make olddefconfig"kmake -s olddefconfig@@ -361,13 +172,14 @@ kmake -s olddefconfig# ---------------------------------------------------------------------------declare -A WANT WANTSRC FINALfor f in "${FRAGMENTS[@]}"; do+ fragment=${f##*/}while IFS= read -r line; docase "$line" in"# CONFIG_"*" is not set") sym="${line#\# CONFIG_}"; sym="${sym% is not set}"; WANT[$sym]=n ;;CONFIG_*=*) sym="${line%%=*}"; sym="${sym#CONFIG_}"; WANT[$sym]="${line#*=}" ;;*) continue ;;esac- WANTSRC[$sym]="$(basename "$f")"+ WANTSRC[$sym]="$fragment"done < "$f"donewhile IFS= read -r line; do@@ -377,10 +189,9 @@ while IFS= read -r line; doesacdone < "$OBJ/.config"-allowed_drop() { local s; for s in "${ALLOW_DROP[@]}"; do [ "$s" = "$1" ] && return 0; done; return 1; }WANT[LOCALVERSION]="\"$LV\""-FAIL=0; WARN=0+FAIL=0for sym in $(printf '%s\n' "${!WANT[@]}" | sort); dowant="${WANT[$sym]}"; got="${FINAL[$sym]:-unset}"; ok=1case "$want" in@@ -390,27 +201,15 @@ for sym in $(printf '%s\n' "${!WANT[@]}" | sort); do*) [ "$got" = "$want" ] || ok=0 ;;esac[ "$ok" = 1 ] && continue- if [ "$want" != n ] && allowed_drop "$sym"; then- log "warning: CONFIG_$sym=$want (${WANTSRC[$sym]}) not available with this toolchain/arch (got $got)"- WARN=$((WARN + 1))- else- log "error: CONFIG_$sym wanted $want by ${WANTSRC[$sym]}, final .config has $got"- FAIL=$((FAIL + 1))- fi-done-for sym in "${BLACKLISTED[@]}"; do- got="${FINAL[$sym]:-unset}"- if [ "$got" = y ] || [ "$got" = m ]; then- log "error: blacklisted CONFIG_$sym is $got (selected by something; find it with 'make O=$OBJ ARCH=$KARCH menuconfig', search /$sym)"- FAIL=$((FAIL + 1))- fi+ log "error: CONFIG_$sym wanted $want by ${WANTSRC[$sym]}, final .config has $got"+ FAIL=$((FAIL + 1))done# Two invariants the whole setup rests on, checked on the final result# regardless of what the fragments say. [S][ "${FINAL[LSM]:-}" = '"bpf"' ] || { log "error: CONFIG_LSM is ${FINAL[LSM]:-unset}, must be \"bpf\""; FAIL=$((FAIL + 1)); }[ "${FINAL[DYNAMIC_FTRACE_WITH_DIRECT_CALLS]:-}" = y ] || { log "error: CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS is not y: shirudo cannot attach trampolines"; FAIL=$((FAIL + 1)); }[ "$FAIL" = 0 ] || die "$FAIL configuration mismatch(es); .config left at $OBJ/.config"-log "configuration verified (${#WANT[@]} fragment symbols, ${#BLACKLISTED[@]} blacklisted, $WARN warning(s))"+log "configuration verified (${#WANT[@]} fragment symbols)"# kernelrelease reads CONFIG_LOCALVERSION* from include/config/auto.conf,# which only syncconfig writes.@@ -419,28 +218,6 @@ KREL="$(kmake -s kernelrelease)"KVER="$(kmake -s kernelversion)"cp "$OBJ/.config" "$OUT/kernel-$ARCH.config"-# Module signing with ML-DSA (kernel.conf) needs OpenSSL >= 3.5 on the-# build host twice: scripts/sign-file links libcrypto, and certs/Makefile-# runs "openssl req -newkey ml-dsa-87" unless --module-key supplies the key.-# A config-only run only warns; a build stops here instead of after an-# hour of compiling.-check_signing_host() {- local ver- grep -q '^CONFIG_MODULE_SIG_KEY_TYPE_MLDSA' "$OBJ/.config" || return 0- ver="$(pkg-config --modversion libcrypto 2>/dev/null || echo 0)"- if [ "$(printf '%s\n3.5\n' "$ver" | sort -V | head -1)" != 3.5 ]; then- log "signing: libcrypto $ver via pkg-config is older than 3.5, sign-file cannot sign ML-DSA (use --openssl DIR)"- return 1- fi- return 0-}-if ! check_signing_host; then- if [ "$CONFIG_ONLY" = 1 ]; then- log "warning: this host cannot sign modules for this configuration, see above"- else- die "this host cannot sign modules for this configuration, see above"- fi-filog "release: $KREL ($SRC_DESC)"if [ "$CONFIG_ONLY" = 1 ]; thenlog "config written to $OUT/kernel-$ARCH.config"@@ -454,34 +231,25 @@ STAMP="$(date -u +%Y%m%d%H%M)"PKGDIR="$OUT/pkgs/$ARCH/$KREL-$STAMP"mkdir -p "$PKGDIR"# Reproducible metadata: timestamp of the source commit, fixed user/host.-# Patch commits carry REF's commit date (see git am above), so with+# Patch commits carry the pinned commit date, so with# patches applied this is still the upstream date.-export KBUILD_BUILD_TIMESTAMP="$(git -C "$SRC" log -1 --format=%cD HEAD)"+KBUILD_BUILD_TIMESTAMP="$(git -C "$SRC" log -1 --format=%cD HEAD)"+export KBUILD_BUILD_TIMESTAMPexport KBUILD_BUILD_USER=shirudo KBUILD_BUILD_HOST=build-kernel-export SOURCE_DATE_EPOCH="$(git -C "$SRC" log -1 --format=%ct HEAD)"--if [ "$FORMAT" = deb ] || [ "$FORMAT" = both ]; then- PKGVER="${KVER//-rc/\~rc}-${STAMP}.g${SHA:0:12}"- PROFILES=()- [ "$WITH_DBG" = 1 ] || PROFILES+=(pkg.linux-upstream.nokerneldbg)- # The headers package rebuilds the host tools for the target with the- # GNU cross compiler, which a cross build with LLVM does not have.- [ "$HOST" = "$ARCH" ] || PROFILES+=(pkg.linux-upstream.nokernelheaders)- DIST="$(lsb_release -cs 2>/dev/null || echo unstable)"- log "building bindeb-pkg $PKGVER for $DEBARCH (-j$JOBS, $TOOLCHAIN)"- DEB_BUILD_PROFILES="${PROFILES[*]}" \+SOURCE_DATE_EPOCH="$(git -C "$SRC" log -1 --format=%ct HEAD)"+export SOURCE_DATE_EPOCH++PKGVER="${KVER//-rc/\~rc}-${STAMP}.g${SHA:0:12}"+PROFILES=(pkg.linux-upstream.nokerneldbg)+# The headers package needs a GNU cross compiler to build the target tools.+[ "$(host_arch)" = "$ARCH" ] || PROFILES+=(pkg.linux-upstream.nokernelheaders)+DIST="$(lsb_release -cs 2>/dev/null || echo unstable)"+log "building bindeb-pkg $PKGVER for $ARCH (-j$JOBS)"+DEB_BUILD_PROFILES="${PROFILES[*]}" \kmake -j"$JOBS" bindeb-pkg KDEB_PKGVERSION="$PKGVER" KDEB_CHANGELOG_DIST="$DIST" \DPKG_FLAGS="--no-check-builddeps"- mv "$OUT"/*_"${PKGVER}"_*.deb "$OUT"/*_"${PKGVER}"_*.buildinfo "$OUT"/*_"${PKGVER}"_*.changes "$PKGDIR"/ 2>/dev/null || true- ls "$PKGDIR"/*.deb >/dev/null 2>&1 || die "no .deb produced for $PKGVER"-fi-if [ "$FORMAT" = rpm ] || [ "$FORMAT" = both ]; then- log "building binrpm-pkg for $UTS (-j$JOBS, $TOOLCHAIN)"- rm -rf "$OBJ/rpmbuild/RPMS"- kmake -j"$JOBS" binrpm-pkg- find "$OBJ/rpmbuild/RPMS" -name '*.rpm' -exec cp {} "$PKGDIR"/ \;- ls "$PKGDIR"/*.rpm >/dev/null 2>&1 || die "no .rpm produced"-fi+mv "$OUT"/*_"${PKGVER}"_*.deb "$OUT"/*_"${PKGVER}"_*.buildinfo "$OUT"/*_"${PKGVER}"_*.changes "$PKGDIR"/+ls "$PKGDIR"/*.deb >/dev/null 2>&1 || die "no .deb produced for $PKGVER"# ---------------------------------------------------------------------------# Side artifacts: config, BTF for vmlinux.h generation, build info@@ -490,34 +258,41 @@ cp "$OBJ/.config" "$PKGDIR/config-$KREL"cp "$OBJ/System.map" "$PKGDIR/System.map-$KREL"# The module signing certificate (public half) travels with the packages;# the private key stays where it was: the object tree when generated here.-if [ -n "$MODULE_KEY" ]; then- openssl x509 -in "$MODULE_KEY" -outform DER -out "$PKGDIR/module-signing-cert-$KREL.der" 2>/dev/null ||- log "warning: could not extract the certificate from $MODULE_KEY"-elif [ -f "$OBJ/certs/signing_key.x509" ]; then+if [ -f "$OBJ/certs/signing_key.x509" ]; thencp "$OBJ/certs/signing_key.x509" "$PKGDIR/module-signing-cert-$KREL.der"fi"$OBJCOPY" --dump-section .BTF="$PKGDIR/vmlinux-$KREL.btf" "$OBJ/vmlinux" /dev/null 2>/dev/null ||"$OBJCOPY" --dump-section .BTF="$PKGDIR/vmlinux-$KREL.btf" "$OBJ/vmlinux" "$OBJ/.vmlinux.btf-tmp"rm -f "$OBJ/.vmlinux.btf-tmp"[ -s "$PKGDIR/vmlinux-$KREL.btf" ] || die "vmlinux has no .BTF section"+# Use commit metadata for the kernel archive and fixed metadata for the recipe+# so both architecture jobs can verify the same source archive.+git -C "$SRC" archive --format=tar --prefix=linux/ HEAD >"$OUT/kernel-ci-source.tar"+tar --append --file="$OUT/kernel-ci-source.tar" --sort=name --owner=0 --group=0 \+ --numeric-owner --mtime="@$SOURCE_DATE_EPOCH" -C "$REPO/../.." testing/kernel+zstd -q -f "$OUT/kernel-ci-source.tar" -o "$OUT/kernel-ci-source.tar.zst"+rm -f "$OUT/kernel-ci-source.tar"+source_sha256=$(sha256sum "$OUT/kernel-ci-source.tar.zst"){- echo "ref=$REF"+ echo "ref=bpf-next"echo "commit=$SHA"+ echo "patched_commit=$(git -C "$SRC" rev-parse HEAD)"echo "describe=$SRC_DESC"echo "patches=${PATCHES[*]##*/}"echo "arch=$ARCH"echo "kernelrelease=$KREL"- echo "toolchain=$TOOLCHAIN"+ echo "toolchain=llvm"echo "compiler=$(grep -E '^CONFIG_CC_VERSION_TEXT=' "$OBJ/.config" | cut -d= -f2-)"- echo "base=$BASE"- config_inputs=("${FRAGMENTS[@]}")- [ -z "$BLACKLIST" ] || config_inputs+=("$BLACKLIST")- echo "profile=$PROFILE"- echo "fragments_sha256=$(cat "${config_inputs[@]}" | sha256sum | cut -d' ' -f1)"- echo "module_key=${MODULE_KEY:-generated in $OBJ/certs/signing_key.pem}"+ echo "base=allnoconfig"+ echo "profile=ci"+ echo "fragments_sha256=$(cat "${FRAGMENTS[@]}" | sha256sum | cut -d' ' -f1)"+ echo "producer_commit=$(git -C "$REPO" rev-parse HEAD)"+ echo "run_id=${GITHUB_RUN_ID:-}"+ echo "run_attempt=${GITHUB_RUN_ATTEMPT:-}"+ echo "source_sha256=${source_sha256%% *}"echo "libcrypto=$(pkg-config --modversion libcrypto 2>/dev/null || echo unknown)"echo "built_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)"} > "$PKGDIR/BUILD-INFO"-(cd "$PKGDIR" && find . -type f ! -name SHA256SUMS -print0 | sort -z | xargs -0 sha256sum > SHA256SUMS)+(cd "$PKGDIR" && find . -type f ! -name SHA256SUMS -print0 | sort -z | xargs -0 sha256sum > ../SHA256SUMS && mv ../SHA256SUMS .)log "packages in $PKGDIR:"ls -1 "$PKGDIR" >&2diff --git a/testing/kernel/patches/.gitattributes b/testing/kernel/patches/.gitattributesnew file mode 100644index 00000000..304effa8--- /dev/null+++ b/testing/kernel/patches/.gitattributes@@ -0,0 +1,2 @@+# Retain format-patch context and signatures verbatim.+*.patch -whitespace