diff --git a/.travis.yml b/.travis.yml index 8218395b..5c8ebbbd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,69 @@ -os: linux -dist: trusty -sudo: false -language: python -python: 3.6 -cache: - apt: true - ccache: true -addons: - apt: - packages: - - "python3-pip" - - "libcap-dev" - - "libidn2-0-dev" - - "nettle-dev" - - "xsltproc" - - "docbook-xsl-ns" +sudo: required +language: c +services: + - docker + matrix: - include: - - env: CC=gcc - - env: CC=clang -install: - - set -e - - export NINJA_LATEST="https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip" - - wget "$NINJA_LATEST" - - unzip -q ninja-linux.zip -d build - - export PATH="$PWD/build:$PATH" - - sudo ln -s $PWD/build /root - - pip3 install meson + include: + # cross compilation + # NOTE: cannot set cross compiler as compiler variable (meson tests also native build) + - os: linux + env: DISTRO=debian:unstable VARIANT=cross-compile.aarch64 + compiler: gcc + + - os: linux + env: DISTRO=debian:testing VARIANT=cross-compile.ppc64le + compiler: gcc + + # musl (native) + - os: linux + # Message: WARNING: xsltproc: cannot process http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl + # doc/meson.build:70:1: ERROR: Problem encountered: Docs cannot be built: xsltproc does not work correctly + env: DISTRO=alpine:latest EXTRA_BUILD_OPTS='-DBUILD_HTML_MANS=false -DBUILD_MANS=false' + compiler: gcc + + # glibc (gcc/clang) + - os: linux + env: DISTRO=opensuse/tumbleweed + compiler: gcc + + - os: linux + env: DISTRO=ubuntu:xenial + compiler: clang + + - os: linux + env: DISTRO=ubuntu:latest + compiler: gcc + + - os: linux + env: DISTRO=fedora:latest + compiler: clang + + - os: linux + env: DISTRO=centos:7 + compiler: gcc + + - os: linux + env: DISTRO=debian:testing + compiler: gcc + + - os: linux + env: DISTRO=debian:stable + compiler: gcc + + - os: linux + env: DISTRO=debian:oldstable + compiler: clang + +before_install: + - DIR="/usr/src/iputils" + - printf "FROM $DISTRO\nRUN mkdir -p $DIR\nWORKDIR $DIR\nCOPY . $DIR\n" > Dockerfile + - echo "cat Dockerfile"; cat Dockerfile + - docker build -t iputils . + script: - - set -e - - meson builddir -DBUILD_RARPD=true -DBUILD_TFTPD=true -DBUILD_TRACEROUTE6=true -DBUILD_HTML_MANS=true - - ninja -C builddir - - sudo sh -c 'PATH="/root/build:$PATH" make install' + - INSTALL="${DISTRO%%:*}" + - INSTALL="${INSTALL%%/*}" + - DISTRO_VERSION="${DISTRO#*:}" + - case $VARIANT in cross-compile*) BUILD="cross";; i386) BUILD="32";; *) BUILD="native";; esac + - docker run -it iputils /bin/sh -c "cd travis && DISTRO_VERSION=\"$DISTRO_VERSION\" ./$INSTALL.sh && if [ \"$VARIANT\" ]; then ./$INSTALL.$VARIANT.sh; fi && CC=$CC EXTRA_BUILD_OPTS=\"$EXTRA_BUILD_OPTS\" ../build.sh" diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..ce3696a2 --- /dev/null +++ b/build.sh @@ -0,0 +1,57 @@ +#!/bin/sh + +CC="${CC:-gcc}" +BUILD_DIR="${BUILD_DIR:-builddir}" +PREFIX="${PREFIX:-$HOME/iputils-install}" + +# ninja-build is not detected causes build failing => symlink to ninja +# needed for CentOS 7 but maybe for others +if ! which ninja > /dev/null >&2; then + if which ninja-build > /dev/null >&2; then + ln -sv $(which ninja-build) /usr/local/bin/ninja + else + echo "ninja binary not found (tried ninja and $NINJA on $PATH)" >&2 + exit 1 + fi +fi + +which meson > /dev/null 2>&1 || { echo "meson binary not found" >&2; exit 1; } + +BUILD_OPTS="-Dprefix=$PREFIX -DBUILD_RARPD=true -DBUILD_TFTPD=true -DBUILD_TRACEROUTE6=true $EXTRA_BUILD_OPTS" +[ -z "$EXTRA_BUILD_OPTS" ] && BUILD_OPTS="$BUILD_OPTS -DBUILD_HTML_MANS=true" +[ -f "meson.cross" ] && BUILD_OPTS="--cross-file $PWD/meson.cross $BUILD_OPTS" + +cd `dirname $0` + +echo "=== compiler version ===" +$CC --version + +echo "=== meson version ===" +meson --version + +echo "=== ninja version ===" +ninja --version + +echo "=== build ===" +echo "Build options: $BUILD_OPTS" +meson $BUILD_DIR $BUILD_OPTS && \ +make -j$(getconf _NPROCESSORS_ONLN) && make install +ret=$? + +cat << EOF +============ +END OF BUILD +============ + +EOF + +if [ $ret -ne 0 ]; then + log="$DIR/meson-logs/meson-log.txt" + if [ -f "$log" ]; then + echo "=== START $log ===" + cat $log + echo "=== END $log ===" + fi +fi + +exit $ret diff --git a/travis/alpine.sh b/travis/alpine.sh new file mode 100755 index 00000000..20aac35e --- /dev/null +++ b/travis/alpine.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# Copyright (c) 2019 Petr Vorel +set -e + +apk update + +# NOTE: libidn2-dev is not in 3.10, only in edge +apk add \ + clang \ + docbook-xml \ + docbook-xsl \ + gcc \ + gettext-dev \ + libcap-dev \ + libxslt \ + make \ + meson \ + musl-dev \ + nettle-dev \ + openssl-dev \ + pkgconfig diff --git a/travis/centos.sh b/travis/centos.sh new file mode 120000 index 00000000..1479a43e --- /dev/null +++ b/travis/centos.sh @@ -0,0 +1 @@ +fedora.sh \ No newline at end of file diff --git a/travis/debian.cross-compile.aarch64.sh b/travis/debian.cross-compile.aarch64.sh new file mode 100755 index 00000000..67002bc8 --- /dev/null +++ b/travis/debian.cross-compile.aarch64.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Copyright (c) 2019 Petr Vorel +set -e + +dpkg --add-architecture arm64 +apt update + +apt install -y --no-install-recommends \ + dpkg-dev \ + gcc-aarch64-linux-gnu \ + libc6-dev-arm64-cross \ + libcap-dev:arm64 \ + libidn2-0-dev:arm64 \ + libssl-dev:arm64 + +cat < meson.cross +[binaries] +c = 'aarch64-linux-gnu-gcc' +pkgconfig = 'aarch64-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'aarch64' +endian = 'little' +EOF diff --git a/travis/debian.cross-compile.ppc64le.sh b/travis/debian.cross-compile.ppc64le.sh new file mode 100755 index 00000000..27cfc259 --- /dev/null +++ b/travis/debian.cross-compile.ppc64le.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Copyright (c) 2019 Petr Vorel +set -e + +dpkg --add-architecture ppc64el +apt update + +apt install -y --no-install-recommends \ + dpkg-dev \ + gcc-powerpc64le-linux-gnu \ + libc6-dev-ppc64el-cross \ + libcap-dev:ppc64el \ + libidn2-0-dev:ppc64el \ + libssl-dev:ppc64el + +cat < meson.cross +[binaries] +c = 'powerpc64le-linux-gnu-gcc' +pkgconfig = 'powerpc64le-linux-gnu-pkg-config' + +[host_machine] +system = 'linux' +cpu_family = 'ppc64' +cpu = 'ppc64' +endian = 'little' +EOF diff --git a/travis/debian.sh b/travis/debian.sh new file mode 100755 index 00000000..3a9bbae9 --- /dev/null +++ b/travis/debian.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Copyright (c) 2019 Petr Vorel +set -e + +if [ "$DISTRO_VERSION" = "oldstable" ]; then + cat < +set -e + +yum -y install \ + clang \ + gcc \ + gettext \ + libcap-devel \ + libxslt \ + make \ + nettle-devel \ + openssl-devel \ + pkg-config \ + which + +yum -y install libidn2-devel docbook5-style-xsl || true + +# supported since Centos 7 (Centos 6 don't have python 3.5 meson dependency) +if [ "$(basename $0)" = "centos.sh" ]; then + yum -y install epel-release +fi + +yum -y install meson ninja-build diff --git a/travis/opensuse.sh b/travis/opensuse.sh new file mode 100755 index 00000000..f0d5c29f --- /dev/null +++ b/travis/opensuse.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# Copyright (c) 2018 Petr Vorel +set -e + +zypper --non-interactive install --no-recommends \ + clang \ + docbook_5 \ + docbook5-xsl-stylesheets \ + gcc \ + gettext-tools \ + libcap-devel \ + libcap-progs \ + libidn2-devel \ + libnettle-devel \ + libxslt-tools \ + make \ + meson \ + ninja \ + openssl-devel \ + pkg-config \ + which diff --git a/travis/ubuntu.sh b/travis/ubuntu.sh new file mode 120000 index 00000000..0edcb8b8 --- /dev/null +++ b/travis/ubuntu.sh @@ -0,0 +1 @@ +debian.sh \ No newline at end of file