From 4c53768dccdc22cf47e6da4afb3b6f67018bd50b Mon Sep 17 00:00:00 2001 From: Sam Yuan Date: Wed, 3 Apr 2024 20:00:30 +0800 Subject: [PATCH] add linux Header and libbpf prequest Signed-off-by: Sam Yuan --- .github/workflows/test.yml | 1 + main.sh | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cedabf9..3f0ad7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -80,6 +80,7 @@ jobs: export GRAFANA_ENABLE=${{matrix.GRAFANA_ENABLE}} export CLUSTER_PROVIDER=${{matrix.cluster_provider}} export TEKTON_ENABLE=${{matrix.TEKTON_ENABLE}} + ./main.sh prerequisites ./main.sh up - name: verify run: | diff --git a/main.sh b/main.sh index eab4836..1ad883f 100755 --- a/main.sh +++ b/main.sh @@ -52,6 +52,7 @@ declare -r REGISTRY_PORT=${REGISTRY_PORT:-5001} declare -r PROMETHEUS_ENABLE=${PROMETHEUS_ENABLE:-false} declare -r GRAFANA_ENABLE=${GRAFANA_ENABLE:-false} declare -r TEKTON_ENABLE=${TEKTON_ENABLE:-false} +declare -r LIBBPF_VERSION=${LIBBPF_VERSION:-v1.2.0} source "$PROJECT_ROOT/lib/utils.sh" @@ -122,6 +123,24 @@ print_config() { EOF } +linuxHeader() { + sudo apt-get install -y linux-headers-"$(uname -r)" + sudo apt-get install -y linux-modules-"$(uname -r)" + sudo apt-get install -y linux-modules-extra-"$(uname -r)" +} + +ebpf() { + sudo apt-get install -y binutils-dev build-essential pkg-config libelf-dev + mkdir -p temp-libbpf + cd temp-libbpf + git clone -b "$LIBBPF_VERSION" https://github.com/libbpf/libbpf + cd libbpf/src + sudo BUILD_STATIC_ONLY=y make install + sudo make install_uapi_headers + cd ../../.. + sudo rm -rf temp-libbpf +} + main() { # ensure that all relative file refs are relative to the project root cd "$PROJECT_ROOT" @@ -143,6 +162,11 @@ main() { print_config case "$1" in + prerequisites) + linuxHeader + ebpf + return $? + ;; up) cluster_up return $?