summaryrefslogtreecommitdiffstats
path: root/src/bootstrap/download.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /src/bootstrap/download.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/bootstrap/download.rs')
-rw-r--r--src/bootstrap/download.rs60
1 files changed, 40 insertions, 20 deletions
diff --git a/src/bootstrap/download.rs b/src/bootstrap/download.rs
index c7969d2a2..cb40521dd 100644
--- a/src/bootstrap/download.rs
+++ b/src/bootstrap/download.rs
@@ -7,6 +7,7 @@ use std::{
process::{Command, Stdio},
};
+use build_helper::util::try_run;
use once_cell::sync::OnceCell;
use xz2::bufread::XzDecoder;
@@ -14,7 +15,7 @@ use crate::{
config::RustfmtMetadata,
llvm::detect_llvm_sha,
t,
- util::{check_run, exe, program_out_of_date, try_run},
+ util::{check_run, exe, program_out_of_date},
Config,
};
@@ -53,9 +54,9 @@ impl Config {
/// Runs a command, printing out nice contextual information if it fails.
/// Exits if the command failed to execute at all, otherwise returns its
/// `status.success()`.
- pub(crate) fn try_run(&self, cmd: &mut Command) -> bool {
+ pub(crate) fn try_run(&self, cmd: &mut Command) -> Result<(), ()> {
if self.dry_run() {
- return true;
+ return Ok(());
}
self.verbose(&format!("running: {:?}", cmd));
try_run(cmd, self.is_verbose())
@@ -155,12 +156,14 @@ impl Config {
];
}
";
- nix_build_succeeded = self.try_run(Command::new("nix-build").args(&[
- Path::new("-E"),
- Path::new(NIX_EXPR),
- Path::new("-o"),
- &nix_deps_dir,
- ]));
+ nix_build_succeeded = self
+ .try_run(Command::new("nix-build").args(&[
+ Path::new("-E"),
+ Path::new(NIX_EXPR),
+ Path::new("-o"),
+ &nix_deps_dir,
+ ]))
+ .is_ok();
nix_deps_dir
});
if !nix_build_succeeded {
@@ -185,7 +188,7 @@ impl Config {
patchelf.args(&["--set-interpreter", dynamic_linker.trim_end()]);
}
- self.try_run(patchelf.arg(fname));
+ self.try_run(patchelf.arg(fname)).unwrap();
}
fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) {
@@ -236,7 +239,7 @@ impl Config {
"(New-Object System.Net.WebClient).DownloadFile('{}', '{}')",
url, tempfile.to_str().expect("invalid UTF-8 not supported with powershell downloads"),
),
- ])) {
+ ])).is_err() {
return;
}
eprintln!("\nspurious failure, trying again");
@@ -245,7 +248,7 @@ impl Config {
if !help_on_error.is_empty() {
eprintln!("{}", help_on_error);
}
- crate::detail_exit(1);
+ crate::detail_exit_macro!(1);
}
}
@@ -270,11 +273,8 @@ impl Config {
// `compile::Sysroot` needs to know the contents of the `rustc-dev` tarball to avoid adding
// it to the sysroot unless it was explicitly requested. But parsing the 100 MB tarball is slow.
// Cache the entries when we extract it so we only have to read it once.
- let mut recorded_entries = if dst.ends_with("ci-rustc") && pattern == "rustc-dev" {
- Some(BufWriter::new(t!(File::create(dst.join(".rustc-dev-contents")))))
- } else {
- None
- };
+ let mut recorded_entries =
+ if dst.ends_with("ci-rustc") { recorded_entries(dst, pattern) } else { None };
for member in t!(tar.entries()) {
let mut member = t!(member);
@@ -331,6 +331,17 @@ impl Config {
}
}
+fn recorded_entries(dst: &Path, pattern: &str) -> Option<BufWriter<File>> {
+ let name = if pattern == "rustc-dev" {
+ ".rustc-dev-contents"
+ } else if pattern.starts_with("rust-std") {
+ ".rust-std-contents"
+ } else {
+ return None;
+ };
+ Some(BufWriter::new(t!(File::create(dst.join(name)))))
+}
+
enum DownloadSource {
CI,
Dist,
@@ -381,11 +392,20 @@ impl Config {
Some(rustfmt_path)
}
- pub(crate) fn rustc_dev_contents(&self) -> Vec<String> {
+ pub(crate) fn ci_rust_std_contents(&self) -> Vec<String> {
+ self.ci_component_contents(".rust-std-contents")
+ }
+
+ pub(crate) fn ci_rustc_dev_contents(&self) -> Vec<String> {
+ self.ci_component_contents(".rustc-dev-contents")
+ }
+
+ fn ci_component_contents(&self, stamp_file: &str) -> Vec<String> {
assert!(self.download_rustc());
let ci_rustc_dir = self.out.join(&*self.build.triple).join("ci-rustc");
- let rustc_dev_contents_file = t!(File::open(ci_rustc_dir.join(".rustc-dev-contents")));
- t!(BufReader::new(rustc_dev_contents_file).lines().collect())
+ let stamp_file = ci_rustc_dir.join(stamp_file);
+ let contents_file = t!(File::open(&stamp_file), stamp_file.display().to_string());
+ t!(BufReader::new(contents_file).lines().collect())
}
pub(crate) fn download_ci_rustc(&self, commit: &str) {