36e8a3
From 45b0a38b47e07186dfe35095c7d8b1e4c2524d80 Mon Sep 17 00:00:00 2001
36e8a3
From: Frantisek Sumsal <fsumsal@redhat.com>
36e8a3
Date: Mon, 14 Jan 2019 14:49:32 +0100
36e8a3
Subject: [PATCH] travis: RHEL8 support
36e8a3
36e8a3
(cherry picked from commit e5c78840b2b124400f56cb5fbaf2357cd8901218)
36e8a3
---
36e8a3
 .travis.yml                                   |   8 +-
36e8a3
 ...ravis-centos.sh => travis-centos-rhel7.sh} |   0
36e8a3
 ci/travis-centos-rhel8.sh                     | 130 ++++++++++++++++++
36e8a3
 3 files changed, 135 insertions(+), 3 deletions(-)
36e8a3
 rename ci/{travis-centos.sh => travis-centos-rhel7.sh} (100%)
36e8a3
 create mode 100755 ci/travis-centos-rhel8.sh
36e8a3
36e8a3
diff --git a/.travis.yml b/.travis.yml
36e8a3
index fc6388732..1c4e6f972 100644
36e8a3
--- a/.travis.yml
36e8a3
+++ b/.travis.yml
36e8a3
@@ -19,11 +19,13 @@ jobs:
36e8a3
               - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
36e8a3
               - docker --version
36e8a3
           install:
36e8a3
-              - $CI_ROOT/travis-centos.sh SETUP
36e8a3
+              - RHEL_VERSION="rhel7"
36e8a3
+              - [ -f meson.build ] && RHEL_VERSION="rhel8"
36e8a3
+              - $CI_ROOT/travis-centos-${RHEL_VERSION}.sh SETUP
36e8a3
           script:
36e8a3
               - set -e
36e8a3
               # Build systemd
36e8a3
-              - $CI_ROOT/travis-centos.sh RUN
36e8a3
+              - $CI_ROOT/travis-centos-${RHEL_VERSION}.sh RUN
36e8a3
               - set +e
36e8a3
           after_script:
36e8a3
-              - $CI_ROOT/travis-centos.sh CLEANUP
36e8a3
+              - $CI_ROOT/travis-centos-${RHEL_VERSION}.sh CLEANUP
36e8a3
diff --git a/ci/travis-centos.sh b/ci/travis-centos-rhel7.sh
36e8a3
similarity index 100%
36e8a3
rename from ci/travis-centos.sh
36e8a3
rename to ci/travis-centos-rhel7.sh
36e8a3
diff --git a/ci/travis-centos-rhel8.sh b/ci/travis-centos-rhel8.sh
36e8a3
new file mode 100755
36e8a3
index 000000000..968603f94
36e8a3
--- /dev/null
36e8a3
+++ b/ci/travis-centos-rhel8.sh
36e8a3
@@ -0,0 +1,130 @@
36e8a3
+#!/bin/bash
36e8a3
+
36e8a3
+# Run this script from the root of the systemd's git repository
36e8a3
+# or set REPO_ROOT to a correct path.
36e8a3
+#
36e8a3
+# Example execution on Fedora:
36e8a3
+# dnf install docker
36e8a3
+# systemctl start docker
36e8a3
+# export CONT_NAME="my-fancy-container"
36e8a3
+# ci/travis-centos.sh SETUP RUN CLEANUP
36e8a3
+
36e8a3
+PHASES=(${@:-SETUP RUN CLEANUP})
36e8a3
+CENTOS_RELEASE="${CENTOS_RELEASE:-latest}"
36e8a3
+CONT_NAME="${CONT_NAME:-centos-$CENTOS_RELEASE-$RANDOM}"
36e8a3
+DOCKER_EXEC="${DOCKER_EXEC:-docker exec -it $CONT_NAME}"
36e8a3
+DOCKER_RUN="${DOCKER_RUN:-docker run}"
36e8a3
+REPO_ROOT="${REPO_ROOT:-$PWD}"
36e8a3
+ADDITIONAL_DEPS=(systemd-ci-environment libidn2-devel python-lxml python36 ninja-build libasan net-tools strace nc busybox e2fsprogs quota dnsmasq)
36e8a3
+# Repo with additional depencencies to compile newer systemd on CentOS 7
36e8a3
+COPR_REPO="https://copr.fedorainfracloud.org/coprs/mrc0mmand/systemd-centos-ci/repo/epel-7/mrc0mmand-systemd-centos-ci-epel-7.repo"
36e8a3
+COPR_REPO_PATH="/etc/yum.repos.d/${COPR_REPO##*/}"
36e8a3
+
36e8a3
+function info() {
36e8a3
+    echo -e "\033[33;1m$1\033[0m"
36e8a3
+}
36e8a3
+
36e8a3
+set -e
36e8a3
+
36e8a3
+source "$(dirname $0)/travis_wait.bash"
36e8a3
+
36e8a3
+for phase in "${PHASES[@]}"; do
36e8a3
+    case $phase in
36e8a3
+        SETUP)
36e8a3
+            info "Setup phase"
36e8a3
+            info "Using Travis $CENTOS_RELEASE"
36e8a3
+            # Pull a Docker image and start a new container
36e8a3
+            docker pull centos:$CENTOS_RELEASE
36e8a3
+            info "Starting container $CONT_NAME"
36e8a3
+            $DOCKER_RUN -v $REPO_ROOT:/build:rw \
36e8a3
+                        -w /build --privileged=true --name $CONT_NAME \
36e8a3
+                        -dit --net=host centos:$CENTOS_RELEASE /sbin/init
36e8a3
+            # Beautiful workaround for Fedora's version of Docker
36e8a3
+            sleep 1
36e8a3
+            $DOCKER_EXEC yum makecache
36e8a3
+            $DOCKER_EXEC curl "$COPR_REPO" -o "$COPR_REPO_PATH"
36e8a3
+            $DOCKER_EXEC yum -q -y install epel-release yum-utils
36e8a3
+            $DOCKER_EXEC yum-config-manager -q --enable epel
36e8a3
+            $DOCKER_EXEC yum -y --exclude selinux-policy\* upgrade
36e8a3
+            # Install necessary build/test requirements
36e8a3
+            $DOCKER_EXEC yum -y install "${ADDITIONAL_DEPS[@]}"
36e8a3
+            $DOCKER_EXEC python3.6 -m ensurepip
36e8a3
+            $DOCKER_EXEC python3.6 -m pip install meson
36e8a3
+            # Create necessary symlinks
36e8a3
+            $DOCKER_EXEC ln --force -s /usr/bin/python3.6 /usr/bin/python3
36e8a3
+            $DOCKER_EXEC ln --force -s /usr/bin/ninja-build /usr/bin/ninja
36e8a3
+            ;;
36e8a3
+        RUN)
36e8a3
+            info "Run phase"
36e8a3
+            # Build systemd
36e8a3
+            CONFIGURE_OPTS=(
36e8a3
+                # RHEL8 options
36e8a3
+                -Dsysvinit-path=/etc/rc.d/init.d
36e8a3
+                -Drc-local=/etc/rc.d/rc.local
36e8a3
+                -Ddns-servers=''
36e8a3
+                -Ddev-kvm-mode=0666
36e8a3
+                -Dkmod=true
36e8a3
+                -Dxkbcommon=true
36e8a3
+                -Dblkid=true
36e8a3
+                -Dseccomp=true
36e8a3
+                -Dima=true
36e8a3
+                -Dselinux=true
36e8a3
+                -Dapparmor=false
36e8a3
+                -Dpolkit=true
36e8a3
+                -Dxz=true
36e8a3
+                -Dzlib=true
36e8a3
+                -Dbzip2=true
36e8a3
+                -Dlz4=true
36e8a3
+                -Dpam=true
36e8a3
+                -Dacl=true
36e8a3
+                -Dsmack=true
36e8a3
+                -Dgcrypt=true
36e8a3
+                -Daudit=true
36e8a3
+                -Delfutils=true
36e8a3
+                -Dlibcryptsetup=true
36e8a3
+                -Delfutils=true
36e8a3
+                -Dqrencode=false
36e8a3
+                -Dgnutls=true
36e8a3
+                -Dmicrohttpd=true
36e8a3
+                -Dlibidn2=true
36e8a3
+                -Dlibiptc=true
36e8a3
+                -Dlibcurl=true
36e8a3
+                -Defi=true
36e8a3
+                -Dtpm=true
36e8a3
+                -Dhwdb=true
36e8a3
+                -Dsysusers=true
36e8a3
+                -Ddefault-kill-user-processes=false
36e8a3
+                -Dtests=unsafe
36e8a3
+                -Dinstall-tests=true
36e8a3
+                -Dtty-gid=5
36e8a3
+                -Dusers-gid=100
36e8a3
+                -Dnobody-user=nobody
36e8a3
+                -Dnobody-group=nobody
36e8a3
+                -Dsplit-usr=false
36e8a3
+                -Dsplit-bin=true
36e8a3
+                -Db_lto=false
36e8a3
+                -Dnetworkd=false
36e8a3
+                -Dtimesyncd=false
36e8a3
+                -Ddefault-hierarchy=legacy
36e8a3
+                # Custom options
36e8a3
+                -Dslow-tests=true
36e8a3
+                -Dtests=unsafe
36e8a3
+                -Dinstall-tests=true
36e8a3
+            )
36e8a3
+            docker exec -it -e CFLAGS='-g -O0 -ftrapv' $CONT_NAME meson build "${CONFIGURE_OPTS[@]}"
36e8a3
+            $DOCKER_EXEC ninja -v -C build
36e8a3
+            # "Mask" the udev-test.pl, as it requires newer version of systemd-detect-virt
36e8a3
+            # and it's pointless to run it on a VM in a Docker container...
36e8a3
+            echo -ne "#!/usr/bin/perl\nexit(0);\n" > "test/udev-test.pl"
36e8a3
+            $DOCKER_EXEC ninja -C build test
36e8a3
+            ;;
36e8a3
+        CLEANUP)
36e8a3
+            info "Cleanup phase"
36e8a3
+            docker stop $CONT_NAME
36e8a3
+            docker rm -f $CONT_NAME
36e8a3
+            ;;
36e8a3
+        *)
36e8a3
+            echo >&2 "Unknown phase '$phase'"
36e8a3
+            exit 1
36e8a3
+    esac
36e8a3
+done