anitazha / rpms / systemd

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