Improve OpenSSL provisioning on macOS

- Make the script idempotent
  - Use local architecture instead of hard-coding x86_64
  - Set deployment target to 10.14
  - Improve logging by not building with --silent
  - Don't install manual pages
  - Allow custom install prefix (for testing)

Pick-to: 6.2
Change-Id: I728a2595987db0568568bbb8ca8117effca73997
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
This commit is contained in:
Tor Arne Vestbø
2021-08-10 16:36:24 +02:00
parent cec25d2ac6
commit f8fab3be9b

View File

@@ -50,8 +50,8 @@ sha="bad9dc4ae6dcc1855085463099b5dacb0ec6130b"
opensslHome="${HOME}/openssl-${version}"
opensslSource="${opensslHome}-src"
DownloadURL "$cachedUrl" "$officialUrl" "$sha" "$targetFile"
tar -xzf "$targetFile" -C "$HOME"
mv "$opensslHome" "$opensslSource"
mkdir -p "$opensslSource"
tar -xzf "$targetFile" --strip 1 -C "$opensslSource"
cd "$opensslSource"
pwd
@@ -68,11 +68,17 @@ if [[ "$os" == "linux" ]]; then
elif [ "$os" == "macos" -o "$os" == "macos-universal" ]; then
# Below target location has been hard coded into Coin.
# QTQAINFRA-1195
openssl_install_dir=/usr/local/openssl-$version
opensslTargetLocation="/usr/local/opt/openssl"
echo "prefix=$prefix"
if [[ -z "$prefix" ]]; then
prefix="/usr/local"
fi
openssl_install_dir="$prefix/openssl-$version"
opensslTargetLocation="$prefix/opt/openssl"
commonFlags="no-tests shared no-ssl3-method enable-ec_nistp_64_gcc_128 -Wa,--noexecstack"
export MACOSX_DEPLOYMENT_TARGET=10.14
opensslBuild="${opensslHome}-build"
opensslDestdir="${opensslHome}-destdir"
mkdir -p $opensslBuild
@@ -80,17 +86,17 @@ elif [ "$os" == "macos" -o "$os" == "macos-universal" ]; then
if [ "$os" == "macos-universal" ]; then
archs="x86_64 arm64"
else
archs="x86_64"
archs="$(uname -m)"
fi
for arch in $archs; do
cd $opensslBuild
echo "Configuring OpenSSL for $arch"
mkdir $arch && cd $arch
mkdir -p $arch && cd $arch
$opensslSource/Configure --prefix=$openssl_install_dir $commonFlags darwin64-$arch-cc
echo "Building OpenSSL for $arch"
make --silent >> /tmp/openssl_make.log 2>&1
echo "Building OpenSSL for $arch in $PWD"
make >> /tmp/openssl_make.log 2>&1
echo "Installing OpenSSL for $arch"
if [ "$os" == "macos-universal" ]; then
@@ -99,12 +105,13 @@ elif [ "$os" == "macos" -o "$os" == "macos-universal" ]; then
destdir=""
fi
# shellcheck disable=SC2024
sudo make --silent install DESTDIR=$destdir >> /tmp/openssl_make_install.log 2>&1
sudo make install_sw install_ssldirs DESTDIR=$destdir >> /tmp/openssl_make_install.log 2>&1
done
if [ "$os" == "macos-universal" ]; then
echo "Making universal OpenSSL package"
# shellcheck disable=SC2024
sudo rm -Rf "$openssl_install_dir"
sudo ${BASH_SOURCE%/*}/../macos/makeuniversal.sh "$opensslDestdir/x86_64" $opensslDestdir/arm64
fi