Skip to content

Commit 24f9c57

Browse files
committed
build: Retry downloads to avoid transient CI issues.
1 parent 5a4322a commit 24f9c57

File tree

2 files changed

+66
-46
lines changed

2 files changed

+66
-46
lines changed

build.mac.sh

+27-17
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,18 @@ fi
7676
mkdir -p dep-build
7777
cd dep-build
7878

79+
download_file() {
80+
local url="$1"
81+
local filename="$2"
82+
for i in {1..5}; do
83+
curl -L "$url" -o "$filename" && return 0 || sleep 5
84+
done
85+
echo "Failed to download '$url' to '$filename' after 5 retries."
86+
return 1
87+
}
88+
7989
if [ ! -d ncurses-6.4 ]; then
80-
curl https://ftp.gnu.org/gnu/ncurses/ncurses-6.4.tar.gz -o ncurses.tar.gz
90+
download_file https://ftp.gnu.org/gnu/ncurses/ncurses-6.4.tar.gz ncurses.tar.gz
8191
tar -xf ncurses.tar.gz
8292
cd ncurses-6.4
8393
./configure --prefix=${PREFIX} --disable-shared --enable-termcap --enable-widec --enable-getcap
@@ -90,7 +100,7 @@ cd ..
90100
fi
91101

92102
if [ ! -d editline-1.17.1 ]; then
93-
curl -L https://github.com/troglobit/editline/releases/download/1.17.1/editline-1.17.1.tar.gz -o editline.tar.gz
103+
download_file https://github.com/troglobit/editline/releases/download/1.17.1/editline-1.17.1.tar.gz editline.tar.gz
94104
tar -xf editline.tar.gz
95105
cd editline-1.17.1
96106
./configure --prefix=${PREFIX} --disable-shared
@@ -100,7 +110,7 @@ cd ..
100110
fi
101111

102112
if [ ! -d sqlite-autoconf-3440000 ]; then
103-
curl https://sqlite.org/2023/sqlite-autoconf-3440000.tar.gz -o sqlite.tar.gz
113+
download_file https://sqlite.org/2023/sqlite-autoconf-3440000.tar.gz sqlite.tar.gz
104114
tar -xf sqlite.tar.gz
105115
cd sqlite-autoconf-3440000
106116
./configure --prefix=${PREFIX} --disable-shared
@@ -110,7 +120,7 @@ cd ..
110120
fi
111121

112122
if [ ! -d openssl-3.1.8 ]; then
113-
curl -L https://www.openssl.org/source/openssl-3.1.8.tar.gz -o openssl.tar.gz
123+
download_file https://www.openssl.org/source/openssl-3.1.8.tar.gz openssl.tar.gz
114124
tar -xf openssl.tar.gz
115125
cd openssl-3.1.8
116126
export "CPPINCLUDES=$PYTHON_BASE/Include"
@@ -127,15 +137,15 @@ cd ..
127137
fi
128138

129139
if [ ! -d bzip2-1.0.8 ]; then
130-
curl -L https://gitlab.com/bzip2/bzip2/-/archive/bzip2-1.0.8/bzip2-bzip2-1.0.8.tar.gz -o bzip2.tar.gz
140+
download_file https://gitlab.com/bzip2/bzip2/-/archive/bzip2-1.0.8/bzip2-bzip2-1.0.8.tar.gz bzip2.tar.gz
131141
tar -xf bzip2.tar.gz
132142
cd bzip2-bzip2-1.0.8
133143
make install "PREFIX=$PREFIX" -j$(sysctl -n hw.ncpu)
134144
cd ..
135145
fi
136146

137147
if [ ! -d xz-5.4.5 ]; then
138-
curl -L https://downloads.sourceforge.net/project/lzmautils/xz-5.4.5.tar.gz -o xz.tar.gz
148+
download_file https://downloads.sourceforge.net/project/lzmautils/xz-5.4.5.tar.gz xz.tar.gz
139149
tar -xf xz.tar.gz
140150
cd xz-5.4.5
141151
./configure --prefix=${PREFIX} --disable-shared
@@ -145,7 +155,7 @@ cd ..
145155
fi
146156

147157
if [ ! -d libffi-3.4.6 ]; then
148-
curl -L https://github.com/libffi/libffi/releases/download/v3.4.6/libffi-3.4.6.tar.gz -o libffi.tar.gz
158+
download_file https://github.com/libffi/libffi/releases/download/v3.4.6/libffi-3.4.6.tar.gz libffi.tar.gz
149159
tar -xf libffi.tar.gz
150160
cd libffi-3.4.6
151161
./configure --prefix=${PREFIX} --disable-shared
@@ -155,7 +165,7 @@ cd ..
155165
fi
156166

157167
if [ ! -d zlib-latest ]; then
158-
curl -L https://www.zlib.net/current/zlib.tar.gz -o zlib.tar.gz
168+
download_file https://www.zlib.net/current/zlib.tar.gz zlib.tar.gz
159169
tar -xf zlib.tar.gz
160170
mv zlib-* zlib-latest
161171
cd zlib-latest
@@ -166,7 +176,7 @@ cd ..
166176
fi
167177

168178
if [ ! -d libxcrypt-4.4.36 ]; then
169-
curl -L https://github.com/besser82/libxcrypt/releases/download/v4.4.36/libxcrypt-4.4.36.tar.xz -o libxcrypt.tar.xz
179+
download_file https://github.com/besser82/libxcrypt/releases/download/v4.4.36/libxcrypt-4.4.36.tar.xz libxcrypt.tar.xz
170180
tar -xf libxcrypt.tar.xz
171181
cd libxcrypt-4.4.36
172182
./configure --prefix=${PREFIX} --disable-shared
@@ -176,7 +186,7 @@ cd ..
176186
fi
177187

178188
if [ ! -d libpng-1.6.39 ]; then
179-
curl -L http://downloads.sourceforge.net/project/libpng/libpng16/1.6.39/libpng-1.6.39.tar.xz -o libpng.tar.gz
189+
download_file http://downloads.sourceforge.net/project/libpng/libpng16/1.6.39/libpng-1.6.39.tar.xz libpng.tar.gz
180190
tar -xf libpng.tar.gz
181191
cd libpng-1.6.39
182192
./configure --prefix=${PREFIX} --disable-shared --with-zlib-prefix=${PREFIX}
@@ -188,7 +198,7 @@ cd ..
188198
fi
189199

190200
if [ ! -d harfbuzz-8.3.0 ]; then
191-
curl -L https://github.com/harfbuzz/harfbuzz/releases/download/8.3.0/harfbuzz-8.3.0.tar.xz -o harfbuzz.tar.gz
201+
download_file https://github.com/harfbuzz/harfbuzz/releases/download/8.3.0/harfbuzz-8.3.0.tar.xz harfbuzz.tar.gz
192202
tar -xf harfbuzz.tar.gz
193203
cd harfbuzz-8.3.0
194204
./configure --prefix=${PREFIX} --disable-shared
@@ -198,7 +208,7 @@ cd ..
198208
fi
199209

200210
if [ ! -d freetype-2.13.2 ]; then
201-
curl -L https://download.savannah.gnu.org/releases/freetype/freetype-2.13.2.tar.gz -o freetype.tar.gz
211+
download_file https://download.savannah.gnu.org/releases/freetype/freetype-2.13.2.tar.gz freetype.tar.gz
202212
tar -xf freetype.tar.gz
203213
cd freetype-2.13.2
204214
./configure --prefix=${PREFIX} --disable-shared --with-brotli=no
@@ -216,7 +226,7 @@ cd ..
216226
fi
217227

218228
if [ ! -d tcl8.6.15 ]; then
219-
curl -L http://downloads.sourceforge.net/project/tcl/Tcl/8.6.15/tcl8.6.15-src.tar.gz -o tcl.tar.gz
229+
download_file http://downloads.sourceforge.net/project/tcl/Tcl/8.6.15/tcl8.6.15-src.tar.gz tcl.tar.gz
220230
tar -xf tcl.tar.gz
221231
cd tcl8.6.15/unix
222232
./configure --prefix=${PREFIX} --enable-shared=no --enable-threads
@@ -226,7 +236,7 @@ cd ../..
226236
fi
227237

228238
if [ ! -d expat-2.5.0 ]; then
229-
curl -L https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-2.5.0.tar.gz -o expat.tar.gz
239+
download_file https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-2.5.0.tar.gz expat.tar.gz
230240
tar -xf expat.tar.gz
231241
cd expat-2.5.0
232242
./configure --prefix=${PREFIX} --disable-shared
@@ -236,7 +246,7 @@ cd ..
236246
fi
237247

238248
if [ ! -d tk8.6.15 ]; then
239-
curl -L http://downloads.sourceforge.net/project/tcl/Tcl/8.6.15/tk8.6.15-src.tar.gz -o tk.tar.gz
249+
download_file http://downloads.sourceforge.net/project/tcl/Tcl/8.6.15/tk8.6.15-src.tar.gz tk.tar.gz
240250
tar -xf tk.tar.gz
241251
cd tk8.6.15/unix
242252
./configure --prefix=${PREFIX} --enable-shared=no --enable-threads --with-tcl=${PREFIX}/lib --enable-aqua
@@ -246,7 +256,7 @@ cd ../..
246256
fi
247257

248258
if [ ! -d mpdecimal-4.0.0 ]; then
249-
curl -L https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.0.tar.gz -o mpdecimal.tar.gz
259+
download_file https://www.bytereef.org/software/mpdecimal/releases/mpdecimal-4.0.0.tar.gz mpdecimal.tar.gz
250260
tar -xf mpdecimal.tar.gz
251261
cd mpdecimal-4.0.0
252262
./configure --prefix=${PREFIX} --disable-shared
@@ -256,7 +266,7 @@ cd ..
256266
fi
257267

258268
if [ ! -d libb2-0.98.1 ]; then
259-
curl -L https://github.com/BLAKE2/libb2/releases/download/v0.98.1/libb2-0.98.1.tar.gz -o libb2.tar.gz
269+
download_file https://github.com/BLAKE2/libb2/releases/download/v0.98.1/libb2-0.98.1.tar.gz libb2.tar.gz
260270
tar -xf libb2.tar.gz
261271
cd libb2-0.98.1
262272
./configure --prefix=${PREFIX} --disable-shared

0 commit comments

Comments
 (0)