dryang / rpms / systemd

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