Skip to content

Commit 5de0406

Browse files
committed
rustbuild: Retry downloads of OpenSSL source
We need this to compile Cargo and we download it at build time, but as like all other network requests it has a chance of failing. This commit moves the source of the tarball to a mirror (S3 seems semi-more-reliable most of the time) and also wraps the download in a retry loop. cc rust-lang#40474
1 parent 6f10e2f commit 5de0406

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/bootstrap/native.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,24 @@ pub fn openssl(build: &Build, target: &str) {
222222
let tarball = out.join(&name);
223223
if !tarball.exists() {
224224
let tmp = tarball.with_extension("tmp");
225-
build.run(Command::new("curl")
226-
.arg("-o").arg(&tmp)
227-
.arg(format!("https://www.openssl.org/source/{}", name)));
225+
// originally from https://www.openssl.org/source/...
226+
let url = format!("https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/{}",
227+
name);
228+
let mut ok = false;
229+
for _ in 0..3 {
230+
let status = Command::new("curl")
231+
.arg("-o").arg(&tmp)
232+
.arg(&url)
233+
.status()
234+
.expect("failed to spawn curl");
235+
if status.success() {
236+
ok = true;
237+
break
238+
}
239+
}
240+
if !ok {
241+
panic!("failed to download openssl source")
242+
}
228243
let mut shasum = if target.contains("apple") {
229244
let mut cmd = Command::new("shasum");
230245
cmd.arg("-a").arg("256");

0 commit comments

Comments
 (0)