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