#!/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 \ meson \ pkgconfig \ gcc \ vala \ gobject-introspection-devel \ json-glib-devel \ libgee-devel \ gnutls-devel \ libnotify-devel \ at-spi2-core-devel \ gtk3-devel \ glib-networking \ tree \ uncrustify } deps_opensuse() { zypper install -y \ make \ meson \ pkgconfig \ gcc \ vala \ gobject-introspection-devel \ json-glib-devel \ libgee-devel \ gnutls-devel \ libnotify-devel \ at-spi2-core-devel \ gtk3-devel \ glib-networking \ tree \ uncrustify } deps_archlinux() { pacman -Syu --noconfirm \ base-devel \ meson \ pkg-config \ gcc \ vala \ glib2 \ gobject-introspection \ json-glib \ libgee \ libnotify \ at-spi2-core \ gtk3 \ gnutls \ glib-networking \ tree \ uncrustify } deps_ubuntu_xenial() { apt-get update && \ apt-get install -y \ meson/xenial-backports \ pkg-config \ valac \ libgirepository1.0-dev \ libjson-glib-dev \ libgee-0.8-dev \ libgnutls28-dev \ libnotify-dev \ libgtk-3-dev \ glib-networking \ tree \ uncrustify } install_deps() { case "$1" in fedora) deps_fedora ;; opensuse) deps_opensuse ;; archlinux) deps_archlinux ;; ubuntu-xenial) deps_ubuntu_xenial ;; *) echo "unsupported distro $1" exit 1 esac } build() { set -ex ./extra/fmt check || { echo "WARNING: code formatting check failed" [ -z "${SUPPRESS_FMT}" ] && false } mkdir -p build && \ cd build && \ meson .. && \ ninja && \ ninja test \ || false DESTDIR=$PWD/install-dir ninja install (cd install-dir; LC_ALL=C tree -pan . > ../current-tree) diff -up ../extra/install-tree current-tree } build_in_container() { install_deps $1 # distro specific quirks case "$1" in ubuntu-xenial|opensuse) echo "$1 is using an outdated version of uncrustify, suppress formatting errors" export SUPPRESS_FMT=1 ;; esac build } spin_container() { case "$1" in fedora) DOCKER_IMG=fedora ;; archlinux) DOCKER_IMG=base/archlinux ;; opensuse) DOCKER_IMG=opensuse:tumbleweed ;; ubuntu-xenial) DOCKER_IMG=ubuntu:xenial ;; *) 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 [ -z "$NO_BUILD" ]; then if [ "$IN_CONTAINER" = "1" ]; then build_in_container "$@" else spin_container "$@" fi fi