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