github.com/cilium/ebpf@v0.15.0/testdata/sh/update-kernel-deps.sh (about)

     1  #!/bin/bash
     2  
     3  set -euo pipefail
     4  
     5  source "$(dirname "$(realpath "$0")")/lib.sh"
     6  
     7  tmp=$(mktemp -d)
     8  
     9  cleanup() {
    10  	rm -r "$tmp"
    11  }
    12  
    13  trap cleanup EXIT
    14  
    15  # Download and process libbpf.c
    16  curl -fL "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/plain/tools/lib/bpf/libbpf.c?h=v$KERNEL_VERSION" -o "$tmp/libbpf.c"
    17  "./internal/cmd/gensections.awk" "$tmp/libbpf.c" | gofmt > "./elf_sections.go"
    18  
    19  # Download and process vmlinux and btf_testmod
    20  extract_oci_image "ghcr.io/cilium/ci-kernels:$KERNEL_VERSION" "$tmp"
    21  
    22  "/lib/modules/$(uname -r)/build/scripts/extract-vmlinux" "$tmp/boot/vmlinuz" > "$tmp/vmlinux"
    23  
    24  objcopy --dump-section .BTF=/dev/stdout "$tmp/vmlinux" /dev/null | gzip > "btf/testdata/vmlinux.btf.gz"
    25  find "$tmp/lib/modules" -type f -name bpf_testmod.ko -exec objcopy --dump-section .BTF="btf/testdata/btf_testmod.btf" {} /dev/null \;