xref: /openssh-portable/.github/setup_ci.sh (revision a38016d3)
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-*)
51        INSTALL_OPENSSL=$(echo ${TARGET} | cut -f2 -d-)
52        case ${INSTALL_OPENSSL} in
53          1.*)	INSTALL_OPENSSL="OpenSSL_$(echo ${INSTALL_OPENSSL} | tr . _)" ;;
54          3.*)	INSTALL_OPENSSL="openssl-${INSTALL_OPENSSL}" ;;
55        esac
56        PACKAGES="${PACKAGES} putty-tools"
57       ;;
58    libressl-*)
59        INSTALL_LIBRESSL=$(echo ${TARGET} | cut -f2 -d-)
60        case ${INSTALL_LIBRESSL} in
61          master) ;;
62          *) INSTALL_LIBRESSL="v$(echo ${TARGET} | cut -f2 -d-)" ;;
63        esac
64        PACKAGES="${PACKAGES} putty-tools"
65       ;;
66    valgrind*)
67       PACKAGES="$PACKAGES valgrind"
68       ;;
69    *) echo "Invalid option '${TARGET}'"
70        exit 1
71        ;;
72    esac
73done
74
75if [ "yes" = "$INSTALL_FIDO_PPA" ]; then
76    sudo apt update -qq
77    sudo apt install software-properties-common
78    sudo apt-add-repository ppa:yubico/stable
79fi
80
81if [ "x" != "x$PACKAGES" ]; then
82    sudo apt update -qq
83    sudo apt install -qy $PACKAGES
84fi
85
86if [ "${INSTALL_HARDENED_MALLOC}" = "yes" ]; then
87    (cd ${HOME} &&
88     git clone https://github.com/GrapheneOS/hardened_malloc.git &&
89     cd ${HOME}/hardened_malloc &&
90     make -j2 && sudo cp libhardened_malloc.so /usr/lib/)
91fi
92
93if [ ! -z "${INSTALL_OPENSSL}" ]; then
94    (cd ${HOME} &&
95     git clone https://github.com/openssl/openssl.git &&
96     cd ${HOME}/openssl &&
97     ./config no-threads no-engine no-fips no-shared --prefix=/opt/openssl/head &&
98     make -j2 && sudo make install_sw)
99fi
100
101if [ ! -z "${INSTALL_LIBRESSL}" ]; then
102    (mkdir -p ${HOME}/libressl && cd ${HOME}/libressl &&
103     git clone https://github.com/libressl-portable/portable.git &&
104     cd ${HOME}/libressl/portable &&
105     git checkout ${INSTALL_LIBRESSL} &&
106     sh update.sh && sh autogen.sh &&
107     ./configure --prefix=/opt/libressl/head &&
108     make -j2 && sudo make install)
109fi
110