xref: /openssh-portable/.github/setup_ci.sh (revision da9d59f5)
1#!/bin/sh
2
3case $(./config.guess) in
4*-darwin*)
5	brew install automake
6	exit 0
7	;;
8esac
9
10TARGETS=$@
11
12PACKAGES=""
13INSTALL_FIDO_PPA="no"
14
15#echo "Setting up for '$TARGETS'"
16
17set -ex
18
19lsb_release -a
20
21if [ "${TARGETS}" = "kitchensink" ]; then
22	TARGETS="kerberos5 libedit pam sk selinux"
23fi
24
25for TARGET in $TARGETS; do
26    case $TARGET in
27    default|without-openssl|without-zlib)
28        # nothing to do
29        ;;
30    kerberos5)
31        PACKAGES="$PACKAGES heimdal-dev"
32        #PACKAGES="$PACKAGES libkrb5-dev"
33        ;;
34    libedit)
35        PACKAGES="$PACKAGES libedit-dev"
36        ;;
37    *pam)
38        PACKAGES="$PACKAGES libpam0g-dev"
39        ;;
40    sk)
41        INSTALL_FIDO_PPA="yes"
42        PACKAGES="$PACKAGES libfido2-dev libu2f-host-dev libcbor-dev"
43        ;;
44    selinux)
45        PACKAGES="$PACKAGES libselinux1-dev selinux-policy-dev"
46        ;;
47    hardenedmalloc)
48        INSTALL_HARDENED_MALLOC=yes
49       ;;
50    openssl-noec)
51	INSTALL_OPENSSL=OpenSSL_1_1_1k
52	SSLCONFOPTS="no-ec"
53	;;
54    openssl-*)
55        INSTALL_OPENSSL=$(echo ${TARGET} | cut -f2 -d-)
56        case ${INSTALL_OPENSSL} in
57          1.*)	INSTALL_OPENSSL="OpenSSL_$(echo ${INSTALL_OPENSSL} | tr . _)" ;;
58          3.*)	INSTALL_OPENSSL="openssl-${INSTALL_OPENSSL}" ;;
59        esac
60        PACKAGES="${PACKAGES} putty-tools"
61       ;;
62    libressl-*)
63        INSTALL_LIBRESSL=$(echo ${TARGET} | cut -f2 -d-)
64        case ${INSTALL_LIBRESSL} in
65          master) ;;
66          *) INSTALL_LIBRESSL="v$(echo ${TARGET} | cut -f2 -d-)" ;;
67        esac
68        PACKAGES="${PACKAGES} putty-tools"
69       ;;
70    valgrind*)
71       PACKAGES="$PACKAGES valgrind"
72       ;;
73    *) echo "Invalid option '${TARGET}'"
74        exit 1
75        ;;
76    esac
77done
78
79if [ "yes" = "$INSTALL_FIDO_PPA" ]; then
80    sudo apt update -qq
81    sudo apt install software-properties-common
82    sudo apt-add-repository ppa:yubico/stable
83fi
84
85if [ "x" != "x$PACKAGES" ]; then
86    sudo apt update -qq
87    sudo apt install -qy $PACKAGES
88fi
89
90if [ "${INSTALL_HARDENED_MALLOC}" = "yes" ]; then
91    (cd ${HOME} &&
92     git clone https://github.com/GrapheneOS/hardened_malloc.git &&
93     cd ${HOME}/hardened_malloc &&
94     make -j2 && sudo cp libhardened_malloc.so /usr/lib/)
95fi
96
97if [ ! -z "${INSTALL_OPENSSL}" ]; then
98    (cd ${HOME} &&
99     git clone https://github.com/openssl/openssl.git &&
100     cd ${HOME}/openssl &&
101     ./config no-threads no-engine no-fips no-shared ${SSLCONFOPTS} \
102         --prefix=/opt/openssl/head &&
103     make -j2 && sudo make install_sw)
104fi
105
106if [ ! -z "${INSTALL_LIBRESSL}" ]; then
107    (mkdir -p ${HOME}/libressl && cd ${HOME}/libressl &&
108     git clone https://github.com/libressl-portable/portable.git &&
109     cd ${HOME}/libressl/portable &&
110     git checkout ${INSTALL_LIBRESSL} &&
111     sh update.sh && sh autogen.sh &&
112     ./configure --prefix=/opt/libressl/head &&
113     make -j2 && sudo make install)
114fi
115