Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path handling in download-mongodb #498

Merged
merged 17 commits into from
Sep 17, 2024
27 changes: 9 additions & 18 deletions .evergreen/download-mongodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -688,25 +688,27 @@ set_url_win32 ()
MONGODB_24="https://fastdl.mongodb.org/win32/mongodb-win32-i386${DEBUG}-${VERSION_24}.zip"
}

# curl_retry runs curl with up to three retries, retrying any error.
eramongodb marked this conversation as resolved.
Show resolved Hide resolved
curl_retry ()
{
for i in 2 4 8; do curl --fail -sS --max-time 300 "$@" && break || sleep $i;
blink1073 marked this conversation as resolved.
Show resolved Hide resolved
done
eramongodb marked this conversation as resolved.
Show resolved Hide resolved
}

# download_and_extract_package downloads a MongoDB server package.
download_and_extract_package ()
{
MONGODB_DOWNLOAD_URL=$1
EXTRACT=$2

# shellcheck disable=SC3028
SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})
. $SCRIPT_DIR/handle-paths.sh

if [ -n "${MONGODB_BINARIES:-}" ]; then
cd "$(dirname "$(dirname "${MONGODB_BINARIES:?}")")"
else
cd $DRIVERS_TOOLS
fi

echo "Installing server binaries..."
"$SCRIPT_DIR/retry-with-backoff.sh" curl $MONGODB_DOWNLOAD_URL --output mongodb-binaries.tgz
curl_retry $MONGODB_DOWNLOAD_URL --output mongodb-binaries.tgz

$EXTRACT mongodb-binaries.tgz
echo "Installing server binaries... done."
Expand All @@ -727,10 +729,6 @@ download_and_extract_mongosh ()
MONGOSH_DOWNLOAD_URL=$1
EXTRACT_MONGOSH=${2:-"tar zxf"}

# shellcheck disable=SC3028
SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})
. $SCRIPT_DIR/handle-paths.sh

if [ -z "$MONGOSH_DOWNLOAD_URL" ]; then
get_mongodb_download_url_for "$(get_distro)" latest false
fi
Expand All @@ -742,7 +740,7 @@ download_and_extract_mongosh ()
fi

echo "Installing MongoDB shell..."
"$SCRIPT_DIR/retry-with-backoff.sh" curl $MONGOSH_DOWNLOAD_URL --output mongosh.tgz
curl_retry $MONGOSH_DOWNLOAD_URL --output mongosh.tgz
$EXTRACT_MONGOSH mongosh.tgz

rm -f mongosh.tgz
Expand Down Expand Up @@ -771,10 +769,6 @@ download_and_extract ()
download_and_extract_mongosh "$MONGOSH_DOWNLOAD_URL" "$EXTRACT_MONGOSH"
fi

# shellcheck disable=SC3028
SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})
. $SCRIPT_DIR/handle-paths.sh

if [ ! -z "${INSTALL_LEGACY_SHELL:-}" ] && [ ! -e $DRIVERS_TOOLS/mongodb/bin/mongo ] && [ ! -e $DRIVERS_TOOLS/mongodb/bin/mongo.exe ]; then
# The legacy mongo shell is not included in server downloads of 6.0.0-rc6 or later. Refer: SERVER-64352.
# Some test scripts use the mongo shell for setup.
Expand Down Expand Up @@ -829,10 +823,7 @@ download_and_extract_crypt_shared ()
mkdir crypt_shared_download
cd crypt_shared_download

# shellcheck disable=SC3028
SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})
. $SCRIPT_DIR/handle-paths.sh
"$SCRIPT_DIR/retry-with-backoff.sh" curl $MONGO_CRYPT_SHARED_DOWNLOAD_URL --output crypt_shared-binaries.tgz
curl_retry $MONGO_CRYPT_SHARED_DOWNLOAD_URL --output crypt_shared-binaries.tgz
$EXTRACT crypt_shared-binaries.tgz

LIBRARY_NAME="mongo_crypt_v1"
Expand Down
Loading