summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2016-11-29 13:13:15 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2016-11-29 13:13:15 +0000
commit2bea7c4ad13be7abd51f3d3f1d36c1021bb23673 (patch)
treeb9076b340fab98a1c6246078156a3f26069902d1
parentca2cdab866ad6ef94a477bde6497dbf8deb3aeef (diff)
parentab1973ed15948a76a3bd0bfa528647c22a1cadfb (diff)
downloaddbus-2bea7c4ad13be7abd51f3d3f1d36c1021bb23673.tar.gz
Merge branch '1.10-docker'
-rw-r--r--.travis.yml83
-rw-r--r--tools/ci-Dockerfile.in10
-rwxr-xr-xtools/ci-build.sh442
-rwxr-xr-xtools/ci-install.sh161
4 files changed, 459 insertions, 237 deletions
diff --git a/.travis.yml b/.travis.yml
index f5e691a2..4ffc48c4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,58 +1,45 @@
+# Copyright © 2015-2016 Collabora Ltd.
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
sudo: required
dist: trusty
language: c
-install:
- # travis-ci has a sources list for Chrome which doesn't support i386
- - ": | sudo tee /etc/apt/sources.list.d/google-chrome.list"
- - test "$dbus_ci_host" != mingw || sudo dpkg --add-architecture i386
- - sudo apt-get -qq -y update
- - >
- test "$dbus_ci_host" != mingw || sudo apt-get -qq -y install
- binutils-mingw-w64-i686 g++-mingw-w64-i686 wine:i386
- - sudo apt-get -qq -y build-dep dbus
- - >
- sudo apt-get -qq -y install
- automake
- autotools-dev
- debhelper
- dh-autoreconf
- doxygen
- dpkg-dev
- gnome-desktop-testing
- libapparmor-dev
- libaudit-dev
- libcap-ng-dev
- libexpat-dev
- libglib2.0-dev
- libselinux1-dev
- libx11-dev
- python
- python-dbus
- python-gi
- valgrind
- xauth
- xmlto
- xsltproc
- xvfb
- # Ubuntu 14.04's autoconf-archive is too old
- - >
- wget
- http://snapshot.debian.org/archive/debian/20160905T163745Z/pool/main/a/autoconf-archive/autoconf-archive_20160320-1_all.deb
- - 'sudo dpkg -i autoconf-archive_*_all.deb'
- - 'rm autoconf-archive_*_all.deb'
script:
+ - ./tools/ci-install.sh
# python-dbus and python-gi aren't available to Travis's version of
# Python in /opt, which it uses as a default
- - PYTHON=/usr/bin/python dbus_ci_parallel=2 dbus_ci_sudo=yes ./tools/ci-build.sh
+ - PYTHON=/usr/bin/python ci_parallel=2 ci_sudo=yes ./tools/ci-build.sh
env:
- - dbus_ci_variant=production
- - dbus_ci_variant=debug
- - dbus_ci_variant=reduced
- - dbus_ci_variant=legacy
- - dbus_ci_buildsys=cmake
- - dbus_ci_host=mingw
- - dbus_ci_host=mingw dbus_ci_variant=debug
- - dbus_ci_host=mingw dbus_ci_buildsys=cmake
+ - ci_variant=production
+ - ci_variant=debug
+ - ci_variant=reduced
+ - ci_variant=legacy
+ - ci_buildsys=cmake
+ - ci_host=mingw
+ - ci_host=mingw ci_variant=debug
+ - ci_host=mingw ci_buildsys=cmake
+ - ci_docker=ubuntu:xenial ci_distro=ubuntu ci_suite=xenial
+ - ci_docker=debian:jessie-slim ci_distro=debian ci_suite=jessie
+ - ci_docker=debian:stretch-slim ci_distro=debian ci_suite=stretch
# vim:set sw=2 sts=2 et:
diff --git a/tools/ci-Dockerfile.in b/tools/ci-Dockerfile.in
new file mode 100644
index 00000000..e198b0d9
--- /dev/null
+++ b/tools/ci-Dockerfile.in
@@ -0,0 +1,10 @@
+FROM @ci_docker@
+ENV container docker
+
+ADD tools/ci-install.sh /ci-install.sh
+RUN ci_suite="@ci_suite@" ci_distro="@ci_distro@" ci_in_docker=yes /ci-install.sh
+
+ADD . /home/user/ci
+RUN chown -R user:user /home/user/ci
+WORKDIR /home/user/ci
+USER user
diff --git a/tools/ci-build.sh b/tools/ci-build.sh
index 3d732919..79d54deb 100755
--- a/tools/ci-build.sh
+++ b/tools/ci-build.sh
@@ -1,204 +1,268 @@
-#!/bin/sh
+#!/bin/bash
-set -e
+# Copyright © 2015-2016 Collabora Ltd.
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+set -euo pipefail
set -x
-if [ -z "$dbus_ci_variant" ]; then
- dbus_ci_variant=production
-fi
+NULL=
-if [ -z "$dbus_ci_host" ]; then
- dbus_ci_host=native
-fi
+# ci_buildsys:
+# Build system under test: autotools or cmake
+: "${ci_buildsys:=autotools}"
-if [ -z "$dbus_ci_buildsys" ]; then
- dbus_ci_buildsys=autotools
-fi
+# ci_docker:
+# If non-empty, this is the name of a Docker image. ci-install.sh will
+# fetch it with "docker pull" and use it as a base for a new Docker image
+# named "ci-image" in which we will do our testing.
+#
+# If empty, we test on "bare metal".
+# Typical values: ubuntu:xenial, debian:jessie-slim
+: "${ci_docker:=}"
+
+# ci_host:
+# See ci-install.sh
+: "${ci_host:=native}"
+
+# ci_parallel:
+# A number of parallel jobs, passed to make -j
+: "${ci_parallel:=1}"
+
+# ci_sudo:
+# If yes, assume we can get root using sudo; if no, only use current user
+: "${ci_sudo:=no}"
-if [ -z "$dbus_ci_parallel" ]; then
- dbus_ci_parallel=1
+# ci_test:
+# If yes, run tests; if no, just build
+: "${ci_test:=yes}"
+
+# ci_test_fatal:
+# If yes, test failures break the build; if no, they are reported but ignored
+: "${ci_test_fatal:=yes}"
+
+# ci_variant:
+# One of debug, reduced, legacy, production
+: "${ci_variant:=production}"
+
+if [ -n "$ci_docker" ]; then
+ exec docker run \
+ --env=ci_buildsys="${ci_buildsys}" \
+ --env=ci_docker="" \
+ --env=ci_host="${ci_host}" \
+ --env=ci_parallel="${ci_parallel}" \
+ --env=ci_sudo=yes \
+ --env=ci_test="${ci_test}" \
+ --env=ci_test_fatal="${ci_test_fatal}" \
+ --env=ci_variant="${ci_variant}" \
+ --privileged \
+ ci-image \
+ tools/ci-build.sh
fi
-dbus_test=yes
-dbus_test_fatal=yes
+maybe_fail_tests () {
+ if [ "$ci_test_fatal" = yes ]; then
+ exit 1
+ fi
+}
NOCONFIGURE=1 ./autogen.sh
srcdir="$(pwd)"
-mkdir ci-build-${dbus_ci_variant}-${dbus_ci_host}
-cd ci-build-${dbus_ci_variant}-${dbus_ci_host}
-
-make="make -j${dbus_ci_parallel} V=1 VERBOSE=1"
-
-case "$dbus_ci_host" in
- (mingw)
- mirror=http://sourceforge.net/projects/msys2/files/REPOS/MINGW/i686/
- mingw="$(pwd)/mingw32"
- install -d "${mingw}"
- export PKG_CONFIG_LIBDIR="${mingw}/lib/pkgconfig"
- export PKG_CONFIG_PATH=
- export PKG_CONFIG="pkg-config --define-variable=prefix=${mingw}"
- unset CC
- unset CXX
- for pkg in \
- expat-2.1.0-6 \
- gcc-libs-5.2.0-4 \
- gettext-0.19.6-1 \
- glib2-2.46.1-1 \
- libffi-3.2.1-3 \
- zlib-1.2.8-9 \
- ; do
- wget ${mirror}/mingw-w64-i686-${pkg}-any.pkg.tar.xz
- tar -xvf mingw-w64-i686-${pkg}-any.pkg.tar.xz
- done
- export TMPDIR=/tmp
- ;;
+mkdir ci-build-${ci_variant}-${ci_host}
+cd ci-build-${ci_variant}-${ci_host}
+
+make="make -j${ci_parallel} V=1 VERBOSE=1"
+
+case "$ci_host" in
+ (mingw)
+ mirror=http://sourceforge.net/projects/msys2/files/REPOS/MINGW/i686/
+ mingw="$(pwd)/mingw32"
+ install -d "${mingw}"
+ export PKG_CONFIG_LIBDIR="${mingw}/lib/pkgconfig"
+ export PKG_CONFIG_PATH=
+ export PKG_CONFIG="pkg-config --define-variable=prefix=${mingw}"
+ unset CC
+ unset CXX
+ for pkg in \
+ expat-2.1.0-6 \
+ gcc-libs-5.2.0-4 \
+ gettext-0.19.6-1 \
+ glib2-2.46.1-1 \
+ libffi-3.2.1-3 \
+ zlib-1.2.8-9 \
+ ; do
+ wget ${mirror}/mingw-w64-i686-${pkg}-any.pkg.tar.xz
+ tar -xvf mingw-w64-i686-${pkg}-any.pkg.tar.xz
+ done
+ export TMPDIR=/tmp
+ ;;
esac
-case "$dbus_ci_buildsys" in
- (autotools)
- case "$dbus_ci_variant" in
- (debug)
- # Full developer/debug build.
- set _ "$@"
- set "$@" --enable-developer --enable-tests
- shift
- # The test coverage for OOM-safety is too
- # verbose to be useful on travis-ci.
- export DBUS_TEST_MALLOC_FAILURES=0
- ;;
-
- (reduced)
- # A smaller configuration than normal, with
- # various features disabled; this emulates
- # an older system or one that does not have
- # all the optional libraries.
- set _ "$@"
- # No LSMs (the production build has both)
- set "$@" --disable-selinux --disable-apparmor
- # No inotify (we will use dnotify)
- set "$@" --disable-inotify
- # No epoll or kqueue (we will use poll)
- set "$@" --disable-epoll --disable-kqueue
- # No special init system support
- set "$@" --disable-launchd --disable-systemd
- # No libaudit or valgrind
- set "$@" --disable-libaudit --without-valgrind
- shift
- ;;
-
- (legacy)
- # An unrealistically cut-down configuration,
- # to check that it compiles and works.
- set _ "$@"
- # Disable native atomic operations on Unix
- # (armv4, as used as the baseline for Debian
- # armel, is one architecture that really
- # doesn't have them)
- set "$@" dbus_cv_sync_sub_and_fetch=no
- # No epoll, kqueue or poll (we will fall back
- # to select, even on Unix where we would
- # usually at least have poll)
- set "$@" --disable-epoll --disable-kqueue
- set "$@" CPPFLAGS=-DBROKEN_POLL=1
- # Enable SELinux and AppArmor but not
- # libaudit - that configuration has sometimes
- # failed
- set "$@" --enable-selinux --enable-apparmor
- set "$@" --disable-libaudit --without-valgrind
- # No directory monitoring at all
- set "$@" --disable-inotify --disable-dnotify
- # No special init system support
- set "$@" --disable-launchd --disable-systemd
- # No X11 autolaunching
- set "$@" --disable-x11-autolaunch
- shift
- ;;
-
- (*)
- ;;
- esac
-
- case "$dbus_ci_host" in
- (mingw)
- set _ "$@"
- set "$@" --build="$(build-aux/config.guess)"
- set "$@" --host=i686-w64-mingw32
- set "$@" LDFLAGS=-L"${mingw}/lib"
- set "$@" CPPFLAGS=-I"${mingw}/include"
- set "$@" CFLAGS=-static-libgcc
- set "$@" CXXFLAGS=-static-libgcc
- # don't run tests yet, Wine needs Xvfb and
- # more msys2 libraries
- dbus_test=
- # don't "make install" system-wide
- dbus_ci_sudo=
- shift
- ;;
- esac
-
- ../configure \
- --enable-installed-tests \
- --enable-maintainer-mode \
- --enable-modular-tests \
- --with-glib \
- "$@"
-
- ${make}
- [ -z "$dbus_test" ] || ${make} check || [ -z "$dbus_test_fatal" ]
- cat test/test-suite.log || :
- [ -z "$dbus_test" ] || ${make} distcheck || \
- [ -z "$dbus_test_fatal" ]
-
- ${make} install DESTDIR=$(pwd)/DESTDIR
- ( cd DESTDIR && find . )
-
- if [ -n "$dbus_ci_sudo" ] && [ -n "$dbus_test" ]; then
- sudo ${make} install
- LD_LIBRARY_PATH=/usr/local/lib ${make} installcheck || \
- [ -z "$dbus_test_fatal" ]
- cat test/test-suite.log || :
-
- # re-run them with gnome-desktop-testing
- env LD_LIBRARY_PATH=/usr/local/lib \
- gnome-desktop-testing-runner -d /usr/local/share dbus/ || \
- [ -z "$dbus_test_fatal" ]
-
- # these tests benefit from being re-run as root
- sudo env LD_LIBRARY_PATH=/usr/local/lib \
- gnome-desktop-testing-runner -d /usr/local/share \
- dbus/test-uid-permissions_with_config.test || \
- [ -z "$dbus_test_fatal" ]
- fi
- ;;
-
- (cmake)
- case "$dbus_ci_host" in
- (mingw)
- set _ "$@"
- set "$@" -D CMAKE_TOOLCHAIN_FILE="${srcdir}/cmake/i686-w64-mingw32.cmake"
- set "$@" -D CMAKE_PREFIX_PATH="${mingw}"
- set "$@" -D CMAKE_INCLUDE_PATH="${mingw}/include"
- set "$@" -D CMAKE_LIBRARY_PATH="${mingw}/lib"
- set "$@" -D EXPAT_LIBRARY="${mingw}/lib/libexpat.dll.a"
- set "$@" -D GLIB2_LIBRARIES="${mingw}/lib/libglib-2.0.dll.a"
- set "$@" -D GOBJECT_LIBRARIES="${mingw}/lib/libgobject-2.0.dll.a"
- set "$@" -D GIO_LIBRARIES="${mingw}/lib/libgio-2.0.dll.a"
- shift
- # don't run tests yet, Wine needs Xvfb and more
- # msys2 libraries
- dbus_test=
- ;;
- esac
-
- cmake "$@" ../cmake
-
- ${make}
- # The test coverage for OOM-safety is too verbose to be useful on
- # travis-ci.
- export DBUS_TEST_MALLOC_FAILURES=0
- [ -z "$dbus_test" ] || ctest -VV || [ -z "$dbus_test_fatal" ]
- ${make} install DESTDIR=$(pwd)/DESTDIR
- ( cd DESTDIR && find . )
- ;;
+case "$ci_buildsys" in
+ (autotools)
+ case "$ci_variant" in
+ (debug)
+ # Full developer/debug build.
+ set _ "$@"
+ set "$@" --enable-developer --enable-tests
+ shift
+ # The test coverage for OOM-safety is too
+ # verbose to be useful on travis-ci.
+ export DBUS_TEST_MALLOC_FAILURES=0
+ ;;
+
+ (reduced)
+ # A smaller configuration than normal, with
+ # various features disabled; this emulates
+ # an older system or one that does not have
+ # all the optional libraries.
+ set _ "$@"
+ # No LSMs (the production build has both)
+ set "$@" --disable-selinux --disable-apparmor
+ # No inotify (we will use dnotify)
+ set "$@" --disable-inotify
+ # No epoll or kqueue (we will use poll)
+ set "$@" --disable-epoll --disable-kqueue
+ # No special init system support
+ set "$@" --disable-launchd --disable-systemd
+ # No libaudit or valgrind
+ set "$@" --disable-libaudit --without-valgrind
+ shift
+ ;;
+
+ (legacy)
+ # An unrealistically cut-down configuration,
+ # to check that it compiles and works.
+ set _ "$@"
+ # Disable native atomic operations on Unix
+ # (armv4, as used as the baseline for Debian
+ # armel, is one architecture that really
+ # doesn't have them)
+ set "$@" dbus_cv_sync_sub_and_fetch=no
+ # No epoll, kqueue or poll (we will fall back
+ # to select, even on Unix where we would
+ # usually at least have poll)
+ set "$@" --disable-epoll --disable-kqueue
+ set "$@" CPPFLAGS=-DBROKEN_POLL=1
+ # Enable SELinux and AppArmor but not
+ # libaudit - that configuration has sometimes
+ # failed
+ set "$@" --enable-selinux --enable-apparmor
+ set "$@" --disable-libaudit --without-valgrind
+ # No directory monitoring at all
+ set "$@" --disable-inotify --disable-dnotify
+ # No special init system support
+ set "$@" --disable-launchd --disable-systemd
+ # No X11 autolaunching
+ set "$@" --disable-x11-autolaunch
+ shift
+ ;;
+
+ (*)
+ ;;
+ esac
+
+ case "$ci_host" in
+ (mingw)
+ set _ "$@"
+ set "$@" --build="$(build-aux/config.guess)"
+ set "$@" --host=i686-w64-mingw32
+ set "$@" LDFLAGS=-L"${mingw}/lib"
+ set "$@" CPPFLAGS=-I"${mingw}/include"
+ set "$@" CFLAGS=-static-libgcc
+ set "$@" CXXFLAGS=-static-libgcc
+ # don't run tests yet, Wine needs Xvfb and
+ # more msys2 libraries
+ ci_test=no
+ # don't "make install" system-wide
+ ci_sudo=no
+ shift
+ ;;
+ esac
+
+ ../configure \
+ --enable-installed-tests \
+ --enable-maintainer-mode \
+ --enable-modular-tests \
+ --with-glib \
+ "$@"
+
+ ${make}
+ [ "$ci_test" = no ] || ${make} check || maybe_fail_tests
+ cat test/test-suite.log || :
+ [ "$ci_test" = no ] || ${make} distcheck || maybe_fail_tests
+
+ ${make} install DESTDIR=$(pwd)/DESTDIR
+ ( cd DESTDIR && find . )
+
+ if [ "$ci_sudo" = yes ] && [ "$ci_test" = yes ]; then
+ sudo ${make} install
+ LD_LIBRARY_PATH=/usr/local/lib ${make} installcheck || \
+ maybe_fail_tests
+ cat test/test-suite.log || :
+
+ # re-run them with gnome-desktop-testing
+ env LD_LIBRARY_PATH=/usr/local/lib \
+ gnome-desktop-testing-runner -d /usr/local/share dbus/ || \
+ maybe_fail_tests
+
+ # these tests benefit from being re-run as root
+ sudo env LD_LIBRARY_PATH=/usr/local/lib \
+ gnome-desktop-testing-runner -d /usr/local/share \
+ dbus/test-uid-permissions_with_config.test || \
+ maybe_fail_tests
+ fi
+ ;;
+
+ (cmake)
+ case "$ci_host" in
+ (mingw)
+ set _ "$@"
+ set "$@" -D CMAKE_TOOLCHAIN_FILE="${srcdir}/cmake/i686-w64-mingw32.cmake"
+ set "$@" -D CMAKE_PREFIX_PATH="${mingw}"
+ set "$@" -D CMAKE_INCLUDE_PATH="${mingw}/include"
+ set "$@" -D CMAKE_LIBRARY_PATH="${mingw}/lib"
+ set "$@" -D EXPAT_LIBRARY="${mingw}/lib/libexpat.dll.a"
+ set "$@" -D GLIB2_LIBRARIES="${mingw}/lib/libglib-2.0.dll.a"
+ set "$@" -D GOBJECT_LIBRARIES="${mingw}/lib/libgobject-2.0.dll.a"
+ set "$@" -D GIO_LIBRARIES="${mingw}/lib/libgio-2.0.dll.a"
+ shift
+ # don't run tests yet, Wine needs Xvfb and more
+ # msys2 libraries
+ ci_test=no
+ ;;
+ esac
+
+ cmake "$@" ../cmake
+
+ ${make}
+ # The test coverage for OOM-safety is too verbose to be useful on
+ # travis-ci.
+ export DBUS_TEST_MALLOC_FAILURES=0
+ [ "$ci_test" = no ] || ctest -VV || maybe_fail_tests
+ ${make} install DESTDIR=$(pwd)/DESTDIR
+ ( cd DESTDIR && find . )
+ ;;
esac
+
+# vim:set sw=4 sts=4 et:
diff --git a/tools/ci-install.sh b/tools/ci-install.sh
new file mode 100755
index 00000000..b01c28ab
--- /dev/null
+++ b/tools/ci-install.sh
@@ -0,0 +1,161 @@
+#!/bin/bash
+
+# Copyright © 2015-2016 Collabora Ltd.
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+set -euo pipefail
+set -x
+
+NULL=
+
+# ci_distro:
+# OS distribution in which we are testing
+# Typical values: ubuntu, debian; maybe fedora in future
+: "${ci_distro:=ubuntu}"
+
+# ci_docker:
+# If non-empty, this is the name of a Docker image. ci-install.sh will
+# fetch it with "docker pull" and use it as a base for a new Docker image
+# named "ci-image" in which we will do our testing.
+: "${ci_docker:=}"
+
+# ci_host:
+# Either "native", or an Autoconf --host argument to cross-compile
+# the package
+: "${ci_host:=native}"
+
+# ci_in_docker:
+# Used internally by ci-install.sh. If yes, we are inside the Docker image
+# (ci_docker is empty in this case).
+: "${ci_in_docker:=no}"
+
+# ci_suite:
+# OS suite (release, branch) in which we are testing.
+# Typical values for ci_distro=debian: sid, jessie
+# Typical values for ci_distro=fedora might be 25, rawhide
+: "${ci_suite:=trusty}"
+
+if [ $(id -u) = 0 ]; then
+ sudo=
+else
+ sudo=sudo
+fi
+
+if [ -n "$ci_docker" ]; then
+ sed \
+ -e "s/@ci_distro@/${ci_distro}/" \
+ -e "s/@ci_docker@/${ci_docker}/" \
+ -e "s/@ci_suite@/${ci_suite}/" \
+ < tools/ci-Dockerfile.in > Dockerfile
+ exec docker build -t ci-image .
+fi
+
+case "$ci_distro" in
+ (debian|ubuntu)
+ # Don't ask questions, just do it
+ sudo="$sudo env DEBIAN_FRONTEND=noninteractive"
+
+ # Debian Docker images use httpredir.debian.org but it seems to be
+ # unreliable; use a CDN instead
+ $sudo sed -i -e 's/httpredir\.debian\.org/deb.debian.org/g' \
+ /etc/apt/sources.list
+
+ # travis-ci has a sources list for Chrome which doesn't support i386
+ : | $sudo tee /etc/apt/sources.list.d/google-chrome.list
+
+ if [ "$ci_host" = mingw ]; then
+ $sudo dpkg --add-architecture i386
+ fi
+
+ $sudo apt-get -qq -y update
+
+ if [ "$ci_host" = mingw ]; then
+ $sudo apt-get -qq -y install \
+ binutils-mingw-w64-i686 \
+ g++-mingw-w64-i686 \
+ wine:i386 \
+ ${NULL}
+ fi
+
+ $sudo apt-get -qq -y install \
+ autoconf-archive \
+ automake \
+ autotools-dev \
+ debhelper \
+ dh-autoreconf \
+ dh-exec \
+ doxygen \
+ dpkg-dev \
+ gnome-desktop-testing \
+ libapparmor-dev \
+ libaudit-dev \
+ libcap-ng-dev \
+ libexpat-dev \
+ libglib2.0-dev \
+ libselinux1-dev \
+ libx11-dev \
+ python \
+ python-dbus \
+ python-gi \
+ valgrind \
+ wget \
+ xauth \
+ xmlto \
+ xsltproc \
+ xvfb \
+ ${NULL}
+
+ case "$ci_suite" in
+ (trusty)
+ $sudo apt-get -qq -y install libsystemd-daemon-dev
+ ;;
+ (*)
+ $sudo apt-get -qq -y install libsystemd-dev
+ ;;
+ esac
+
+ if [ "$ci_in_docker" = yes ]; then
+ # Add the user that we will use to do the build inside the
+ # Docker container, and let them use sudo
+ adduser --disabled-password user </dev/null
+ apt-get -y install sudo
+ echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nopasswd
+ chmod 0440 /etc/sudoers.d/nopasswd
+ fi
+
+ case "$ci_suite" in
+ (trusty|jessie)
+ # Ubuntu 14.04's autoconf-archive is too old
+ wget http://snapshot.debian.org/archive/debian/20160905T163745Z/pool/main/a/autoconf-archive/autoconf-archive_20160320-1_all.deb
+ $sudo dpkg -i autoconf-archive_*_all.deb
+ rm autoconf-archive_*_all.deb
+ ;;
+ esac
+ ;;
+
+ (*)
+ echo "Don't know how to set up ${ci_distro}" >&2
+ exit 1
+ ;;
+esac
+
+# vim:set sw=4 sts=4 et: