1#!/bin/sh 2set -o xtrace # Write all commands first to stderr 3set -o errexit # Exit the script with error if any of the commands fail 4 5SSL=${SSL:-no} 6INSTALL_DIR=$(pwd)/install-dir 7 8install_openssl_fips() { 9 curl --retry 5 -o fips.tar.gz https://www.openssl.org/source/openssl-fips-2.0.14.tar.gz 10 tar zxvf fips.tar.gz 11 cd openssl-fips-2.0.14 12 ./config --prefix=$INSTALL_DIR -fPIC 13 cpus=$(grep -c '^processor' /proc/cpuinfo) 14 make -j${cpus} || true 15 make install || true 16 cd .. 17 SSL_EXTRA_FLAGS="--openssldir=$INSTALL_DIR --with-fipsdir=$INSTALL_DIR fips" 18 SSL=${SSL%-fips} 19} 20install_openssl () { 21 SSL_VERSION=${SSL##openssl-} 22 tmp=$(echo $SSL_VERSION | tr . _) 23 curl -L --retry 5 -o ssl.tar.gz https://github.com/openssl/openssl/archive/OpenSSL_${tmp}.tar.gz 24 tar zxvf ssl.tar.gz 25 cd openssl-OpenSSL_$tmp 26 ./config --prefix=$INSTALL_DIR $SSL_EXTRA_FLAGS shared -fPIC 27 cpus=$(grep -c '^processor' /proc/cpuinfo) 28 make -j32 || true 29 make -j${cpus} || true 30 make install || true 31 cd .. 32 33 export PKG_CONFIG_PATH=$INSTALL_DIR/lib/pkgconfig 34 export EXTRA_LIB_PATH="$INSTALL_DIR/lib" 35 SSL="openssl"; 36} 37 38install_libressl () { 39 curl --retry 5 -o ssl.tar.gz https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/$SSL.tar.gz 40 tar zxvf ssl.tar.gz 41 cd $SSL 42 ./configure --prefix=$INSTALL_DIR 43 cpus=$(grep -c '^processor' /proc/cpuinfo) 44 make -j${cpus} 45 make install 46 cd .. 47 48 export PKG_CONFIG_PATH=$INSTALL_DIR/lib/pkgconfig 49 export EXTRA_LIB_PATH="$INSTALL_DIR/lib" 50 SSL="libressl"; 51} 52# Get the kernel name, lowercased 53OS=$(uname -s | tr '[:upper:]' '[:lower:]') 54echo "OS: $OS" 55 56# Automatically retrieve the machine architecture, lowercase, unless provided 57# as an environment variable (e.g. to force 32bit) 58[ -z "$MARCH" ] && MARCH=$(uname -m | tr '[:upper:]' '[:lower:]') 59 60case "$SSL" in 61 openssl-*-fips) 62 install_openssl_fips; 63 install_openssl; 64 ;; 65 66 openssl-*) 67 install_openssl; 68 ;; 69 70 libressl-*) 71 install_libressl; 72 ;; 73esac 74 75 76