1#! /bin/sh
2# Copyright 2014 The Kyua Authors.
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    local pkgsuffix=
34    local packages=
35    if [ "${ARCH?}" = i386 ]; then
36         pkgsuffix=:i386
37         packages="${packages} gcc-multilib"
38         packages="${packages} g++-multilib"
39         sudo dpkg --add-architecture i386
40    fi
41    packages="${packages} gdb"
42    packages="${packages} liblua5.2-0${pkgsuffix}"
43    packages="${packages} liblua5.2-dev${pkgsuffix}"
44    packages="${packages} libsqlite3-0${pkgsuffix}"
45    packages="${packages} libsqlite3-dev${pkgsuffix}"
46    packages="${packages} pkg-config${pkgsuffix}"
47    packages="${packages} sqlite3"
48    sudo apt-get update -qq
49    sudo apt-get install -y ${packages}
50}
51
52install_kyua() {
53    local name="20190321-usr-local-kyua-ubuntu-16-04-${ARCH?}-${CC?}.tar.gz"
54    wget -O "${name}" "http://dl.bintray.com/ngie-eign/kyua/${name}" || return 1
55    sudo tar -xzvp -C / -f "${name}"
56    rm -f "${name}"
57}
58
59do_apidocs() {
60    sudo apt-get install -y doxygen
61}
62
63do_distcheck() {
64    :
65}
66
67do_style() {
68    :
69}
70
71main() {
72    if [ -z "${DO}" ]; then
73        echo "DO must be defined" 1>&2
74        exit 1
75    fi
76    install_deps
77    install_kyua
78    for step in ${DO}; do
79        "do_${DO}" || exit 1
80    done
81}
82
83main "${@}"
84