Path: blob/main/contrib/kyua/admin/build-bintray-dist.sh
39478 views
#! /bin/sh1# Copyright 2017 The Kyua Authors.2# All rights reserved.3#4# Redistribution and use in source and binary forms, with or without5# modification, are permitted provided that the following conditions are6# met:7#8# * Redistributions of source code must retain the above copyright9# notice, this list of conditions and the following disclaimer.10# * Redistributions in binary form must reproduce the above copyright11# notice, this list of conditions and the following disclaimer in the12# documentation and/or other materials provided with the distribution.13# * Neither the name of Google Inc. nor the names of its contributors14# may be used to endorse or promote products derived from this software15# without specific prior written permission.16#17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2829# \file admin/build-bintray-dist.sh30# Builds a full Kyua installation under /usr/local for Ubuntu.31#32# This script is used to create the bintray distribution packages in lieu33# of real Debian packages for Kyua. The result of this script is a34# tarball that provides the contents of /usr/local for Kyua.3536set -e -x3738err() {39echo "${@}" 1>&240exit 141}4243install_deps() {44sudo apt-get update -qq4546local pkgsuffix=47local packages=48packages="${packages} autoconf"49packages="${packages} automake"50packages="${packages} clang"51packages="${packages} g++"52packages="${packages} gdb"53packages="${packages} git"54packages="${packages} libtool"55packages="${packages} make"56if [ "${ARCH?}" = i386 ]; then57pkgsuffix=:i38658packages="${packages} gcc-multilib"59packages="${packages} g++-multilib"60fi61packages="${packages} liblua5.2-0${pkgsuffix}"62packages="${packages} liblua5.2-dev${pkgsuffix}"63packages="${packages} libsqlite3-0${pkgsuffix}"64packages="${packages} libsqlite3-dev${pkgsuffix}"65packages="${packages} pkg-config${pkgsuffix}"66packages="${packages} sqlite3"67sudo apt-get install -y ${packages}68}6970install_from_github() {71local name="${1}"; shift72local release="${1}"; shift7374local distname="${name}-${release}"7576local baseurl="https://github.com/jmmv/${name}"77wget --no-check-certificate \78"${baseurl}/releases/download/${distname}/${distname}.tar.gz"79tar -xzvf "${distname}.tar.gz"8081local archflags=82[ "${ARCH?}" != i386 ] || archflags=-m328384cd "${distname}"85./configure \86--disable-developer \87--without-atf \88--without-doxygen \89CC="${CC?}" \90CFLAGS="${archflags}" \91CPPFLAGS="-I/usr/local/include" \92CXX="${CXX?}" \93CXXFLAGS="${archflags}" \94LDFLAGS="-L/usr/local/lib -Wl,-R/usr/local/lib" \95PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"96make97sudo make install98cd -99100rm -rf "${distname}" "${distname}.tar.gz"101}102103main() {104[ "${ARCH+set}" = set ] || err "ARCH must be set in the environment"105[ "${CC+set}" = set ] || err "CC must be set in the environment"106[ "${CXX+set}" = set ] || err "CXX must be set in the environment"107108[ ! -f /root/local.tgz ] || err "/root/local.tgz already exists"109tar -czf /root/local.tgz /usr/local110restore() {111rm -rf /usr/local112tar -xz -C / -f /root/local.tgz113rm /root/local.tgz114}115trap restore EXIT116rm -rf /usr/local117mkdir /usr/local118119install_deps120install_from_github atf 0.21121install_from_github lutok 0.4122install_from_github kyua 0.13123124local version="$(lsb_release -rs | cut -d . -f 1-2 | tr . -)"125local name="$(date +%Y%m%d)-usr-local-kyua"126name="${name}-ubuntu-${version}-${ARCH?}-${CC?}.tar.gz"127tar -czf "${name}" /usr/local128}129130main "${@}"131132133