]> git.ipfire.org Git - thirdparty/systemd.git/blob - travis-ci/managers/debian.sh
Merge pull request #15794 from poettering/pam-sudo-fixes-part2
[thirdparty/systemd.git] / travis-ci / managers / debian.sh
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:
7 # dnf install docker
8 # systemctl start docker
9 # export CONT_NAME="my-fancy-container"
10 # travis-ci/managers/debian.sh SETUP RUN CLEANUP
11
12 PHASES=(${@:-SETUP RUN RUN_ASAN CLEANUP})
13 DEBIAN_RELEASE="${DEBIAN_RELEASE:-testing}"
14 CONT_NAME="${CONT_NAME:-debian-$DEBIAN_RELEASE-$RANDOM}"
15 DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}"
16 DOCKER_RUN="${DOCKER_RUN:-docker run}"
17 REPO_ROOT="${REPO_ROOT:-$PWD}"
18 ADDITIONAL_DEPS=(python3-libevdev
19 python3-pyparsing
20 clang
21 perl
22 libpwquality-dev
23 fdisk
24 libfdisk-dev
25 libp11-kit-dev
26 libssl-dev
27 libzstd-dev
28 zstd)
29
30 function info() {
31 echo -e "\033[33;1m$1\033[0m"
32 }
33
34 set -e
35
36 source "$(dirname $0)/travis_wait.bash"
37
38 for phase in "${PHASES[@]}"; do
39 case $phase in
40 SETUP)
41 info "Setup phase"
42 info "Using Debian $DEBIAN_RELEASE"
43 printf "FROM debian:$DEBIAN_RELEASE\nRUN bash -c 'apt-get -y update && apt-get install -y systemd'\n" | docker build -t debian-with-systemd/latest -
44 info "Starting container $CONT_NAME"
45 $DOCKER_RUN -v $REPO_ROOT:/build:rw -e container=docker \
46 -w /build --privileged=true --name $CONT_NAME \
47 -dit --net=host debian-with-systemd/latest /bin/systemd
48 $DOCKER_EXEC bash -c "echo deb-src http://deb.debian.org/debian $DEBIAN_RELEASE main >>/etc/apt/sources.list"
49 # Wait for the container to properly boot up, otherwise we were
50 # running following apt-get commands during the initializing/starting
51 # (early/late bootup) phase, which caused nasty race conditions
52 $DOCKER_EXEC bash -c 'systemctl is-system-running --wait || :'
53 $DOCKER_EXEC apt-get -y update
54 $DOCKER_EXEC apt-get -y build-dep systemd
55 $DOCKER_EXEC apt-get -y install "${ADDITIONAL_DEPS[@]}"
56 ;;
57 RUN|RUN_CLANG)
58 if [[ "$phase" = "RUN_CLANG" ]]; then
59 ENV_VARS="-e CC=clang -e CXX=clang++"
60 fi
61 docker exec $ENV_VARS -it $CONT_NAME meson --werror -Dtests=unsafe -Dslow-tests=true -Dsplit-usr=true -Dman=true build
62 $DOCKER_EXEC ninja -v -C build
63 docker exec -e "TRAVIS=$TRAVIS" -it $CONT_NAME ninja -C build test
64 ;;
65 RUN_ASAN|RUN_CLANG_ASAN)
66 if [[ "$phase" = "RUN_CLANG_ASAN" ]]; then
67 ENV_VARS="-e CC=clang -e CXX=clang++"
68 MESON_ARGS="-Db_lundef=false" # See https://github.com/mesonbuild/meson/issues/764
69 fi
70 docker exec $ENV_VARS -it $CONT_NAME meson --werror -Dtests=unsafe -Db_sanitize=address,undefined -Dsplit-usr=true $MESON_ARGS build
71 $DOCKER_EXEC ninja -v -C build
72
73 # Never remove halt_on_error from UBSAN_OPTIONS. See https://github.com/systemd/systemd/commit/2614d83aa06592aedb.
74 travis_wait docker exec --interactive=false \
75 -e UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 \
76 -e ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1 \
77 -e "TRAVIS=$TRAVIS" \
78 -t $CONT_NAME \
79 meson test --timeout-multiplier=3 -C ./build/ --print-errorlogs
80 ;;
81 CLEANUP)
82 info "Cleanup phase"
83 docker stop $CONT_NAME
84 docker rm -f $CONT_NAME
85 ;;
86 *)
87 echo >&2 "Unknown phase '$phase'"
88 exit 1
89 esac
90 done