diff --git a/.travis.yml b/.travis.yml index bf4ee49..9ec8548 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,10 @@ -# default 12.04 is ancient, use trusty instead -dist: trusty -# pretend we're building C -language: c -compiler: - - gcc +services: + - docker + env: - - VALAC=valac-0.32 -before_install: - - sudo add-apt-repository -y ppa:vala-team/ppa - - sudo apt-get update -qq - - sudo apt-get install -qq ${VALAC} valac - - sudo apt-get install -qq libgirepository1.0-dev - - sudo apt-get install -qq gir1.2-gee-0.8 libgee-0.8-dev - - sudo apt-get install -qq gir1.2-json-1.0 libjson-glib-dev - - sudo apt-get install -qq gir1.2-notify-0.7 libnotify-dev - - sudo apt-get install -qq gir1.2-atspi-2.0 libatspi2.0-dev - - sudo apt-get install -qq gir1.2-gtk-3.0 libgtk-3-dev -before_script: - - autoreconf -if + matrix: + - DISTRO=fedora + - DISTRO=archlinux + script: - - ./configure && make V=1 + - ./extra/travis-build "${DISTRO}" diff --git a/extra/travis-build b/extra/travis-build new file mode 100755 index 0000000..f95c075 --- /dev/null +++ b/extra/travis-build @@ -0,0 +1,118 @@ +#!/bin/bash -xe +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# AUTHORS +# Maciek Borzecki + +# Travis build script. The script reexecs itself inside the container (setting +# IN_CONTAINER=1). The proceeds to install build dependencies and runs through +# the whole build process. Source tree is bind-mounted at /mnt and the container +# has its workdir set to /mnt +# +# NOTE: it is assumed that the script is run while at the top of source tree +# (i.e. $PWD is your checked out tree, this crucial for properly mounting the +# source code into the container). + +deps_fedora() { + dnf install --best -y --refresh \ + automake \ + autoconf \ + libtool \ + pkgconfig \ + gcc \ + vala \ + gobject-introspection-devel \ + json-glib-devel \ + libgee-devel \ + openssl-devel \ + libnotify-devel \ + at-spi2-core-devel \ + gtk3-devel +} + +deps_archlinux() { + pacman -Syu --noconfirm \ + base-devel \ + autoconf \ + automake \ + libtool \ + pkg-config \ + gcc \ + vala \ + glib2 \ + gobject-introspection \ + json-glib \ + libgee \ + openssl \ + libnotify \ + at-spi2-core \ + gtk3 +} + +install_deps() { + case "$1" in + fedora) + deps_fedora + ;; + archlinux) + deps_archlinux + ;; + *) + echo "unsupported distro $1" + exit 1 + esac +} + +build() { + autoreconf -if + # TODO: out of source builds + ./configure + make + make install +} + +build_in_container() { + install_deps $1 + + build +} + +spin_container() { + case "$1" in + fedora) + DOCKER_IMG=fedora + ;; + archlinux) + DOCKER_IMG=base/archlinux + ;; + *) + echo "unsupported distro $1" + exit 1 + esac + + # run a container, mount sources at /mnt, st + docker run --rm \ + -v $PWD:/mnt \ + -w /mnt \ + -e IN_CONTAINER=1 \ + $DOCKER_IMG \ + /mnt/extra/travis-build "$@" +} + +if [ "$IN_CONTAINER" = "1" ]; then + build_in_container "$@" +else + spin_container "$@" +fi