Discover channel for artifact download

When we're downloading based on a CI commit, that can still be -beta- or even
-stable-, so we should lookup the channel it was built with.
This commit is contained in:
Mark Rousskov 2022-07-30 15:44:37 -04:00
parent 1202bbaf48
commit d63e982cd9
2 changed files with 13 additions and 6 deletions

View File

@ -1312,6 +1312,13 @@ impl Config {
git git
} }
pub(crate) fn artifact_channel(&self, commit: &str) -> String {
let mut channel = self.git();
channel.arg("show").arg(format!("{}:src/ci/channel", commit));
let channel = output(&mut channel);
channel.trim().to_owned()
}
/// Try to find the relative path of `bindir`, otherwise return it in full. /// Try to find the relative path of `bindir`, otherwise return it in full.
pub fn bindir_relative(&self) -> &Path { pub fn bindir_relative(&self) -> &Path {
let bindir = &self.bindir; let bindir = &self.bindir;
@ -1547,8 +1554,7 @@ fn maybe_download_rustfmt(builder: &Builder<'_>) -> Option<PathBuf> {
fn download_ci_rustc(builder: &Builder<'_>, commit: &str) { fn download_ci_rustc(builder: &Builder<'_>, commit: &str) {
builder.verbose(&format!("using downloaded stage2 artifacts from CI (commit {commit})")); builder.verbose(&format!("using downloaded stage2 artifacts from CI (commit {commit})"));
// FIXME: support downloading artifacts from the beta channel let channel = builder.config.artifact_channel(commit);
const CHANNEL: &str = "nightly";
let host = builder.config.build.triple; let host = builder.config.build.triple;
let bin_root = builder.out.join(host).join("ci-rustc"); let bin_root = builder.out.join(host).join("ci-rustc");
let rustc_stamp = bin_root.join(".rustc-stamp"); let rustc_stamp = bin_root.join(".rustc-stamp");
@ -1557,13 +1563,13 @@ fn download_ci_rustc(builder: &Builder<'_>, commit: &str) {
if bin_root.exists() { if bin_root.exists() {
t!(fs::remove_dir_all(&bin_root)); t!(fs::remove_dir_all(&bin_root));
} }
let filename = format!("rust-std-{CHANNEL}-{host}.tar.xz"); let filename = format!("rust-std-{channel}-{host}.tar.xz");
let pattern = format!("rust-std-{host}"); let pattern = format!("rust-std-{host}");
download_ci_component(builder, filename, &pattern, commit); download_ci_component(builder, filename, &pattern, commit);
let filename = format!("rustc-{CHANNEL}-{host}.tar.xz"); let filename = format!("rustc-{channel}-{host}.tar.xz");
download_ci_component(builder, filename, "rustc", commit); download_ci_component(builder, filename, "rustc", commit);
// download-rustc doesn't need its own cargo, it can just use beta's. // download-rustc doesn't need its own cargo, it can just use beta's.
let filename = format!("rustc-dev-{CHANNEL}-{host}.tar.xz"); let filename = format!("rustc-dev-{channel}-{host}.tar.xz");
download_ci_component(builder, filename, "rustc-dev", commit); download_ci_component(builder, filename, "rustc-dev", commit);
builder.fix_bin_or_dylib(&bin_root.join("bin").join("rustc")); builder.fix_bin_or_dylib(&bin_root.join("bin").join("rustc"));

View File

@ -189,7 +189,8 @@ fn download_ci_llvm(builder: &Builder<'_>, llvm_sha: &str) {
} else { } else {
&builder.config.stage0_metadata.config.artifacts_server &builder.config.stage0_metadata.config.artifacts_server
}; };
let filename = format!("rust-dev-nightly-{}.tar.xz", builder.build.build.triple); let channel = builder.config.artifact_channel(llvm_sha);
let filename = format!("rust-dev-{}-{}.tar.xz", channel, builder.build.build.triple);
let tarball = rustc_cache.join(&filename); let tarball = rustc_cache.join(&filename);
if !tarball.exists() { if !tarball.exists() {
let help_on_error = "error: failed to download llvm from ci let help_on_error = "error: failed to download llvm from ci