1#!/bin/bash -ex
2#
3# Copyright 2005-2019 The Mumble Developers. All rights reserved.
4# Use of this source code is governed by a BSD-style license
5# that can be found in the LICENSE file at the root of the
6# Mumble source tree or at <https://www.mumble.info/LICENSE>.
7
8MUMBLE_HOST_DEB=${MUMBLE_HOST/_/-}
9
10if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
11	# Bump the apt http timeout to 120 seconds.
12	# Without this, we'd regularly get timeout errors
13	# from our MXE mirror on dl.mumble.info.
14	#
15	# See mumble-voip/mumble#3312 for more information.
16	echo 'Acquire::http::Timeout "120";' | sudo tee /etc/apt/apt.conf.d/99zzztimeout
17
18	if [ "${MUMBLE_QT}" == "qt4" ] && [ "${MUMBLE_HOST}" == "x86_64-linux-gnu" ]; then
19		sudo apt-get -qq update
20		sudo apt-get build-dep -qq mumble
21		sudo apt-get install libjack-jackd2-dev
22	elif [ "${MUMBLE_QT}" == "qt5" ] && [ "${MUMBLE_HOST}" == "x86_64-linux-gnu" ]; then
23		sudo apt-get -qq update
24		sudo apt-get build-dep -qq mumble
25		sudo apt-get install libqt5sql5 libqt5sql5-sqlite qt5-default qttools5-dev qttools5-dev-tools qtbase5-dev qtbase5-dev-tools qttranslations5-l10n libqt5svg5-dev
26		sudo apt-get install libjack-jackd2-dev
27	elif [ "${MUMBLE_QT}" == "qt5" ] && [ "${MUMBLE_HOST}" == "i686-w64-mingw32" ]; then
28		sudo dpkg --add-architecture i386
29		sudo apt-get -qq update
30		echo "deb https://dl.mumble.info/mirror/pkg.mxe.cc/repos/apt xenial main" | sudo tee /etc/apt/sources.list.d/mxe.list
31		sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 86B72ED9
32		sudo apt-get -qq update
33		sudo apt-get install \
34			wine \
35			mxe-${MUMBLE_HOST_DEB}.static-qtbase \
36			mxe-${MUMBLE_HOST_DEB}.static-qtsvg \
37			mxe-${MUMBLE_HOST_DEB}.static-qttools \
38			mxe-${MUMBLE_HOST_DEB}.static-qttranslations \
39			mxe-${MUMBLE_HOST_DEB}.static-boost \
40			mxe-${MUMBLE_HOST_DEB}.static-protobuf \
41			mxe-${MUMBLE_HOST_DEB}.static-sqlite \
42			mxe-${MUMBLE_HOST_DEB}.static-flac \
43			mxe-${MUMBLE_HOST_DEB}.static-ogg \
44			mxe-${MUMBLE_HOST_DEB}.static-vorbis \
45			mxe-${MUMBLE_HOST_DEB}.static-libsndfile
46	elif [ "${MUMBLE_QT}" == "qt5" ] && [ "${MUMBLE_HOST}" == "x86_64-w64-mingw32" ]; then
47		sudo dpkg --add-architecture i386
48		sudo apt-get -qq update
49		echo "deb https://dl.mumble.info/mirror/pkg.mxe.cc/repos/apt xenial main" | sudo tee /etc/apt/sources.list.d/mxe.list
50		sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 86B72ED9
51		sudo apt-get -qq update
52		sudo apt-get install \
53			wine \
54			mxe-${MUMBLE_HOST_DEB}.static-qtbase \
55			mxe-${MUMBLE_HOST_DEB}.static-qtsvg \
56			mxe-${MUMBLE_HOST_DEB}.static-qttools \
57			mxe-${MUMBLE_HOST_DEB}.static-qttranslations \
58			mxe-${MUMBLE_HOST_DEB}.static-boost \
59			mxe-${MUMBLE_HOST_DEB}.static-protobuf \
60			mxe-${MUMBLE_HOST_DEB}.static-sqlite \
61			mxe-${MUMBLE_HOST_DEB}.static-flac \
62			mxe-${MUMBLE_HOST_DEB}.static-ogg \
63			mxe-${MUMBLE_HOST_DEB}.static-vorbis \
64			mxe-${MUMBLE_HOST_DEB}.static-libsndfile
65	else
66		exit 1
67	fi
68elif [ "${TRAVIS_OS_NAME}" == "osx" ]; then
69	# We install the protobuf package via brew,
70	# which depends on "python@2".
71	#
72	# The build image upgraded the installed "python",
73	# and now "python@2" conflicts with it when trying
74	# to create symlinks.
75	#
76	# We don’t use the symlinked "python" installed
77	# by default in the image, so we unlink it to allow
78	# the "python@2" package to be installed without conflict.
79	brew update && brew unlink python
80
81	# As brew will set a non-zero exit status if one of the packages it is asked to install
82	# is installed already. Thus we have to iterate through every single one and check if it
83	# is installed first.
84	for pkg in qt5 libogg libvorbis flac libsndfile protobuf openssl ice; do
85		if brew ls --versions "$pkg" > /dev/null; then
86			echo "Skipping installation of $pkg as it is already installed"
87		else
88			brew install "$pkg"
89		fi
90	done
91else
92	exit 1
93fi
94