freebsd-src/crypto/openssh/.github/setup_ci.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

244 lines
6.4 KiB
Bash
Raw Normal View History

2021-08-30 19:14:33 +00:00
#!/bin/sh
2021-02-14 21:09:58 +00:00
2022-10-04 15:10:40 +00:00
PACKAGES=""
2022-02-23 18:16:45 +00:00
. .github/configs $@
2023-08-10 16:16:53 +00:00
host=`./config.guess`
echo "config.guess: $host"
case "$host" in
2022-10-04 15:10:40 +00:00
*cygwin)
PACKAGER=setup
2023-03-16 12:41:22 +00:00
echo Setting CYGWIN system environment variable.
2022-10-04 15:10:40 +00:00
setx CYGWIN "binmode"
2023-03-16 12:41:22 +00:00
echo Removing extended ACLs so umask works as expected.
setfacl -b . regress
2022-10-04 15:10:40 +00:00
PACKAGES="$PACKAGES,autoconf,automake,cygwin-devel,gcc-core"
PACKAGES="$PACKAGES,make,openssl-devel,zlib-devel"
;;
2021-04-23 19:10:38 +00:00
*-darwin*)
2022-10-04 15:10:40 +00:00
PACKAGER=brew
2023-12-18 15:59:40 +00:00
PACKAGES="automake"
2021-04-23 19:10:38 +00:00
;;
2022-10-04 15:10:40 +00:00
*)
PACKAGER=apt
2021-04-23 19:10:38 +00:00
esac
2021-02-14 21:09:58 +00:00
TARGETS=$@
INSTALL_FIDO_PPA="no"
2021-11-04 17:16:52 +00:00
export DEBIAN_FRONTEND=noninteractive
2021-02-14 21:09:58 +00:00
2023-12-18 15:59:40 +00:00
set -e
2021-02-14 21:09:58 +00:00
2022-10-04 15:10:40 +00:00
if [ -x "`which lsb_release 2>&1`" ]; then
lsb_release -a
fi
2023-12-18 15:59:40 +00:00
if [ ! -z "$SUDO" ]; then
# Ubuntu 22.04 defaults to private home dirs which prevent the
# agent-getpeerid test from running ssh-add as nobody. See
# https://github.com/actions/runner-images/issues/6106
if ! "$SUDO" -u nobody test -x ~; then
echo ~ is not executable by nobody, adding perms.
chmod go+x ~
fi
# Some of the Mac OS X runners don't have a nopasswd sudo rule. Regular
# sudo still works, but sudo -u doesn't. Restore the sudo rule.
if ! "$SUDO" grep -E 'runner.*NOPASSWD' /etc/passwd >/dev/null; then
echo "Restoring runner nopasswd rule to sudoers."
echo 'runner ALL=(ALL) NOPASSWD: ALL' |$SUDO tee -a /etc/sudoers
fi
if ! "$SUDO" -u nobody -S test -x ~ </dev/null; then
echo "Still can't sudo to nobody."
exit 1
fi
2022-10-04 15:10:40 +00:00
fi
2021-02-14 21:09:58 +00:00
2021-04-23 19:10:38 +00:00
if [ "${TARGETS}" = "kitchensink" ]; then
2022-02-23 18:16:45 +00:00
TARGETS="krb5 libedit pam sk selinux"
2021-04-23 19:10:38 +00:00
fi
2022-02-23 18:16:45 +00:00
for flag in $CONFIGFLAGS; do
case "$flag" in
2022-10-04 15:10:40 +00:00
--with-pam) TARGETS="${TARGETS} pam" ;;
--with-libedit) TARGETS="${TARGETS} libedit" ;;
2022-02-23 18:16:45 +00:00
esac
done
2023-12-18 15:59:40 +00:00
echo "Setting up for '$TARGETS'"
2021-02-14 21:09:58 +00:00
for TARGET in $TARGETS; do
case $TARGET in
2022-10-04 15:10:40 +00:00
default|without-openssl|without-zlib|c89)
2021-02-14 21:09:58 +00:00
# nothing to do
;;
2022-10-04 15:10:40 +00:00
clang-sanitize*)
PACKAGES="$PACKAGES clang-12"
;;
cygwin-release)
PACKAGES="$PACKAGES libcrypt-devel libfido2-devel libkrb5-devel"
;;
gcc-sanitize*)
;;
2022-02-23 18:16:45 +00:00
clang-*|gcc-*)
compiler=$(echo $TARGET | sed 's/-Werror//')
PACKAGES="$PACKAGES $compiler"
2021-02-14 21:09:58 +00:00
;;
2022-02-23 18:16:45 +00:00
krb5)
PACKAGES="$PACKAGES libkrb5-dev"
;;
heimdal)
PACKAGES="$PACKAGES heimdal-dev"
2021-02-14 21:09:58 +00:00
;;
2022-10-04 15:10:40 +00:00
libedit)
case "$PACKAGER" in
setup) PACKAGES="$PACKAGES libedit-devel" ;;
apt) PACKAGES="$PACKAGES libedit-dev" ;;
esac
;;
*pam)
2023-12-18 15:59:40 +00:00
case "$PACKAGER" in
apt) PACKAGES="$PACKAGES libpam0g-dev" ;;
esac
2022-10-04 15:10:40 +00:00
;;
2021-04-23 19:10:38 +00:00
sk)
2021-02-14 21:09:58 +00:00
INSTALL_FIDO_PPA="yes"
2021-04-23 19:13:32 +00:00
PACKAGES="$PACKAGES libfido2-dev libu2f-host-dev libcbor-dev"
2021-02-14 21:09:58 +00:00
;;
2021-04-23 19:10:38 +00:00
selinux)
2021-02-14 21:09:58 +00:00
PACKAGES="$PACKAGES libselinux1-dev selinux-policy-dev"
;;
2021-04-23 19:10:38 +00:00
hardenedmalloc)
INSTALL_HARDENED_MALLOC=yes
2022-02-23 18:16:45 +00:00
;;
musl)
PACKAGES="$PACKAGES musl-tools"
;;
tcmalloc)
PACKAGES="$PACKAGES libgoogle-perftools-dev"
;;
2021-08-30 19:14:33 +00:00
openssl-noec)
INSTALL_OPENSSL=OpenSSL_1_1_1k
SSLCONFOPTS="no-ec"
;;
openssl-*)
INSTALL_OPENSSL=$(echo ${TARGET} | cut -f2 -d-)
case ${INSTALL_OPENSSL} in
2021-11-04 17:16:52 +00:00
1.1.1_stable) INSTALL_OPENSSL="OpenSSL_1_1_1-stable" ;;
2021-08-30 19:14:33 +00:00
1.*) INSTALL_OPENSSL="OpenSSL_$(echo ${INSTALL_OPENSSL} | tr . _)" ;;
3.*) INSTALL_OPENSSL="openssl-${INSTALL_OPENSSL}" ;;
esac
2023-12-18 15:59:40 +00:00
PACKAGES="${PACKAGES} putty-tools dropbear-bin"
2021-04-23 19:10:38 +00:00
;;
2021-08-30 19:14:33 +00:00
libressl-*)
INSTALL_LIBRESSL=$(echo ${TARGET} | cut -f2 -d-)
case ${INSTALL_LIBRESSL} in
master) ;;
2022-04-08 17:19:17 +00:00
*) INSTALL_LIBRESSL="$(echo ${TARGET} | cut -f2 -d-)" ;;
2021-08-30 19:14:33 +00:00
esac
2023-12-18 15:59:40 +00:00
PACKAGES="${PACKAGES} putty-tools dropbear-bin"
2021-04-23 19:10:38 +00:00
;;
2023-08-10 16:16:53 +00:00
boringssl)
INSTALL_BORINGSSL=1
PACKAGES="${PACKAGES} cmake ninja-build"
;;
2021-04-23 19:10:38 +00:00
valgrind*)
PACKAGES="$PACKAGES valgrind"
;;
2023-10-04 12:06:41 +00:00
zlib-*)
;;
2021-04-23 19:10:38 +00:00
*) echo "Invalid option '${TARGET}'"
2021-02-14 21:09:58 +00:00
exit 1
;;
esac
done
2021-08-30 19:14:33 +00:00
if [ "yes" = "$INSTALL_FIDO_PPA" ]; then
2021-02-14 21:09:58 +00:00
sudo apt update -qq
2021-11-04 17:16:52 +00:00
sudo apt install -qy software-properties-common
sudo apt-add-repository -y ppa:yubico/stable
2021-02-14 21:09:58 +00:00
fi
2023-02-05 18:04:12 +00:00
tries=3
while [ ! -z "$PACKAGES" ] && [ "$tries" -gt "0" ]; do
2022-10-04 15:10:40 +00:00
case "$PACKAGER" in
apt)
sudo apt update -qq
2023-02-05 18:04:12 +00:00
if sudo apt install -qy $PACKAGES; then
PACKAGES=""
fi
2022-10-04 15:10:40 +00:00
;;
2023-12-18 15:59:40 +00:00
brew)
if [ ! -z "PACKAGES" ]; then
if brew install $PACKAGES; then
PACKAGES=""
fi
fi
;;
2022-10-04 15:10:40 +00:00
setup)
2023-02-05 18:04:12 +00:00
if /cygdrive/c/setup.exe -q -P `echo "$PACKAGES" | tr ' ' ,`; then
PACKAGES=""
fi
2022-10-04 15:10:40 +00:00
;;
esac
2023-02-05 18:04:12 +00:00
if [ ! -z "$PACKAGES" ]; then
sleep 90
fi
tries=$(($tries - 1))
done
if [ ! -z "$PACKAGES" ]; then
echo "Package installation failed."
exit 1
2021-02-14 21:09:58 +00:00
fi
2021-04-23 19:10:38 +00:00
if [ "${INSTALL_HARDENED_MALLOC}" = "yes" ]; then
(cd ${HOME} &&
git clone https://github.com/GrapheneOS/hardened_malloc.git &&
cd ${HOME}/hardened_malloc &&
2023-12-18 15:59:40 +00:00
make && sudo cp out/libhardened_malloc.so /usr/lib/)
2021-04-23 19:10:38 +00:00
fi
2021-08-30 19:14:33 +00:00
if [ ! -z "${INSTALL_OPENSSL}" ]; then
2021-04-23 19:10:38 +00:00
(cd ${HOME} &&
git clone https://github.com/openssl/openssl.git &&
cd ${HOME}/openssl &&
2021-08-30 19:14:33 +00:00
git checkout ${INSTALL_OPENSSL} &&
./config no-threads shared ${SSLCONFOPTS} \
--prefix=/opt/openssl &&
make && sudo make install_sw)
2021-04-23 19:10:38 +00:00
fi
2021-08-30 19:14:33 +00:00
if [ ! -z "${INSTALL_LIBRESSL}" ]; then
2022-04-08 17:19:17 +00:00
if [ "${INSTALL_LIBRESSL}" = "master" ]; then
(mkdir -p ${HOME}/libressl && cd ${HOME}/libressl &&
git clone https://github.com/libressl-portable/portable.git &&
cd ${HOME}/libressl/portable &&
git checkout ${INSTALL_LIBRESSL} &&
sh update.sh && sh autogen.sh &&
./configure --prefix=/opt/libressl &&
2023-12-18 15:59:40 +00:00
make && sudo make install)
2022-04-08 17:19:17 +00:00
else
LIBRESSL_URLBASE=https://cdn.openbsd.org/pub/OpenBSD/LibreSSL
(cd ${HOME} &&
wget ${LIBRESSL_URLBASE}/libressl-${INSTALL_LIBRESSL}.tar.gz &&
tar xfz libressl-${INSTALL_LIBRESSL}.tar.gz &&
cd libressl-${INSTALL_LIBRESSL} &&
2023-12-18 15:59:40 +00:00
./configure --prefix=/opt/libressl && make && sudo make install)
2022-04-08 17:19:17 +00:00
fi
2021-04-23 19:10:38 +00:00
fi
2023-08-10 16:16:53 +00:00
if [ ! -z "${INSTALL_BORINGSSL}" ]; then
(cd ${HOME} && git clone https://boringssl.googlesource.com/boringssl &&
cd ${HOME}/boringssl && mkdir build && cd build &&
cmake -GNinja -DCMAKE_POSITION_INDEPENDENT_CODE=ON .. && ninja &&
mkdir -p /opt/boringssl/lib &&
cp ${HOME}/boringssl/build/crypto/libcrypto.a /opt/boringssl/lib &&
cp -r ${HOME}/boringssl/include /opt/boringssl)
fi
2023-10-04 12:06:41 +00:00
if [ ! -z "${INSTALL_ZLIB}" ]; then
(cd ${HOME} && git clone https://github.com/madler/zlib.git &&
cd ${HOME}/zlib && ./configure && make &&
sudo make install prefix=/opt/zlib)
fi