Debian Codegraph @

scripts/update-kernel-deps.sh

raw symbols SCIP
1 #!/bin/bash
2
3 set -euo pipefail
4
5 # Extract kernel version from CI workflow file
6 kernel_version=$(awk -F': ' '/CI_MAX_KERNEL_VERSION:/ {gsub(/['\''"]/, "", $2); print $2}' .github/workflows/ci.yml)
7
8 if [ -z "$kernel_version" ]; then
9 echo "Error: Could not extract CI_MAX_KERNEL_VERSION from .github/workflows/ci.yml" >&2
10 exit 1
11 fi
12
13 echo "Using kernel version: $kernel_version"
14
15 tmp=$(mktemp -d)
16
17 cleanup() {
18 rm -r "$tmp"
19 }
20
21 trap cleanup EXIT
22
23 # Download and process libbpf.c
24 # Truncate .0 patch versions (e.g., 6.16.0 -> 6.16, but leave 7.0 as 7.0)
25 kernel_version_for_url="$kernel_version"
26 if [[ $kernel_version =~ ^([0-9]+\.[0-9]+)\.0$ ]]; then
27 kernel_version_for_url="${BASH_REMATCH[1]}"
28 fi
29 curl -fL "https://raw.githubusercontent.com/gregkh/linux/refs/tags/v$kernel_version_for_url/tools/lib/bpf/libbpf.c" -o "$tmp/libbpf.c"
30 "./internal/cmd/gensections.awk" "$tmp/libbpf.c" | gofmt > "./elf_sections.go"
31
32 # Download and process vmlinux and btf_testmod
33 go tool crane export "ghcr.io/cilium/ci-kernels:$kernel_version" | tar -x -C "$tmp"
34
35 extract-vmlinux "$tmp/boot/vmlinuz" > "$tmp/vmlinux"
36
37 objcopy --dump-section .BTF=/dev/stdout "$tmp/vmlinux" /dev/null | gzip > "btf/testdata/vmlinux.btf.gz"
38 find "$tmp/lib/modules" -type f -name bpf_testmod.ko -exec objcopy --dump-section .BTF="btf/testdata/btf_testmod.btf" {} /dev/null \;
39 find "$tmp/lib/modules" -type f -name bpf_testmod.ko -exec objcopy --dump-section .BTF.base="btf/testdata/btf_testmod.btf.base" {} /dev/null \;