about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-08-31 02:19:55 +0000
committerbors <bors@rust-lang.org>2023-08-31 02:19:55 +0000
commit008c21c9779fd1e3632d9fe908b8afc0c421b26c (patch)
treee19df4763ad536f607e9ca7a83ba852c7eb1e58b
parente51c5ea16f84ef811bf0aecbdc0ac48821d52cc9 (diff)
parent4ea90af70f2211fb07a5b722f21850ce99f06cf8 (diff)
downloadrust-008c21c9779fd1e3632d9fe908b8afc0c421b26c.tar.gz
rust-008c21c9779fd1e3632d9fe908b8afc0c421b26c.zip
Auto merge of #115323 - onur-ozkan:curl-download-checksum-fix, r=Mark-Simulacrum
avoid stdout redirection on `curl` executions

Avoid redirecting the curl output directly to the stdout. This alteration affects the integrity of the file during the retry process, as it also redirects the logs from the retries. Consequently, this leads to the bootstrap process failing because of an invalid checksum.

For more information, see the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/checksum.20errors)

Fixes #115275
-rw-r--r--src/bootstrap/bootstrap.py19
-rw-r--r--src/bootstrap/download.rs4
2 files changed, 11 insertions, 12 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 9dbc87c337c..e4c76226454 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -104,16 +104,15 @@ def _download(path, url, probably_big, verbose, exception):
         # If curl is not present on Win32, we should not sys.exit
         #   but raise `CalledProcessError` or `OSError` instead
         require(["curl", "--version"], exception=platform_is_win32())
-        with open(path, "wb") as outfile:
-            run(["curl", option,
-                "-L", # Follow redirect.
-                "-y", "30", "-Y", "10",    # timeout if speed is < 10 bytes/sec for > 30 seconds
-                "--connect-timeout", "30",  # timeout if cannot connect within 30 seconds
-                "--retry", "3", "-SRf", url],
-                stdout=outfile,    #Implements cli redirect operator '>'
-                verbose=verbose,
-                exception=True, # Will raise RuntimeError on failure
-            )
+        run(["curl", option,
+            "-L", # Follow redirect.
+            "-y", "30", "-Y", "10",    # timeout if speed is < 10 bytes/sec for > 30 seconds
+            "--connect-timeout", "30",  # timeout if cannot connect within 30 seconds
+            "-o", path,
+            "--retry", "3", "-SRf", url],
+            verbose=verbose,
+            exception=True, # Will raise RuntimeError on failure
+        )
     except (subprocess.CalledProcessError, OSError, RuntimeError):
         # see http://serverfault.com/questions/301128/how-to-download
         if platform_is_win32():
diff --git a/src/bootstrap/download.rs b/src/bootstrap/download.rs
index 17c308e915b..9489297d67d 100644
--- a/src/bootstrap/download.rs
+++ b/src/bootstrap/download.rs
@@ -225,6 +225,8 @@ impl Config {
             "10", // timeout if speed is < 10 bytes/sec for > 30 seconds
             "--connect-timeout",
             "30", // timeout if cannot connect within 30 seconds
+            "-o",
+            tempfile.to_str().unwrap(),
             "--retry",
             "3",
             "-SRf",
@@ -236,8 +238,6 @@ impl Config {
             curl.arg("--progress-bar");
         }
         curl.arg(url);
-        let f = File::create(tempfile).unwrap();
-        curl.stdout(Stdio::from(f));
         if !self.check_run(&mut curl) {
             if self.build.contains("windows-msvc") {
                 eprintln!("Fallback to PowerShell");