1*b0d29bc4SBrooks Davis#! /bin/sh 2*b0d29bc4SBrooks Davis# Copyright 2017 The Kyua Authors. 3*b0d29bc4SBrooks Davis# All rights reserved. 4*b0d29bc4SBrooks Davis# 5*b0d29bc4SBrooks Davis# Redistribution and use in source and binary forms, with or without 6*b0d29bc4SBrooks Davis# modification, are permitted provided that the following conditions are 7*b0d29bc4SBrooks Davis# met: 8*b0d29bc4SBrooks Davis# 9*b0d29bc4SBrooks Davis# * Redistributions of source code must retain the above copyright 10*b0d29bc4SBrooks Davis# notice, this list of conditions and the following disclaimer. 11*b0d29bc4SBrooks Davis# * Redistributions in binary form must reproduce the above copyright 12*b0d29bc4SBrooks Davis# notice, this list of conditions and the following disclaimer in the 13*b0d29bc4SBrooks Davis# documentation and/or other materials provided with the distribution. 14*b0d29bc4SBrooks Davis# * Neither the name of Google Inc. nor the names of its contributors 15*b0d29bc4SBrooks Davis# may be used to endorse or promote products derived from this software 16*b0d29bc4SBrooks Davis# without specific prior written permission. 17*b0d29bc4SBrooks Davis# 18*b0d29bc4SBrooks Davis# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19*b0d29bc4SBrooks Davis# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20*b0d29bc4SBrooks Davis# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21*b0d29bc4SBrooks Davis# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22*b0d29bc4SBrooks Davis# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23*b0d29bc4SBrooks Davis# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24*b0d29bc4SBrooks Davis# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25*b0d29bc4SBrooks Davis# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26*b0d29bc4SBrooks Davis# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27*b0d29bc4SBrooks Davis# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28*b0d29bc4SBrooks Davis# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29*b0d29bc4SBrooks Davis 30*b0d29bc4SBrooks Davis# \file admin/build-bintray-dist.sh 31*b0d29bc4SBrooks Davis# Builds a full Kyua installation under /usr/local for Ubuntu. 32*b0d29bc4SBrooks Davis# 33*b0d29bc4SBrooks Davis# This script is used to create the bintray distribution packages in lieu 34*b0d29bc4SBrooks Davis# of real Debian packages for Kyua. The result of this script is a 35*b0d29bc4SBrooks Davis# tarball that provides the contents of /usr/local for Kyua. 36*b0d29bc4SBrooks Davis 37*b0d29bc4SBrooks Davisset -e -x 38*b0d29bc4SBrooks Davis 39*b0d29bc4SBrooks Daviserr() { 40*b0d29bc4SBrooks Davis echo "${@}" 1>&2 41*b0d29bc4SBrooks Davis exit 1 42*b0d29bc4SBrooks Davis} 43*b0d29bc4SBrooks Davis 44*b0d29bc4SBrooks Davisinstall_deps() { 45*b0d29bc4SBrooks Davis sudo apt-get update -qq 46*b0d29bc4SBrooks Davis 47*b0d29bc4SBrooks Davis local pkgsuffix= 48*b0d29bc4SBrooks Davis local packages= 49*b0d29bc4SBrooks Davis packages="${packages} autoconf" 50*b0d29bc4SBrooks Davis packages="${packages} automake" 51*b0d29bc4SBrooks Davis packages="${packages} clang" 52*b0d29bc4SBrooks Davis packages="${packages} g++" 53*b0d29bc4SBrooks Davis packages="${packages} gdb" 54*b0d29bc4SBrooks Davis packages="${packages} git" 55*b0d29bc4SBrooks Davis packages="${packages} libtool" 56*b0d29bc4SBrooks Davis packages="${packages} make" 57*b0d29bc4SBrooks Davis if [ "${ARCH?}" = i386 ]; then 58*b0d29bc4SBrooks Davis pkgsuffix=:i386 59*b0d29bc4SBrooks Davis packages="${packages} gcc-multilib" 60*b0d29bc4SBrooks Davis packages="${packages} g++-multilib" 61*b0d29bc4SBrooks Davis fi 62*b0d29bc4SBrooks Davis packages="${packages} liblua5.2-0${pkgsuffix}" 63*b0d29bc4SBrooks Davis packages="${packages} liblua5.2-dev${pkgsuffix}" 64*b0d29bc4SBrooks Davis packages="${packages} libsqlite3-0${pkgsuffix}" 65*b0d29bc4SBrooks Davis packages="${packages} libsqlite3-dev${pkgsuffix}" 66*b0d29bc4SBrooks Davis packages="${packages} pkg-config${pkgsuffix}" 67*b0d29bc4SBrooks Davis packages="${packages} sqlite3" 68*b0d29bc4SBrooks Davis sudo apt-get install -y ${packages} 69*b0d29bc4SBrooks Davis} 70*b0d29bc4SBrooks Davis 71*b0d29bc4SBrooks Davisinstall_from_github() { 72*b0d29bc4SBrooks Davis local name="${1}"; shift 73*b0d29bc4SBrooks Davis local release="${1}"; shift 74*b0d29bc4SBrooks Davis 75*b0d29bc4SBrooks Davis local distname="${name}-${release}" 76*b0d29bc4SBrooks Davis 77*b0d29bc4SBrooks Davis local baseurl="https://github.com/jmmv/${name}" 78*b0d29bc4SBrooks Davis wget --no-check-certificate \ 79*b0d29bc4SBrooks Davis "${baseurl}/releases/download/${distname}/${distname}.tar.gz" 80*b0d29bc4SBrooks Davis tar -xzvf "${distname}.tar.gz" 81*b0d29bc4SBrooks Davis 82*b0d29bc4SBrooks Davis local archflags= 83*b0d29bc4SBrooks Davis [ "${ARCH?}" != i386 ] || archflags=-m32 84*b0d29bc4SBrooks Davis 85*b0d29bc4SBrooks Davis cd "${distname}" 86*b0d29bc4SBrooks Davis ./configure \ 87*b0d29bc4SBrooks Davis --disable-developer \ 88*b0d29bc4SBrooks Davis --without-atf \ 89*b0d29bc4SBrooks Davis --without-doxygen \ 90*b0d29bc4SBrooks Davis CC="${CC?}" \ 91*b0d29bc4SBrooks Davis CFLAGS="${archflags}" \ 92*b0d29bc4SBrooks Davis CPPFLAGS="-I/usr/local/include" \ 93*b0d29bc4SBrooks Davis CXX="${CXX?}" \ 94*b0d29bc4SBrooks Davis CXXFLAGS="${archflags}" \ 95*b0d29bc4SBrooks Davis LDFLAGS="-L/usr/local/lib -Wl,-R/usr/local/lib" \ 96*b0d29bc4SBrooks Davis PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" 97*b0d29bc4SBrooks Davis make 98*b0d29bc4SBrooks Davis sudo make install 99*b0d29bc4SBrooks Davis cd - 100*b0d29bc4SBrooks Davis 101*b0d29bc4SBrooks Davis rm -rf "${distname}" "${distname}.tar.gz" 102*b0d29bc4SBrooks Davis} 103*b0d29bc4SBrooks Davis 104*b0d29bc4SBrooks Davismain() { 105*b0d29bc4SBrooks Davis [ "${ARCH+set}" = set ] || err "ARCH must be set in the environment" 106*b0d29bc4SBrooks Davis [ "${CC+set}" = set ] || err "CC must be set in the environment" 107*b0d29bc4SBrooks Davis [ "${CXX+set}" = set ] || err "CXX must be set in the environment" 108*b0d29bc4SBrooks Davis 109*b0d29bc4SBrooks Davis [ ! -f /root/local.tgz ] || err "/root/local.tgz already exists" 110*b0d29bc4SBrooks Davis tar -czf /root/local.tgz /usr/local 111*b0d29bc4SBrooks Davis restore() { 112*b0d29bc4SBrooks Davis rm -rf /usr/local 113*b0d29bc4SBrooks Davis tar -xz -C / -f /root/local.tgz 114*b0d29bc4SBrooks Davis rm /root/local.tgz 115*b0d29bc4SBrooks Davis } 116*b0d29bc4SBrooks Davis trap restore EXIT 117*b0d29bc4SBrooks Davis rm -rf /usr/local 118*b0d29bc4SBrooks Davis mkdir /usr/local 119*b0d29bc4SBrooks Davis 120*b0d29bc4SBrooks Davis install_deps 121*b0d29bc4SBrooks Davis install_from_github atf 0.21 122*b0d29bc4SBrooks Davis install_from_github lutok 0.4 123*b0d29bc4SBrooks Davis install_from_github kyua 0.13 124*b0d29bc4SBrooks Davis 125*b0d29bc4SBrooks Davis local version="$(lsb_release -rs | cut -d . -f 1-2 | tr . -)" 126*b0d29bc4SBrooks Davis local name="$(date +%Y%m%d)-usr-local-kyua" 127*b0d29bc4SBrooks Davis name="${name}-ubuntu-${version}-${ARCH?}-${CC?}.tar.gz" 128*b0d29bc4SBrooks Davis tar -czf "${name}" /usr/local 129*b0d29bc4SBrooks Davis} 130*b0d29bc4SBrooks Davis 131*b0d29bc4SBrooks Davismain "${@}" 132