2019-05-03 09:31:20 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -eux
|
|
|
|
|
2024-05-22 16:31:30 +00:00
|
|
|
BUILDSSL_DESTDIR=${BUILDSSL_DESTDIR:-${HOME}/opt}
|
|
|
|
BUILDSSL_TMPDIR=${BUILDSSL_TMPDIR:-/tmp/download-cache}
|
|
|
|
|
2019-05-03 09:31:20 +00:00
|
|
|
download_openssl () {
|
2024-05-22 16:31:30 +00:00
|
|
|
if [ ! -f "${BUILDSSL_TMPDIR}/openssl-${OPENSSL_VERSION}.tar.gz" ]; then
|
2020-04-07 18:35:49 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# OpenSSL has different links for latest and previous releases
|
|
|
|
# since we want to download several versions, let us try to treat
|
|
|
|
# current version as latest, if it fails, follow with previous
|
|
|
|
#
|
|
|
|
|
2024-05-22 16:31:30 +00:00
|
|
|
wget -P ${BUILDSSL_TMPDIR}/ \
|
2020-04-07 18:35:49 +00:00
|
|
|
"https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" || \
|
2024-05-22 16:31:30 +00:00
|
|
|
wget -P ${BUILDSSL_TMPDIR}/ \
|
2024-02-02 19:33:16 +00:00
|
|
|
"https://www.openssl.org/source/old/${OPENSSL_VERSION%[a-z]}/openssl-${OPENSSL_VERSION}.tar.gz" || \
|
2024-05-22 16:31:30 +00:00
|
|
|
wget -P ${BUILDSSL_TMPDIR}/ \
|
2024-02-02 19:33:16 +00:00
|
|
|
"https://github.com/openssl/openssl/releases/download/openssl-${OPENSSL_VERSION}/openssl-${OPENSSL_VERSION}.tar.gz"
|
2019-05-03 09:31:20 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-06-17 13:39:30 +00:00
|
|
|
# recent openssl versions support parallel builds and skipping the docs,
|
|
|
|
# while older ones require to build everything sequentially.
|
2019-05-03 09:31:20 +00:00
|
|
|
build_openssl_linux () {
|
|
|
|
(
|
2024-05-22 16:31:30 +00:00
|
|
|
cd "${BUILDSSL_TMPDIR}/openssl-${OPENSSL_VERSION}/"
|
|
|
|
./config shared --prefix="${BUILDSSL_DESTDIR}" --openssldir="${BUILDSSL_DESTDIR}" --libdir=lib -DPURIFY
|
2021-06-17 13:39:30 +00:00
|
|
|
if [ -z "${OPENSSL_VERSION##1.*}" ]; then
|
|
|
|
make all
|
|
|
|
else
|
|
|
|
make -j$(nproc) build_sw
|
|
|
|
fi
|
2021-06-10 05:52:23 +00:00
|
|
|
make install_sw
|
2019-05-03 09:31:20 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
build_openssl_osx () {
|
|
|
|
(
|
2024-05-22 16:31:30 +00:00
|
|
|
cd "${BUILDSSL_TMPDIR}/openssl-${OPENSSL_VERSION}/"
|
2019-05-03 09:31:20 +00:00
|
|
|
./Configure darwin64-x86_64-cc shared \
|
2024-05-22 16:31:30 +00:00
|
|
|
--prefix="${BUILDSSL_DESTDIR}" --openssldir="${BUILDSSL_DESTDIR}" --libdir=lib -DPURIFY
|
2021-06-10 05:52:23 +00:00
|
|
|
make depend build_sw install_sw
|
2019-05-03 09:31:20 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
build_openssl () {
|
2024-05-22 16:31:30 +00:00
|
|
|
if [ "$(cat ${BUILDSSL_DESTDIR}/.openssl-version)" != "${OPENSSL_VERSION}" ]; then
|
|
|
|
|
|
|
|
mkdir -p "${BUILDSSL_TMPDIR}/openssl-${OPENSSL_VERSION}/"
|
|
|
|
tar zxf "${BUILDSSL_TMPDIR}/openssl-${OPENSSL_VERSION}.tar.gz" -C "${BUILDSSL_TMPDIR}/openssl-${OPENSSL_VERSION}/" --strip-components=1
|
2020-02-11 09:36:23 +00:00
|
|
|
case `uname` in
|
|
|
|
'Darwin')
|
|
|
|
build_openssl_osx
|
|
|
|
;;
|
|
|
|
'Linux')
|
|
|
|
build_openssl_linux
|
|
|
|
;;
|
2024-05-15 19:41:42 +00:00
|
|
|
*)
|
|
|
|
echo "not yet implemented"
|
|
|
|
exit 1
|
|
|
|
;;
|
2020-02-11 09:36:23 +00:00
|
|
|
esac
|
2024-05-22 16:31:30 +00:00
|
|
|
echo "${OPENSSL_VERSION}" > "${BUILDSSL_DESTDIR}/.openssl-version"
|
2019-05-03 09:31:20 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
download_libressl () {
|
2024-05-22 16:31:30 +00:00
|
|
|
if [ ! -f "${BUILDSSL_TMPDIR}/libressl-${LIBRESSL_VERSION}.tar.gz" ]; then
|
|
|
|
wget -P ${BUILDSSL_TMPDIR}/ \
|
2023-04-26 10:15:11 +00:00
|
|
|
"https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL_VERSION}.tar.gz"
|
2019-05-03 09:31:20 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
build_libressl () {
|
2024-05-22 16:31:30 +00:00
|
|
|
if [ "$(cat ${BUILDSSL_DESTDIR}/.libressl-version)" != "${LIBRESSL_VERSION}" ]; then
|
|
|
|
mkdir -p "${BUILDSSL_TMPDIR}/libressl-${LIBRESSL_VERSION}/"
|
|
|
|
tar zxf "${BUILDSSL_TMPDIR}/libressl-${LIBRESSL_VERSION}.tar.gz" -C "${BUILDSSL_TMPDIR}/libressl-${LIBRESSL_VERSION}/" --strip-components=1
|
2019-05-03 09:31:20 +00:00
|
|
|
(
|
2024-05-22 16:31:30 +00:00
|
|
|
cd "${BUILDSSL_TMPDIR}/libressl-${LIBRESSL_VERSION}/"
|
|
|
|
./configure --prefix="${BUILDSSL_DESTDIR}"
|
2019-05-03 09:31:20 +00:00
|
|
|
make all install
|
|
|
|
)
|
2024-05-22 16:31:30 +00:00
|
|
|
echo "${LIBRESSL_VERSION}" > "${BUILDSSL_DESTDIR}/.libressl-version"
|
2019-05-03 09:31:20 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-06-04 21:16:51 +00:00
|
|
|
download_boringssl () {
|
2024-05-23 14:54:30 +00:00
|
|
|
|
|
|
|
# travis-ci comes with go-1.11, while boringssl requires go-1.13
|
|
|
|
eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.13 bash)"
|
|
|
|
|
2024-05-22 16:31:30 +00:00
|
|
|
if [ ! -d "${BUILDSSL_TMPDIR}/boringssl" ]; then
|
|
|
|
git clone --depth=1 https://boringssl.googlesource.com/boringssl ${BUILDSSL_TMPDIR}/boringssl
|
2019-06-04 21:16:51 +00:00
|
|
|
else
|
|
|
|
(
|
2024-05-22 16:31:30 +00:00
|
|
|
cd ${BUILDSSL_TMPDIR}/boringssl
|
2019-06-04 21:16:51 +00:00
|
|
|
git pull
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-05-23 14:54:30 +00:00
|
|
|
build_boringssl () {
|
|
|
|
cd ${BUILDSSL_TMPDIR}/boringssl
|
|
|
|
if [ -d build ]; then rm -rf build; fi
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
cmake -GNinja -DCMAKE_BUILD_TYPE=release -DBUILD_SHARED_LIBS=1 ..
|
|
|
|
ninja
|
|
|
|
|
|
|
|
rm -rf ${BUILDSSL_DESTDIR}/lib || exit 0
|
|
|
|
rm -rf ${BUILDSSL_DESTDIR}/include || exit 0
|
|
|
|
|
|
|
|
mkdir -p ${BUILDSSL_DESTDIR}/lib
|
|
|
|
cp crypto/libcrypto.so ssl/libssl.so ${BUILDSSL_DESTDIR}/lib
|
|
|
|
|
|
|
|
mkdir -p ${BUILDSSL_DESTDIR}/include
|
|
|
|
cp -r ../include/* ${BUILDSSL_DESTDIR}/include
|
|
|
|
}
|
|
|
|
|
2023-09-05 23:23:05 +00:00
|
|
|
download_aws_lc () {
|
2024-05-22 16:31:30 +00:00
|
|
|
if [ ! -f "${BUILDSSL_TMPDIR}/aws-lc-${AWS_LC_VERSION}.tar.gz" ]; then
|
|
|
|
mkdir -p "${BUILDSSL_TMPDIR}"
|
|
|
|
wget -q -O "${BUILDSSL_TMPDIR}/aws-lc-${AWS_LC_VERSION}.tar.gz" \
|
2023-09-05 23:23:05 +00:00
|
|
|
"https://github.com/aws/aws-lc/archive/refs/tags/v${AWS_LC_VERSION}.tar.gz"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
build_aws_lc () {
|
2024-05-22 16:31:30 +00:00
|
|
|
if [ "$(cat ${BUILDSSL_DESTDIR}/.aws_lc-version)" != "${AWS_LC_VERSION}" ]; then
|
|
|
|
mkdir -p "${BUILDSSL_TMPDIR}/aws-lc-${AWS_LC_VERSION}/"
|
|
|
|
tar zxf "${BUILDSSL_TMPDIR}/aws-lc-${AWS_LC_VERSION}.tar.gz" -C "${BUILDSSL_TMPDIR}/aws-lc-${AWS_LC_VERSION}/" --strip-components=1
|
2023-09-05 23:23:05 +00:00
|
|
|
(
|
2024-05-22 16:31:30 +00:00
|
|
|
cd "${BUILDSSL_TMPDIR}/aws-lc-${AWS_LC_VERSION}/"
|
2023-09-05 23:23:05 +00:00
|
|
|
mkdir -p build
|
|
|
|
cd build
|
|
|
|
cmake -version
|
|
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DDISABLE_GO=1 -DDISABLE_PERL=1 \
|
2024-05-22 16:31:30 +00:00
|
|
|
-DBUILD_TESTING=0 -DCMAKE_INSTALL_PREFIX=${BUILDSSL_DESTDIR} ..
|
2023-09-05 23:23:05 +00:00
|
|
|
make -j$(nproc)
|
|
|
|
make install
|
|
|
|
)
|
2024-05-22 16:31:30 +00:00
|
|
|
echo "${AWS_LC_VERSION}" > "${BUILDSSL_DESTDIR}/.aws_lc-version"
|
2023-09-05 23:23:05 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-11-18 13:27:56 +00:00
|
|
|
download_quictls () {
|
2024-05-22 16:31:30 +00:00
|
|
|
if [ ! -d "${BUILDSSL_TMPDIR}/quictls" ]; then
|
|
|
|
git clone --depth=1 https://github.com/quictls/openssl ${BUILDSSL_TMPDIR}/quictls
|
2021-11-18 13:27:56 +00:00
|
|
|
else
|
|
|
|
(
|
2024-05-22 16:31:30 +00:00
|
|
|
cd ${BUILDSSL_TMPDIR}/quictls
|
2021-11-18 13:27:56 +00:00
|
|
|
git pull
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-05-23 14:54:30 +00:00
|
|
|
build_quictls () {
|
|
|
|
cd ${BUILDSSL_TMPDIR}/quictls
|
|
|
|
./config shared no-tests ${QUICTLS_EXTRA_ARGS:-} --prefix="${BUILDSSL_DESTDIR}" --openssldir="${BUILDSSL_DESTDIR}" --libdir=lib -DPURIFY
|
|
|
|
make -j$(nproc) build_sw
|
|
|
|
make install_sw
|
|
|
|
}
|
|
|
|
|
2023-10-09 21:34:44 +00:00
|
|
|
download_wolfssl () {
|
2024-05-22 16:31:30 +00:00
|
|
|
if [ ! -f "${BUILDSSL_TMPDIR}/wolfssl-${WOLFSSL_VERSION}.tar.gz" ]; then
|
|
|
|
mkdir -p ${BUILDSSL_TMPDIR}
|
2023-10-09 22:26:46 +00:00
|
|
|
if [ "${WOLFSSL_VERSION%%-*}" != "git" ]; then
|
2024-05-22 16:31:30 +00:00
|
|
|
wget -q -O "${BUILDSSL_TMPDIR}/wolfssl-${WOLFSSL_VERSION}.tar.gz" \
|
2023-10-09 22:26:46 +00:00
|
|
|
"https://github.com/wolfSSL/wolfssl/archive/refs/tags/v${WOLFSSL_VERSION}-stable.tar.gz"
|
|
|
|
else
|
2024-05-22 16:31:30 +00:00
|
|
|
wget -q -O "${BUILDSSL_TMPDIR}/wolfssl-${WOLFSSL_VERSION}.tar.gz" \
|
2023-10-09 22:26:46 +00:00
|
|
|
"https://github.com/wolfSSL/wolfssl/archive/${WOLFSSL_VERSION##git-}.tar.gz"
|
|
|
|
fi
|
2023-10-09 21:34:44 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
build_wolfssl () {
|
2024-05-22 16:31:30 +00:00
|
|
|
if [ "$(cat ${BUILDSSL_DESTDIR}/.wolfssl-version)" != "${WOLFSSL_VERSION}" ]; then
|
|
|
|
mkdir -p "${BUILDSSL_TMPDIR}/wolfssl-${WOLFSSL_VERSION}/"
|
|
|
|
tar zxf "${BUILDSSL_TMPDIR}/wolfssl-${WOLFSSL_VERSION}.tar.gz" -C "${BUILDSSL_TMPDIR}/wolfssl-${WOLFSSL_VERSION}/" --strip-components=1
|
2023-10-09 21:34:44 +00:00
|
|
|
(
|
2024-05-22 16:31:30 +00:00
|
|
|
cd "${BUILDSSL_TMPDIR}/wolfssl-${WOLFSSL_VERSION}/"
|
2023-10-09 21:34:44 +00:00
|
|
|
autoreconf -i
|
2024-05-22 16:31:30 +00:00
|
|
|
./configure --enable-haproxy --enable-quic --prefix="${BUILDSSL_DESTDIR}"
|
2023-10-09 21:34:44 +00:00
|
|
|
make -j$(nproc)
|
|
|
|
make install
|
|
|
|
)
|
2024-05-22 16:31:30 +00:00
|
|
|
echo "${WOLFSSL_VERSION}" > "${BUILDSSL_DESTDIR}/.wolfssl-version"
|
2023-10-09 21:34:44 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-05-22 16:31:30 +00:00
|
|
|
mkdir -p "${BUILDSSL_DESTDIR}"
|
|
|
|
|
|
|
|
|
2019-05-03 09:31:20 +00:00
|
|
|
if [ ! -z ${LIBRESSL_VERSION+x} ]; then
|
|
|
|
download_libressl
|
|
|
|
build_libressl
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z ${OPENSSL_VERSION+x} ]; then
|
|
|
|
download_openssl
|
|
|
|
build_openssl
|
|
|
|
fi
|
|
|
|
|
2019-05-08 20:15:59 +00:00
|
|
|
if [ ! -z ${BORINGSSL+x} ]; then
|
2024-05-23 14:54:30 +00:00
|
|
|
download_boringssl
|
|
|
|
build_boringssl
|
2019-05-08 20:15:59 +00:00
|
|
|
fi
|
2019-05-03 09:31:20 +00:00
|
|
|
|
2023-09-05 23:23:05 +00:00
|
|
|
if [ ! -z ${AWS_LC_VERSION+x} ]; then
|
|
|
|
download_aws_lc
|
|
|
|
build_aws_lc
|
|
|
|
fi
|
|
|
|
|
2021-11-18 13:27:56 +00:00
|
|
|
if [ ! -z ${QUICTLS+x} ]; then
|
|
|
|
download_quictls
|
2024-05-23 14:54:30 +00:00
|
|
|
build_quictls
|
2021-11-18 13:27:56 +00:00
|
|
|
fi
|
2023-10-09 21:34:44 +00:00
|
|
|
|
|
|
|
if [ ! -z ${WOLFSSL_VERSION+x} ]; then
|
|
|
|
download_wolfssl
|
|
|
|
build_wolfssl
|
|
|
|
fi
|