]> git.ipfire.org Git - thirdparty/systemd.git/blame - travis-ci/managers/fedora.sh
travis: install missing deps for the Coverity run
[thirdparty/systemd.git] / travis-ci / managers / fedora.sh
CommitLineData
a9145fc4
FS
1#!/bin/bash
2
3# Run this script from the root of the systemd's git repository
4# or set REPO_ROOT to a correct path.
5#
6# Example execution on Fedora:
0d589dfc 7# dnf install docker
a9145fc4
FS
8# systemctl start docker
9# export CONT_NAME="my-fancy-container"
10# travis-ci/managers/fedora.sh SETUP RUN CLEANUP
11
eeb8c7ac 12PHASES=(${@:-SETUP RUN RUN_ASAN_UBSAN CLEANUP})
a9145fc4 13FEDORA_RELEASE="${FEDORA_RELEASE:-rawhide}"
eeb8c7ac 14CONT_NAME="${CONT_NAME:-systemd-fedora-$FEDORA_RELEASE}"
a9145fc4
FS
15DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}"
16DOCKER_RUN="${DOCKER_RUN:-docker run}"
17REPO_ROOT="${REPO_ROOT:-$PWD}"
0116d27a
FS
18ADDITIONAL_DEPS=(
19 clang
20 dnf-plugins-core
a64911f9
FS
21 hostname
22 iputils
23 jq
24 libasan
0116d27a 25 libfdisk-devel
a64911f9 26 libfido2-devel
0116d27a
FS
27 libpwquality-devel
28 libubsan
a64911f9 29 libzstd-devel
0116d27a
FS
30 llvm
31 openssl-devel
32 p11-kit-devel
33 perl
34 python3-evdev
35 python3-pyparsing
36)
a9145fc4 37
b36746c9 38info() {
a9145fc4
FS
39 echo -e "\033[33;1m$1\033[0m"
40}
41
b36746c9
FS
42# Simple wrapper which retries given command up to five times
43_retry() {
44 local EC=1
45
46 for i in {1..5}; do
47 if "$@"; then
48 EC=0
49 break
50 fi
51
52 sleep $((i * 5))
53 done
54
55 return $EC
56}
57
a9145fc4
FS
58set -e
59
d419b75c
EV
60source "$(dirname $0)/travis_wait.bash"
61
a9145fc4
FS
62for phase in "${PHASES[@]}"; do
63 case $phase in
64 SETUP)
65 info "Setup phase"
66 info "Using Fedora $FEDORA_RELEASE"
a9145fc4
FS
67 # Pull a Docker image and start a new container
68 docker pull fedora:$FEDORA_RELEASE
69 info "Starting container $CONT_NAME"
70 $DOCKER_RUN -v $REPO_ROOT:/build:rw \
a9145fc4
FS
71 -w /build --privileged=true --name $CONT_NAME \
72 -dit --net=host fedora:$FEDORA_RELEASE /sbin/init
14157349
FS
73 # Wait for the container to properly boot up, otherwise we were
74 # running following dnf commands during the initializing/starting
75 # (early/late bootup) phase, which caused nasty race conditions
76 $DOCKER_EXEC bash -c 'systemctl is-system-running --wait || :'
b36746c9 77 _retry $DOCKER_EXEC dnf makecache
a9145fc4 78 # Install necessary build/test requirements
b36746c9
FS
79 _retry $DOCKER_EXEC dnf -y --exclude selinux-policy\* upgrade
80 _retry $DOCKER_EXEC dnf -y install "${ADDITIONAL_DEPS[@]}"
81 _retry $DOCKER_EXEC dnf -y builddep systemd
a9145fc4
FS
82 ;;
83 RUN)
84 info "Run phase"
85 # Build systemd
7970a525 86 $DOCKER_EXEC meson --werror -Dtests=unsafe -Dslow-tests=true build
eeec5f2a 87 $DOCKER_EXEC ninja -v -C build
1667d63a 88 $DOCKER_EXEC ninja -C build test
79f6178e 89 ;;
37cbcd46 90 RUN_CLANG)
0b0673b6 91 docker exec -e CC=clang -e CXX=clang++ -it $CONT_NAME meson --werror -Dtests=unsafe -Dslow-tests=true -Dman=true build
37cbcd46
EV
92 $DOCKER_EXEC ninja -v -C build
93 $DOCKER_EXEC ninja -C build test
94 ;;
eeb8c7ac
FS
95 RUN_ASAN|RUN_GCC_ASAN_UBSAN|RUN_CLANG_ASAN_UBSAN)
96 if [[ "$phase" = "RUN_CLANG_ASAN_UBSAN" ]]; then
b8366c54
EV
97 ENV_VARS="-e CC=clang -e CXX=clang++"
98 MESON_ARGS="-Db_lundef=false" # See https://github.com/mesonbuild/meson/issues/764
99 fi
100 docker exec $ENV_VARS -it $CONT_NAME meson --werror -Dtests=unsafe -Db_sanitize=address,undefined $MESON_ARGS build
1667d63a 101 $DOCKER_EXEC ninja -v -C build
6dfe7f43
EV
102
103 # Never remove halt_on_error from UBSAN_OPTIONS. See https://github.com/systemd/systemd/commit/2614d83aa06592aedb.
b6b35f0e
EV
104 travis_wait docker exec --interactive=false \
105 -e UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 \
106 -e ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 \
f5f9a580 107 -e "TRAVIS=$TRAVIS" \
b6b35f0e
EV
108 -t $CONT_NAME \
109 meson test --timeout-multiplier=3 -C ./build/ --print-errorlogs
a9145fc4
FS
110 ;;
111 CLEANUP)
112 info "Cleanup phase"
113 docker stop $CONT_NAME
114 docker rm -f $CONT_NAME
115 ;;
116 *)
b36746c9 117 error "Unknown phase '$phase'"
a9145fc4
FS
118 exit 1
119 esac
120done