23
23
fi
24
24
versions=( " ${versions[@]%/ } " )
25
25
26
+ scriptPid=" $$ " # so we can kill the script even from a subshell
27
+ _curl () {
28
+ exec 42>&1
29
+ local code
30
+ code=" $( curl --silent --location -o /dev/fd/42 --write-out ' %{http_code}' " $@ " ) "
31
+ case " $code " in
32
+ 200) return 0 ;;
33
+ 404) return 1 ;;
34
+ esac
35
+ echo >&2 " error: unexpected status code $code while fetching: $* "
36
+ kill " $scriptPid "
37
+ exit 1
38
+ }
39
+
26
40
dindLatest=" $(
27
- curl -fsSL -H ' Accept: application/json' ' https://github.com/docker/docker/commits/master/hack/dind.atom' \
41
+ _curl -H ' Accept: application/json' ' https://github.com/docker/docker/commits/master/hack/dind.atom' \
28
42
| jq -r ' .payload | first(.commitGroups[].commits[].oid)'
29
43
) "
30
44
@@ -75,7 +89,7 @@ buildxVersions="$(
75
89
buildx=
76
90
buildxVersion=
77
91
for buildxVersion in $buildxVersions ; do
78
- if checksums=" $( curl -fsSL " https://github.com/docker/buildx/releases/download/v${buildxVersion} /checksums.txt" ) " ; then
92
+ if checksums=" $( _curl " https://github.com/docker/buildx/releases/download/v${buildxVersion} /checksums.txt" ) " ; then
79
93
buildx=" $( jq <<< " $checksums" -csR --arg version " $buildxVersion " '
80
94
rtrimstr("\n") | split("\n")
81
95
| map(
@@ -127,7 +141,7 @@ composeVersions="$(
127
141
compose=
128
142
composeVersion=
129
143
for composeVersion in $composeVersions ; do
130
- if checksums=" $( curl -fsSL " https://github.com/docker/compose/releases/download/v${composeVersion} /checksums.txt" ) " ; then
144
+ if checksums=" $( _curl " https://github.com/docker/compose/releases/download/v${composeVersion} /checksums.txt" ) " ; then
131
145
compose=" $( jq <<< " $checksums" -csR --arg version " $composeVersion " '
132
146
rtrimstr("\n") | split("\n")
133
147
| map(
@@ -223,7 +237,7 @@ for version in "${versions[@]}"; do
223
237
windows-* ) url=" https://download.docker.com/win/static/$channel /$arch /docker-$fullVersion .zip" ; windows=1 ;;
224
238
* ) url=" https://download.docker.com/linux/static/$channel /$arch /docker-$fullVersion .tgz" ; windows= ;;
225
239
esac
226
- if wget --quiet --spider " $url " & > /dev/null; then
240
+ if _curl --head " $url " > /dev/null; then
227
241
export bashbrewArch url
228
242
doc=" $(
229
243
jq <<< " $doc" -c ' .arches[env.bashbrewArch] = {
@@ -245,7 +259,7 @@ for version in "${versions[@]}"; do
245
259
case " $bashbrewArch " in
246
260
amd64 | arm64v8)
247
261
rootlessExtrasUrl=" https://download.docker.com/linux/static/$channel /$arch /docker-rootless-extras-$fullVersion .tgz"
248
- if wget --quiet --spider " $rootlessExtrasUrl " & > /dev/null; then
262
+ if _curl --head " $rootlessExtrasUrl " > /dev/null; then
249
263
export rootlessExtrasUrl
250
264
doc=" $( jq <<< " $doc" -c '
251
265
.arches[env.bashbrewArch].rootlessExtrasUrl = env.rootlessExtrasUrl
0 commit comments