Change:
I accidentally missed this when porting it to rustbuild: It would be nice to add it back. Mentoring instructions: Add a new parameter to and pass it down from : This code moved around in so you may want to base your changes off that PR until it lands. label +E-easy +E-mentor +A-rustbuild <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
Please also remove the dead code from at the same time:
claim

Discussion:
except tarfile.CompressionError: return False <del> def get(base, url, path, checksums, verbose=False, do_verify=True, help_on_error=None): </del> <ins> def get(base, url, path, checksums, verbose=False, do_verify=True): </ins> with tempfile.NamedTemporaryFile(delete=False) as temp_file: temp_path = temp_file.name

print("ignoring already-download file", path, "due to failed verification") os.unlink(path) <del> download(temp_path, "{}/{}".format(base, url), True, verbose, help_on_error=help_on_error) </del> <ins> download(temp_path, "{}/{}".format(base, url), True, verbose) </ins> if do_verify and not verify(temp_path, sha256, verbose): raise RuntimeError("failed verification") if verbose:

os.unlink(temp_path) <del> def download(path, url, probably_big, verbose, help_on_error=None): </del> <ins> def download(path, url, probably_big, verbose): </ins> for _ in range(0, 4): try: <del> _download(path, url, probably_big, verbose, True, help_on_error=help_on_error) </del> <ins> _download(path, url, probably_big, verbose, True) </ins> return except RuntimeError: print("nspurious failure, trying again") <del> _download(path, url, probably_big, verbose, False, help_on_error=help_on_error) </del> <ins> _download(path, url, probably_big, verbose, False) </ins> <del> def _download(path, url, probably_big, verbose, exception, help_on_error=None): </del> <ins> def _download(path, url, probably_big, verbose, exception): </ins> # Try to use curl (potentially available on win32 #    https://devblogs.microsoft.com/commandline/tar-and-curl-come-to-windows/) # If an error occurs:

"--retry", "3", "-Sf", "-o", path, url], verbose=verbose, exception=True, # Will raise RuntimeError on failure <del> help_on_error=help_on_error) </del> <ins> ) </ins> except (subprocess.CalledProcessError, OSError, RuntimeError): # see http://serverfault.com/questions/301128/how-to-download if platform_is_win32:

shutil.rmtree(os.path.join(dst, fname)) <del> def run(args, verbose=False, exception=False, is_bootstrap=False, help_on_error=None, **kwargs): </del> <ins> def run(args, verbose=False, exception=False, is_bootstrap=False, **kwargs): </ins> """Run a child program in a new process""" if verbose: print("running: " + ' '.join(args))

code = ret.wait() if code != 0: err = "failed to run: " + ' '.join(args) <del> if help_on_error is not None: err += "n" + help_on_error </del> if verbose or exception: raise RuntimeError(err) # For most failures, we definitely do want to print this error, or the user will have no

self.try_run(patchelf.arg(fname)); } <del> pub(crate) fn download_component(&self, base: &str, url: &str, dest_path: &Path) { </del> <ins> pub(crate) fn download_component( &self, base: &str, url: &str, dest_path: &Path, help_on_error: &str, ) { </ins> // Use a temporary file in case we crash while downloading, to avoid a corrupt download in cache/. let tempfile = self.tempdir().join(dest_path.file_name().unwrap()); // FIXME: support `do_verify` (only really needed for nightly rustfmt) <del> self.download_with_retries(&tempfile, &format!("{}/{}", base, url)); </del> <ins> self.download_with_retries(&tempfile, &format!("{}/{}", base, url), help_on_error); </ins> t!(std::fs::rename(&tempfile, dest_path)); } <del> fn download_with_retries(&self, tempfile: &Path, url: &str) { </del> <ins> fn download_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) { </ins> println!("downloading {}", url); // Try curl. If that fails and we are on windows, fallback to PowerShell. let mut curl = Command::new("curl");

println!("nspurious failure, trying again"); } } <ins> if !help_on_error.is_empty() { eprintln!("{}", help_on_error); } </ins> std::process::exit(1); } }

let url = format!("rustc-builds/{commit}"); let tarball = rustc_cache.join(&filename); if !tarball.exists() { <del> builder.download_component(base, &format!("{url}/{filename}"), &tarball); </del> <ins> builder.download_component(base, &format!("{url}/{filename}"), &tarball, ""); </ins> } let bin_root = builder.out.join(builder.config.build.triple).join("ci-rustc"); builder.unpack(&tarball, &bin_root, prefix)

let filename = format!("rust-dev-nightly-{}.tar.xz", builder.build.build.triple); let tarball = rustc_cache.join(&filename); if !tarball.exists() { <del> builder.download_component(base, &format!("{}/{}", url, filename), &tarball); </del> <ins> let help_on_error = "error: failed to download llvm from cin nhelp: old builds get deleted after a certain time nhelp: if trying to compile an old commit of rustc, disable `download-ci-llvm` in config.toml: n n[llvm] ndownload-ci-llvm = false n "; builder.download_component(base, &format!("{}/{}", url, filename), &tarball, help_on_error); </ins> } let llvm_root = builder.config.ci_llvm_root(); builder.unpack(&tarball, &llvm_root, "rust-dev");