Skip to content

Commit 1e9b2e1

Browse files
Tweak find-cmake to use download.sh for downloader-agnosticism.
1 parent d9aeba8 commit 1e9b2e1

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

.evergreen/scripts/find-cmake-latest.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#!/usr/bin/env bash
22

33
find_cmake_latest() {
4-
# shellcheck source=.evergreen/scripts/env-var-utils.sh
5-
. "$(dirname "${BASH_SOURCE[0]}")/env-var-utils.sh"
6-
. "$(dirname "${BASH_SOURCE[0]}")/use-tools.sh" paths
4+
. "$(dirname "${BASH_SOURCE[0]}")/use-tools.sh" paths || return
75

86
declare script_dir
97
script_dir="$(to_absolute "$(dirname "${BASH_SOURCE[0]}")")" || return

.evergreen/scripts/find-cmake-version.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
# Used to workaround curl certificate validation failures on certain distros.
4-
. "$(dirname "${BASH_SOURCE[0]}")/use-tools.sh" platform
4+
. "$(dirname "${BASH_SOURCE[0]}")/use-tools.sh" platform download
55

66
# Create a temporary directory in the existing directory $1.
77
make_tmpdir_in() {
@@ -168,19 +168,13 @@ find_cmake_version() {
168168
*) ;; # Build from source.
169169
esac
170170

171-
declare -a curl_args
172-
curl_args=(
173-
"--retry" "5"
174-
"-sS"
175-
"--max-time" "120"
176-
"--fail"
177-
)
171+
declare -a download_args=(--out="cmake.${extension}")
178172

179173
# TODO: remove once BUILD-16817 is resolved.
180174
# Workaround SSL certificate validation failures on certain distros.
181175
case "$OS_SHORTNAME-$ARCHNAME" in
182176
ubuntu14-*|ubuntu16-ppc|RedHat7-ppc)
183-
curl_args+=("-k")
177+
download_args+=(--no-tls-verify)
184178
;;
185179
esac
186180

@@ -196,13 +190,14 @@ find_cmake_version() {
196190
if [[ -n "${platform:-}" ]]; then
197191
cmake_download_binary() (
198192
declare -r cmake_url="https://cmake.org/files/v${major}.${minor}/cmake-${version}-${platform}.${extension}"
193+
download_args+=(--uri="${cmake_url}")
199194

200195
echo "Downloading cmake-${version}-${platform}..."
201196

202197
cd "${tmp_cmake_dir}" || return
203198

204199
# Allow download to fail and fallback to building from source.
205-
if curl "${curl_args[@]}" "${cmake_url}" --output "cmake.${extension}"; then
200+
if download-file "${download_args[@]}"; then
206201
"${decompressor}" "${decompressor_args[@]}" "cmake.${extension}" || return
207202

208203
cmake_replace_version "${cache_dir}" "$(pwd)/${root_dir}" "${version}" || return

tools/download.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ download-file() {
4242
done
4343
if ! is-set uri || ! is-set out; then
4444
fail "download-file requires --uri=<uri> and --out=<filepath> arguments"
45+
return
4546
fi
4647
debug "Download [$uri] to [$out]"
4748

@@ -60,7 +61,7 @@ download-file() {
6061
fi
6162
curl_argv+=(-- "$uri")
6263
debug "Execute curl command: [curl ${curl_argv[*]}]"
63-
output=$(curl "${curl_argv[@]}") || fail "$output"
64+
output=$(curl "${curl_argv[@]}") || fail "$output" || return
6465
debug "$output"
6566
elif have-command wget; then
6667
wget_argv=(
@@ -73,10 +74,10 @@ download-file() {
7374
fi
7475
wget_argv+=(-- "$uri")
7576
debug "Execute wget command: [wget ${wget_argv[*]}]"
76-
output=$(wget "${wget_argv[@]}" 2>&1) || fail "wget failed: $output"
77+
output=$(wget "${wget_argv[@]}" 2>&1) || fail "wget failed: $output" || return
7778
debug "$output"
7879
else
79-
fail "This script requires wither curl or wget to be available"
80+
fail "This script requires either curl or wget to be available" || return
8081
fi
8182
debug "Download [$uri] to [$out] - Done"
8283
}

0 commit comments

Comments
 (0)