• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3set -e
4set -x
5
6shlib_sed() {
7    # modify the shlib version to a unique one to make sure the dynamic
8    # linker doesn't load the system one.
9    sed -i "s/^SHLIB_MAJOR=.*/SHLIB_MAJOR=100/" Makefile
10    sed -i "s/^SHLIB_MINOR=.*/SHLIB_MINOR=0.0/" Makefile
11    sed -i "s/^SHLIB_VERSION_NUMBER=.*/SHLIB_VERSION_NUMBER=100.0.0/" Makefile
12}
13
14# download, compile, and install if it's not already present via travis
15# cache
16if [ -n "${OPENSSL}" ]; then
17    OPENSSL_DIR="ossl-2/${OPENSSL}"
18    if [[ ! -f "$HOME/$OPENSSL_DIR/bin/openssl" ]]; then
19        curl -O "https://www.openssl.org/source/openssl-${OPENSSL}.tar.gz"
20        tar zxf "openssl-${OPENSSL}.tar.gz"
21        pushd "openssl-${OPENSSL}"
22        ./config shared no-ssl2 no-ssl3 -fPIC --prefix="$HOME/$OPENSSL_DIR"
23        shlib_sed
24        make depend
25        make -j"$(nproc)"
26        if [[ "${OPENSSL}" =~ 1.0.1 ]]; then
27            # OpenSSL 1.0.1 doesn't support installing without the docs.
28            make install
29        else
30            # avoid installing the docs
31            # https://github.com/openssl/openssl/issues/6685#issuecomment-403838728
32            make install_sw install_ssldirs
33        fi
34        popd
35    fi
36elif [ -n "${LIBRESSL}" ]; then
37    LIBRESSL_DIR="ossl-2/${LIBRESSL}"
38    if [[ ! -f "$HOME/$LIBRESSL_DIR/bin/openssl" ]]; then
39        curl -O "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL}.tar.gz"
40        tar zxf "libressl-${LIBRESSL}.tar.gz"
41        pushd "libressl-${LIBRESSL}"
42        ./config -Wl -Wl,-Bsymbolic-functions -fPIC shared --prefix="$HOME/$LIBRESSL_DIR"
43        shlib_sed
44        make -j"$(nproc)" install
45        popd
46    fi
47fi
48
49if [ -n "${DOCKER}" ]; then
50    if [ -n "${OPENSSL}" ] || [ -n "${LIBRESSL}" ]; then
51        echo "OPENSSL and LIBRESSL are not allowed when DOCKER is set."
52        exit 1
53    fi
54    docker pull "$DOCKER" || docker pull "$DOCKER" || docker pull "$DOCKER"
55fi
56
57if [ -z "${DOWNSTREAM}" ]; then
58    git clone --depth=1 https://github.com/google/wycheproof "$HOME/wycheproof"
59fi
60
61pip install virtualenv
62
63python -m virtualenv ~/.venv
64source ~/.venv/bin/activate
65# If we pin coverage it must be kept in sync with tox.ini and Jenkinsfile
66pip install tox codecov coverage
67