1#! /bin/sh 2# Copyright 2014 Google Inc. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: 8# 9# * Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# * Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# * Neither the name of Google Inc. nor the names of its contributors 15# may be used to endorse or promote products derived from this software 16# without specific prior written permission. 17# 18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 30set -e -x 31 32install_deps() { 33 sudo apt-get update -qq 34 35 local pkgsuffix= 36 local packages= 37 if [ "${ARCH?}" = i386 ]; then 38 pkgsuffix=:i386 39 packages="${packages} gcc-multilib" 40 packages="${packages} g++-multilib" 41 fi 42 packages="${packages} doxygen" 43 packages="${packages} gdb" 44 packages="${packages} liblua5.2-0${pkgsuffix}" 45 packages="${packages} liblua5.2-dev${pkgsuffix}" 46 packages="${packages} libsqlite3-0${pkgsuffix}" 47 packages="${packages} libsqlite3-dev${pkgsuffix}" 48 packages="${packages} pkg-config${pkgsuffix}" 49 packages="${packages} sqlite3" 50 sudo apt-get install -y ${packages} 51} 52 53install_from_github() { 54 local project="${1}"; shift 55 local name="${1}"; shift 56 local release="${1}"; shift 57 58 local distname="${name}-${release}" 59 60 local baseurl="https://github.com/jmmv/${project}" 61 wget --no-check-certificate \ 62 "${baseurl}/releases/download/${distname}/${distname}.tar.gz" 63 tar -xzvf "${distname}.tar.gz" 64 65 local archflags= 66 [ "${ARCH?}" != i386 ] || archflags=-m32 67 68 cd "${distname}" 69 ./configure \ 70 --disable-developer \ 71 --without-atf \ 72 --without-doxygen \ 73 CFLAGS="${archflags}" \ 74 CPPFLAGS="-I/usr/local/include" \ 75 CXXFLAGS="${archflags}" \ 76 LDFLAGS="-L/usr/local/lib -Wl,-R/usr/local/lib" \ 77 PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" 78 make 79 sudo make install 80 cd - 81 82 rm -rf "${distname}" "${distname}.tar.gz" 83} 84 85install_from_bintray() { 86 case "${ARCH?}" in 87 amd64) 88 name="20160204-usr-local-kyua-ubuntu-12-04-amd64-${CC?}.tar.gz" 89 ;; 90 i386) 91 name="20160714-usr-local-kyua-ubuntu-12-04-i386-${CC?}.tar.gz" 92 ;; 93 *) 94 echo "ERROR: Unknown ARCH value ${ARCH}" 1>&2 95 exit 1 96 ;; 97 esac 98 wget "http://dl.bintray.com/jmmv/kyua/${name}" || return 1 99 sudo tar -xzvp -C / -f "${name}" 100 rm -f "${name}" 101} 102 103install_deps 104if ! install_from_bintray; then 105 install_from_github atf atf 0.20 106 install_from_github lutok lutok 0.4 107 install_from_github kyua kyua-testers 0.2 108 install_from_github kyua kyua-cli 0.8 109fi 110