]>
Commit | Line | Data |
---|---|---|
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: | |
7 | # dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo | |
8 | # dnf install -y docker-ce | |
9 | # systemctl start docker | |
10 | # export CONT_NAME="my-fancy-container" | |
11 | # travis-ci/managers/fedora.sh SETUP RUN CLEANUP | |
12 | ||
13 | PHASES=(${@:-SETUP RUN CLEANUP}) | |
14 | FEDORA_RELEASE="${FEDORA_RELEASE:-rawhide}" | |
15 | CONT_NAME="${CONT_NAME:-fedora-$FEDORA_RELEASE-$RANDOM}" | |
16 | DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}" | |
17 | DOCKER_RUN="${DOCKER_RUN:-docker run}" | |
18 | REPO_ROOT="${REPO_ROOT:-$PWD}" | |
059f3192 | 19 | ADDITIONAL_DEPS=(dnf-plugins-core python2 iputils hostname libasan) |
a9145fc4 FS |
20 | |
21 | function info() { | |
22 | echo -e "\033[33;1m$1\033[0m" | |
23 | } | |
24 | ||
25 | set -e | |
26 | ||
27 | for phase in "${PHASES[@]}"; do | |
28 | case $phase in | |
29 | SETUP) | |
30 | info "Setup phase" | |
31 | info "Using Fedora $FEDORA_RELEASE" | |
32 | MACHINE_ID="/etc/machine-id" | |
33 | if [ ! -f $MACHINE_ID ]; then | |
34 | MACHINE_ID="/var/lib/dbus/machine-id" | |
35 | fi | |
36 | # Pull a Docker image and start a new container | |
37 | docker pull fedora:$FEDORA_RELEASE | |
38 | info "Starting container $CONT_NAME" | |
39 | $DOCKER_RUN -v $REPO_ROOT:/build:rw \ | |
40 | -v $MACHINE_ID:/etc/machine-id:ro \ | |
41 | -w /build --privileged=true --name $CONT_NAME \ | |
42 | -dit --net=host fedora:$FEDORA_RELEASE /sbin/init | |
43 | $DOCKER_EXEC dnf makecache | |
44 | # Install necessary build/test requirements | |
45 | $DOCKER_EXEC dnf -y install "${ADDITIONAL_DEPS[@]}" | |
46 | $DOCKER_EXEC dnf -y builddep systemd | |
47 | ;; | |
48 | RUN) | |
49 | info "Run phase" | |
50 | # Build systemd | |
51 | $DOCKER_EXEC meson build | |
52 | $DOCKER_EXEC ninja -C build | |
53 | # Run 'make check' | |
54 | $DOCKER_EXEC ninja -C build test | |
55 | ;; | |
56 | CLEANUP) | |
57 | info "Cleanup phase" | |
58 | docker stop $CONT_NAME | |
59 | docker rm -f $CONT_NAME | |
60 | ;; | |
61 | *) | |
62 | echo >&2 "Unknown phase '$phase'" | |
63 | exit 1 | |
64 | esac | |
65 | done |