Skip to content

Commit

Permalink
Fix path handling in download-mongodb (#498)
Browse files Browse the repository at this point in the history
Co-authored-by: Ezra Chung <88335979+eramongodb@users.noreply.github.com>
  • Loading branch information
blink1073 and eramongodb authored Sep 17, 2024
1 parent 73c1eae commit 4327b26
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions .evergreen/download-mongodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -688,25 +688,29 @@ set_url_win32 ()
MONGODB_24="https://fastdl.mongodb.org/win32/mongodb-win32-i386${DEBUG}-${VERSION_24}.zip"
}

# curl_retry emulates running curl with `--retry 5` and `--retry-all-errors`.
curl_retry ()
{
for i in 1 2 4 8 16; do
{ curl --fail -sS --max-time 300 "$@" && return 0; } || sleep $i
done
return 1
}

# 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 +731,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 +742,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 +771,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 +825,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

0 comments on commit 4327b26

Please sign in to comment.