summaryrefslogtreecommitdiffstats
path: root/lib/libbpf/ci/managers/debian.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 07:10:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 07:10:00 +0000
commit4ba2b326284765e942044db13a7f0dae702bec93 (patch)
treecbdfaec33eed4f3a970c54cd10e8ddfe3003b3b1 /lib/libbpf/ci/managers/debian.sh
parentInitial commit. (diff)
downloadxdp-tools-4ba2b326284765e942044db13a7f0dae702bec93.tar.xz
xdp-tools-4ba2b326284765e942044db13a7f0dae702bec93.zip
Adding upstream version 1.3.1.upstream/1.3.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/libbpf/ci/managers/debian.sh')
-rwxr-xr-xlib/libbpf/ci/managers/debian.sh90
1 files changed, 90 insertions, 0 deletions
diff --git a/lib/libbpf/ci/managers/debian.sh b/lib/libbpf/ci/managers/debian.sh
new file mode 100755
index 0000000..bb96114
--- /dev/null
+++ b/lib/libbpf/ci/managers/debian.sh
@@ -0,0 +1,90 @@
+#!/bin/bash
+
+PHASES=(${@:-SETUP RUN RUN_ASAN CLEANUP})
+DEBIAN_RELEASE="${DEBIAN_RELEASE:-testing}"
+CONT_NAME="${CONT_NAME:-libbpf-debian-$DEBIAN_RELEASE}"
+ENV_VARS="${ENV_VARS:-}"
+DOCKER_RUN="${DOCKER_RUN:-docker run}"
+REPO_ROOT="${REPO_ROOT:-$PWD}"
+ADDITIONAL_DEPS=(clang pkg-config gcc-10)
+EXTRA_CFLAGS=""
+EXTRA_LDFLAGS=""
+
+function info() {
+ echo -e "\033[33;1m$1\033[0m"
+}
+
+function error() {
+ echo -e "\033[31;1m$1\033[0m"
+}
+
+function docker_exec() {
+ docker exec $ENV_VARS $CONT_NAME "$@"
+}
+
+set -eu
+
+source "$(dirname $0)/travis_wait.bash"
+
+for phase in "${PHASES[@]}"; do
+ case $phase in
+ SETUP)
+ info "Setup phase"
+ info "Using Debian $DEBIAN_RELEASE"
+
+ docker --version
+
+ docker pull debian:$DEBIAN_RELEASE
+ info "Starting container $CONT_NAME"
+ $DOCKER_RUN -v $REPO_ROOT:/build:rw \
+ -w /build --privileged=true --name $CONT_NAME \
+ -dit --net=host debian:$DEBIAN_RELEASE /bin/bash
+ echo -e "::group::Build Env Setup"
+ docker_exec bash -c "echo deb-src http://deb.debian.org/debian $DEBIAN_RELEASE main >>/etc/apt/sources.list"
+ docker_exec apt-get -y update
+ docker_exec apt-get -y install aptitude
+ docker_exec aptitude -y build-dep libelf-dev
+ docker_exec aptitude -y install libelf-dev
+ docker_exec aptitude -y install "${ADDITIONAL_DEPS[@]}"
+ echo -e "::endgroup::"
+ ;;
+ RUN|RUN_CLANG|RUN_GCC10|RUN_ASAN|RUN_CLANG_ASAN|RUN_GCC10_ASAN)
+ CC="cc"
+ if [[ "$phase" = *"CLANG"* ]]; then
+ ENV_VARS="-e CC=clang -e CXX=clang++"
+ CC="clang"
+ elif [[ "$phase" = *"GCC10"* ]]; then
+ ENV_VARS="-e CC=gcc-10 -e CXX=g++-10"
+ CC="gcc-10"
+ else
+ EXTRA_CFLAGS="${EXTRA_CFLAGS} -Wno-stringop-truncation"
+ fi
+ if [[ "$phase" = *"ASAN"* ]]; then
+ EXTRA_CFLAGS="${EXTRA_CFLAGS} -fsanitize=address,undefined"
+ EXTRA_LDFLAGS="${EXTRA_LDFLAGS} -fsanitize=address,undefined"
+ fi
+ docker_exec mkdir build install
+ docker_exec ${CC} --version
+ info "build"
+ docker_exec make -j$((4*$(nproc))) EXTRA_CFLAGS="${EXTRA_CFLAGS}" EXTRA_LDFLAGS="${EXTRA_LDFLAGS}" -C ./src -B OBJDIR=../build
+ info "ldd build/libbpf.so:"
+ docker_exec ldd build/libbpf.so
+ if ! docker_exec ldd build/libbpf.so | grep -q libelf; then
+ error "No reference to libelf.so in libbpf.so!"
+ exit 1
+ fi
+ info "install"
+ docker_exec make -j$((4*$(nproc))) -C src OBJDIR=../build DESTDIR=../install install
+ info "link binary"
+ docker_exec bash -c "EXTRA_CFLAGS=\"${EXTRA_CFLAGS}\" EXTRA_LDFLAGS=\"${EXTRA_LDFLAGS}\" ./ci/managers/test_compile.sh"
+ ;;
+ CLEANUP)
+ info "Cleanup phase"
+ docker stop $CONT_NAME
+ docker rm -f $CONT_NAME
+ ;;
+ *)
+ echo >&2 "Unknown phase '$phase'"
+ exit 1
+ esac
+done