valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0676-travis-RHEL8-support.patch

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