travis-ci: add an install script instead of open-coding it in .travis.yml
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 28 Nov 2016 13:11:48 +0000 (13:11 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 29 Nov 2016 12:37:27 +0000 (12:37 +0000)
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
[smcv: move comment to install script as suggested]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98889

.travis.yml
tools/ci-install.sh [new file with mode: 0755]

index 03b884f..ca059e3 100644 (file)
@@ -24,44 +24,7 @@ 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 "$ci_host" != mingw || sudo dpkg --add-architecture i386
-  - sudo apt-get -qq -y update
-  - >
-    test "$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'
+  - ./tools/ci-install.sh
 script:
   # python-dbus and python-gi aren't available to Travis's version of
   # Python in /opt, which it uses as a default
diff --git a/tools/ci-install.sh b/tools/ci-install.sh
new file mode 100755 (executable)
index 0000000..9731f58
--- /dev/null
@@ -0,0 +1,101 @@
+#!/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:=ubuntu}"
+: "${ci_host:=native}"
+: "${ci_suite:=trusty}"
+
+if [ $(id -u) = 0 ]; then
+    sudo=
+else
+    sudo=sudo
+fi
+
+case "$ci_distro" in
+    (debian|ubuntu)
+        # 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 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 \
+            ${NULL}
+
+        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: