Skip to content

Commit 6e6171b

Browse files
authored
Rollup merge of rust-lang#129594 - lolbinarycat:explain-curl-options, r=albertlarsan68
explain the options bootstrap passes to curl also fixes a discrepancy where the rust side doesn't use -L docs are only on the rust side, since duplicated prose has a tendancy to get out-of-sync, and also because there are talks of removing the python script all together eventually.
2 parents 3b2139b + 757affd commit 6e6171b

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

src/bootstrap/bootstrap.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,29 @@ def _download(path, url, probably_big, verbose, exception):
106106

107107
try:
108108
if (probably_big or verbose) and "GITHUB_ACTIONS" not in os.environ:
109-
option = "-#"
109+
option = "--progress-bar"
110110
else:
111-
option = "-s"
111+
option = "--silent"
112112
# If curl is not present on Win32, we should not sys.exit
113113
# but raise `CalledProcessError` or `OSError` instead
114114
require(["curl", "--version"], exception=platform_is_win32())
115115
extra_flags = []
116116
if curl_version() > (7, 70):
117117
extra_flags = [ "--retry-all-errors" ]
118+
# options should be kept in sync with
119+
# src/bootstrap/src/core/download.rs
120+
# for consistency.
121+
# they are also more compreprensivly explained in that file.
118122
run(["curl", option] + extra_flags + [
119-
"-L", # Follow redirect.
120-
"-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds
121-
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
122-
"-o", path,
123+
# Follow redirect.
124+
"--location",
125+
# timeout if speed is < 10 bytes/sec for > 30 seconds
126+
"--speed-time", "30", "--speed-limit", "10",
127+
# timeout if cannot connect within 30 seconds
128+
"--connect-timeout", "30",
129+
"--output", path,
123130
"--continue-at", "-",
124-
"--retry", "3", "-SRf", url],
131+
"--retry", "3", "--show-error", "--remote-time", "--fail", url],
125132
verbose=verbose,
126133
exception=True, # Will raise RuntimeError on failure
127134
)

src/bootstrap/src/core/download.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,25 +228,42 @@ impl Config {
228228
fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) {
229229
println!("downloading {url}");
230230
// Try curl. If that fails and we are on windows, fallback to PowerShell.
231+
// options should be kept in sync with
232+
// src/bootstrap/src/core/download.rs
233+
// for consistency
231234
let mut curl = command("curl");
232235
curl.args([
233-
"-y",
236+
// follow redirect
237+
"--location",
238+
// timeout if speed is < 10 bytes/sec for > 30 seconds
239+
"--speed-time",
234240
"30",
235-
"-Y",
236-
"10", // timeout if speed is < 10 bytes/sec for > 30 seconds
241+
"--speed-limit",
242+
"10",
243+
// timeout if cannot connect within 30 seconds
237244
"--connect-timeout",
238-
"30", // timeout if cannot connect within 30 seconds
239-
"-o",
245+
"30",
246+
// output file
247+
"--output",
240248
tempfile.to_str().unwrap(),
249+
// if there is an error, don't restart the download,
250+
// instead continue where it left off.
241251
"--continue-at",
242252
"-",
253+
// retry up to 3 times. note that this means a maximum of 4
254+
// attempts will be made, since the first attempt isn't a *re*try.
243255
"--retry",
244256
"3",
245-
"-SRf",
257+
// show errors, even if --silent is specified
258+
"--show-error",
259+
// set timestamp of downloaded file to that of the server
260+
"--remote-time",
261+
// fail on non-ok http status
262+
"--fail",
246263
]);
247264
// Don't print progress in CI; the \r wrapping looks bad and downloads don't take long enough for progress to be useful.
248265
if CiEnv::is_ci() {
249-
curl.arg("-s");
266+
curl.arg("--silent");
250267
} else {
251268
curl.arg("--progress-bar");
252269
}

0 commit comments

Comments
 (0)