1#!/bin/sh 2 3 . .github/configs $@ 4 5case "`./config.guess`" in 6*-darwin*) 7 brew install automake 8 exit 0 9 ;; 10esac 11 12TARGETS=$@ 13 14PACKAGES="" 15INSTALL_FIDO_PPA="no" 16export DEBIAN_FRONTEND=noninteractive 17 18#echo "Setting up for '$TARGETS'" 19 20set -ex 21 22lsb_release -a 23 24if [ "${TARGETS}" = "kitchensink" ]; then 25 TARGETS="krb5 libedit pam sk selinux" 26fi 27 28for flag in $CONFIGFLAGS; do 29 case "$flag" in 30 --with-pam) PACKAGES="${PACKAGES} libpam0g-dev" ;; 31 --with-libedit) PACKAGES="${PACKAGES} libedit-dev" ;; 32 esac 33done 34 35for TARGET in $TARGETS; do 36 case $TARGET in 37 default|without-openssl|without-zlib|c89|libedit|*pam) 38 # nothing to do 39 ;; 40 clang-*|gcc-*) 41 compiler=$(echo $TARGET | sed 's/-Werror//') 42 PACKAGES="$PACKAGES $compiler" 43 ;; 44 krb5) 45 PACKAGES="$PACKAGES libkrb5-dev" 46 ;; 47 heimdal) 48 PACKAGES="$PACKAGES heimdal-dev" 49 ;; 50 sk) 51 INSTALL_FIDO_PPA="yes" 52 PACKAGES="$PACKAGES libfido2-dev libu2f-host-dev libcbor-dev" 53 ;; 54 selinux) 55 PACKAGES="$PACKAGES libselinux1-dev selinux-policy-dev" 56 ;; 57 hardenedmalloc) 58 INSTALL_HARDENED_MALLOC=yes 59 ;; 60 musl) 61 PACKAGES="$PACKAGES musl-tools" 62 ;; 63 tcmalloc) 64 PACKAGES="$PACKAGES libgoogle-perftools-dev" 65 ;; 66 openssl-noec) 67 INSTALL_OPENSSL=OpenSSL_1_1_1k 68 SSLCONFOPTS="no-ec" 69 ;; 70 openssl-*) 71 INSTALL_OPENSSL=$(echo ${TARGET} | cut -f2 -d-) 72 case ${INSTALL_OPENSSL} in 73 1.1.1_stable) INSTALL_OPENSSL="OpenSSL_1_1_1-stable" ;; 74 1.*) INSTALL_OPENSSL="OpenSSL_$(echo ${INSTALL_OPENSSL} | tr . _)" ;; 75 3.*) INSTALL_OPENSSL="openssl-${INSTALL_OPENSSL}" ;; 76 esac 77 PACKAGES="${PACKAGES} putty-tools" 78 ;; 79 libressl-*) 80 INSTALL_LIBRESSL=$(echo ${TARGET} | cut -f2 -d-) 81 case ${INSTALL_LIBRESSL} in 82 master) ;; 83 *) INSTALL_LIBRESSL="$(echo ${TARGET} | cut -f2 -d-)" ;; 84 esac 85 PACKAGES="${PACKAGES} putty-tools" 86 ;; 87 valgrind*) 88 PACKAGES="$PACKAGES valgrind" 89 ;; 90 *) echo "Invalid option '${TARGET}'" 91 exit 1 92 ;; 93 esac 94done 95 96if [ "yes" = "$INSTALL_FIDO_PPA" ]; then 97 sudo apt update -qq 98 sudo apt install -qy software-properties-common 99 sudo apt-add-repository -y ppa:yubico/stable 100fi 101 102if [ "x" != "x$PACKAGES" ]; then 103 sudo apt update -qq 104 sudo apt install -qy $PACKAGES 105fi 106 107if [ "${INSTALL_HARDENED_MALLOC}" = "yes" ]; then 108 (cd ${HOME} && 109 git clone https://github.com/GrapheneOS/hardened_malloc.git && 110 cd ${HOME}/hardened_malloc && 111 make -j2 && sudo cp out/libhardened_malloc.so /usr/lib/) 112fi 113 114if [ ! -z "${INSTALL_OPENSSL}" ]; then 115 (cd ${HOME} && 116 git clone https://github.com/openssl/openssl.git && 117 cd ${HOME}/openssl && 118 git checkout ${INSTALL_OPENSSL} && 119 ./config no-threads shared ${SSLCONFOPTS} \ 120 --prefix=/opt/openssl && 121 make && sudo make install_sw) 122fi 123 124if [ ! -z "${INSTALL_LIBRESSL}" ]; then 125 if [ "${INSTALL_LIBRESSL}" = "master" ]; then 126 (mkdir -p ${HOME}/libressl && cd ${HOME}/libressl && 127 git clone https://github.com/libressl-portable/portable.git && 128 cd ${HOME}/libressl/portable && 129 git checkout ${INSTALL_LIBRESSL} && 130 sh update.sh && sh autogen.sh && 131 ./configure --prefix=/opt/libressl && 132 make -j2 && sudo make install) 133 else 134 LIBRESSL_URLBASE=https://cdn.openbsd.org/pub/OpenBSD/LibreSSL 135 (cd ${HOME} && 136 wget ${LIBRESSL_URLBASE}/libressl-${INSTALL_LIBRESSL}.tar.gz && 137 tar xfz libressl-${INSTALL_LIBRESSL}.tar.gz && 138 cd libressl-${INSTALL_LIBRESSL} && 139 ./configure --prefix=/opt/libressl && make -j2 && sudo make install) 140 fi 141fi 142