Check for errors in archive download, fix --version, whitespace consistency

This commit is contained in:
Anton Tieleman 2016-09-19 19:59:20 +02:00
parent 955b3df8bb
commit 7c1e6c86d5
1 changed files with 32 additions and 23 deletions

View File

@ -172,7 +172,7 @@ elif [ -n "${BRANCH}" ]; then
if [[ ! "${BRANCH}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then if [[ ! "${BRANCH}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Unknown branch version number format. Examples: 1.0.2, 1.0.1" echo "Unknown branch version number format. Examples: 1.0.2, 1.0.1"
exit 1 exit 1
# Valid version number, determine latest version # Valid version number, determine latest version
else else
echo "Checking latest version of ${BRANCH} branch on GitHub..." echo "Checking latest version of ${BRANCH} branch on GitHub..."
@ -184,13 +184,13 @@ elif [ -n "${BRANCH}" ]; then
echo "Could not determine latest version, please check https://github.com/openssl/openssl/releases and use --version option" echo "Could not determine latest version, please check https://github.com/openssl/openssl/releases and use --version option"
exit 1 exit 1
fi fi
VERSION="${GITHUB_VERSION//_/.}" VERSION="${GITHUB_VERSION//_/.}"
# Check whether download exists # Check whether download exists
# -I = HEAD, -L follow Location header, -f fail silently for 4xx errors and return status 22, -s silent # -I = HEAD, -L follow Location header, -f fail silently for 4xx errors and return status 22, -s silent
curl ${CURL_OPTIONS} -ILfs "https://github.com/openssl/openssl/archive/OpenSSL_${GITHUB_VERSION}.tar.gz" > /dev/null curl ${CURL_OPTIONS} -ILfs "https://github.com/openssl/openssl/archive/OpenSSL_${GITHUB_VERSION}.tar.gz" > /dev/null
# Check for success status # Check for success status
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Script determined latest version ${VERSION}, but the download archive does not seem to be available." echo "Script determined latest version ${VERSION}, but the download archive does not seem to be available."
@ -200,7 +200,7 @@ elif [ -n "${BRANCH}" ]; then
fi fi
# Script default # Script default
else elif [ -z "${VERSION}" ]; then
VERSION="${DEFAULTVERSION}" VERSION="${DEFAULTVERSION}"
fi fi
@ -268,34 +268,43 @@ fi
echo " Script directory and build location: ${CURRENTPATH}" echo " Script directory and build location: ${CURRENTPATH}"
echo echo
# -e Abort script at first error, when a command exits with non-zero status (except in until or while loops, if-tests, list constructs)
# -o pipefail Causes a pipeline to return the exit status of the last command in the pipe that returned a non-zero return value
set -eo pipefail
# Download OpenSSL when not present # Download OpenSSL when not present
OPENSSL_ARCHIVE_BASE_NAME=OpenSSL_${GITHUB_VERSION} OPENSSL_ARCHIVE_BASE_NAME=OpenSSL_${GITHUB_VERSION}
OPENSSL_ARCHIVE_FILE_NAME=${OPENSSL_ARCHIVE_BASE_NAME}.tar.gz OPENSSL_ARCHIVE_FILE_NAME=${OPENSSL_ARCHIVE_BASE_NAME}.tar.gz
if [ ! -e ${OPENSSL_ARCHIVE_FILE_NAME} ]; then if [ ! -e ${OPENSSL_ARCHIVE_FILE_NAME} ]; then
echo "Downloading ${OPENSSL_ARCHIVE_FILE_NAME}..." echo "Downloading ${OPENSSL_ARCHIVE_FILE_NAME}..."
curl ${CURL_OPTIONS} -L -O https://github.com/openssl/openssl/archive/${OPENSSL_ARCHIVE_FILE_NAME} OPENSSL_ARCHIVE_URL="https://github.com/openssl/openssl/archive/${OPENSSL_ARCHIVE_FILE_NAME}"
# -L follow Location header, -f fail silently for 4xx errors and return status 22, -O Use server-specified filename for download
curl ${CURL_OPTIONS} -LfO "${OPENSSL_ARCHIVE_URL}"
# Check for success status
if [ $? -ne 0 ]; then
echo "An error occured when trying to download OpenSSL ${VERSION} from ${OPENSSL_ARCHIVE_URL}."
echo "Please check cURL's error message and/or your network connection."
exit 1
fi
else else
echo "Using ${OPENSSL_ARCHIVE_FILE_NAME}" echo "Using ${OPENSSL_ARCHIVE_FILE_NAME}"
fi fi
# -e Abort script at first error, when a command exits with non-zero status (except in until or while loops, if-tests, list constructs)
# -o pipefail Causes a pipeline to return the exit status of the last command in the pipe that returned a non-zero return value
set -eo pipefail
# Clean up target directories if requested and present # Clean up target directories if requested and present
if [ "${CLEANUP}" == "true" ]; then if [ "${CLEANUP}" == "true" ]; then
if [ -d "${CURRENTPATH}/bin" ]; then if [ -d "${CURRENTPATH}/bin" ]; then
rm -r "${CURRENTPATH}/bin" rm -r "${CURRENTPATH}/bin"
fi fi
if [ -d "${CURRENTPATH}/include/openssl" ]; then if [ -d "${CURRENTPATH}/include/openssl" ]; then
rm -r "${CURRENTPATH}/include/openssl" rm -r "${CURRENTPATH}/include/openssl"
fi fi
if [ -d "${CURRENTPATH}/lib" ]; then if [ -d "${CURRENTPATH}/lib" ]; then
rm -r "${CURRENTPATH}/lib" rm -r "${CURRENTPATH}/lib"
fi fi
if [ -d "${CURRENTPATH}/src" ]; then if [ -d "${CURRENTPATH}/src" ]; then
rm -r "${CURRENTPATH}/src" rm -r "${CURRENTPATH}/src"
fi fi
fi fi
# (Re-)create target directories # (Re-)create target directories
@ -395,7 +404,7 @@ do
else else
(./Configure ${LOCAL_CONFIG_OPTIONS} > "${LOG}" 2>&1) & spinner (./Configure ${LOCAL_CONFIG_OPTIONS} > "${LOG}" 2>&1) & spinner
fi fi
# Check for error status # Check for error status
check_status $? "Configure" check_status $? "Configure"