richardphibel / rpms / systemd

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