1#!/bin/sh 2 3set -exu # Strict shell (w/o -o pipefail) 4 5TARANTOOL_VERSION=${TARANTOOL_VERSION:-1.10} 6 7if [ "$(id -u)" = "0" ]; then 8 SUDO="" 9else 10 SUDO="sudo" 11fi 12 13${SUDO} apt-get update > /dev/null 14 15if [ -z "$(which gpg)" ]; then 16 ${SUDO} apt-get -qy install gnupg2 > /dev/null 17fi 18 19if [ -z "$(which lsb_release)" ]; then 20 ${SUDO} apt-get -qy install lsb-release > /dev/null 21fi 22 23${SUDO} apt-get -qy install apt-transport-https > /dev/null 24${SUDO} apt-get -qy install python-yaml > /dev/null 25 26OS="$(lsb_release --id --short | tr '[:upper:]' '[:lower:]')" # debian or ubuntu 27DIST="$(lsb_release --codename --short)" # stretch, xenial, ... 28 29# Setup tarantool repository. 30curl https://download.tarantool.org/tarantool/${TARANTOOL_VERSION}/gpgkey | \ 31 ${SUDO} apt-key add - 32${SUDO} rm -f /etc/apt/sources.list.d/*tarantool*.list 33${SUDO} tee /etc/apt/sources.list.d/tarantool_${TARANTOOL_VERSION}.list <<- EOF 34deb https://download.tarantool.org/tarantool/${TARANTOOL_VERSION}/${OS}/ ${DIST} main 35EOF 36${SUDO} apt-get update > /dev/null 37 38# Install tarantool executable and headers. 39# 40# Explicit version is necessary to install a lower tarantool 41# version from our repository when a system have a higher version 42# in default repositories. Say, Debian Stretch have tarantool-1.7 43# that prevents tarantool-1.6 from being installed from our repo 44# if we would not hold the version. 45${SUDO} apt-get -qy install "tarantool=${TARANTOOL_VERSION}*" \ 46 "tarantool-dev=${TARANTOOL_VERSION}*" > /dev/null 47tarantool --version 48 49# Ensure we got the requested tarantool version. 50TARANTOOL_VERSION_PATTERN='^Tarantool \([0-9]\+\.[0-9]\+\)\..*$' 51ACTUAL_TARANTOOL_VERSION="$(tarantool --version | head -n 1 | \ 52 sed "s/${TARANTOOL_VERSION_PATTERN}/\\1/")" 53if [ "${ACTUAL_TARANTOOL_VERSION}" != "${TARANTOOL_VERSION}" ]; then 54 echo "Requested tarantool-${TARANTOOL_VERSION}, got" \ 55 "tarantool-${ACTUAL_TARANTOOL_VERSION}" 56 exit 1 57fi 58 59# Determine PHP interpreter version. 60PHP_VERSION_PATTERN='^PHP \([0-9]\+\.[0-9]\+\)\.[0-9]\+ .*$' 61PHP_VERSION="$(php --version | head -n 1 | sed "s/${PHP_VERSION_PATTERN}/\\1/")" 62 63# Choose maximal phpunit version supported by installed PHP 64# interpreter. 65# 66# https://phpunit.de/supported-versions.html 67case "${PHP_VERSION}" in 687.0) PHPUNIT_VERSION=6 ;; 697.1) PHPUNIT_VERSION=7 ;; 707.2) PHPUNIT_VERSION=8 ;; 717.3) PHPUNIT_VERSION=9 ;; 727.4) PHPUNIT_VERSION=9 ;; 73*) 74 echo "Unable to choose phpunit version for PHP ${PHP_VERSION}" 75 exit 1 76 ;; 77esac 78 79# Install phpunit. 80PHPUNIT_URL="https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar" 81PHPUNIT_DIR="/usr/local/phpunit-${PHPUNIT_VERSION}" 82PHPUNIT_FILE="${PHPUNIT_DIR}/phpunit" 83${SUDO} mkdir -p "${PHPUNIT_DIR}" 84${SUDO} curl -SsLf -o "${PHPUNIT_FILE}" "${PHPUNIT_URL}" 85${SUDO} chmod a+x "${PHPUNIT_FILE}" 86export PATH="${PHPUNIT_DIR}:${PATH}" 87phpunit --version 88 89phpize && ./configure 90make 91make install 92/usr/bin/python test-run.py 93