From 8d2b15943b0dad58959f5fcac1664bfdd7c201b7 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Tue, 29 Sep 2020 15:33:25 +0200 Subject: [PATCH] bootstrap: always use the Rust version in package names The format of the tarballs produced by CI is roughly the following: {component}-{release}-{target}.{ext} While on the beta and nightly channels `{release}` is just the channel name, on the stable channel is either the Rust version or the version of the component we're shipping: cargo-0.47.0-x86_64-unknown-linux-gnu.tar.xz clippy-0.0.212-x86_64-unknown-linux-gnu.tar.xz llvm-tools-1.46.0-x86_64-unknown-linux-gnu.tar.xz miri-0.1.0-x86_64-unknown-linux-gnu.tar.xz rls-1.41.0-x86_64-unknown-linux-gnu.tar.xz rust-1.46.0-x86_64-unknown-linux-gnu.tar.xz ... This makes it really hard to get the package URL without having access to the manifest (and there is no manifest on ci-artifacts.rlo), as there is no consistent version number to use. This commit addresses the problem by always using the Rust version number as `{release}` for the stable channel, regardless of the version number of the component we're shipping. I chose that instead of "stable" to avoid breaking the URL scheme *that* much. Rustup should not be affected by this change, as it fetches the URLs from the manifest. Unfortunately we don't have a way to test other clients before making a stable release, as this change only affects the stable channel. --- src/bootstrap/dist.rs | 19 +------ src/bootstrap/lib.rs | 34 ------------ src/tools/build-manifest/src/main.rs | 2 +- src/tools/build-manifest/src/versions.rs | 67 ++++-------------------- 4 files changed, 11 insertions(+), 111 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 857e06d846de4..3a0743da7a415 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -26,24 +26,7 @@ use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS}; use time::{self, Timespec}; pub fn pkgname(builder: &Builder<'_>, component: &str) -> String { - if component == "cargo" { - format!("{}-{}", component, builder.cargo_package_vers()) - } else if component == "rls" { - format!("{}-{}", component, builder.rls_package_vers()) - } else if component == "rust-analyzer" { - format!("{}-{}", component, builder.rust_analyzer_package_vers()) - } else if component == "clippy" { - format!("{}-{}", component, builder.clippy_package_vers()) - } else if component == "miri" { - format!("{}-{}", component, builder.miri_package_vers()) - } else if component == "rustfmt" { - format!("{}-{}", component, builder.rustfmt_package_vers()) - } else if component == "llvm-tools" { - format!("{}-{}", component, builder.llvm_tools_package_vers()) - } else { - assert!(component.starts_with("rust")); - format!("{}-{}", component, builder.rust_package_vers()) - } + format!("{}-{}", component, builder.rust_package_vers()) } pub(crate) fn distdir(builder: &Builder<'_>) -> PathBuf { diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 147bcf30709f9..bf81c4bf28e37 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -1051,40 +1051,6 @@ impl Build { self.package_vers(&self.version) } - /// Returns the value of `package_vers` above for Cargo - fn cargo_package_vers(&self) -> String { - self.package_vers(&self.release_num("cargo")) - } - - /// Returns the value of `package_vers` above for rls - fn rls_package_vers(&self) -> String { - self.package_vers(&self.release_num("rls")) - } - - /// Returns the value of `package_vers` above for rust-analyzer - fn rust_analyzer_package_vers(&self) -> String { - self.package_vers(&self.release_num("rust-analyzer/crates/rust-analyzer")) - } - - /// Returns the value of `package_vers` above for clippy - fn clippy_package_vers(&self) -> String { - self.package_vers(&self.release_num("clippy")) - } - - /// Returns the value of `package_vers` above for miri - fn miri_package_vers(&self) -> String { - self.package_vers(&self.release_num("miri")) - } - - /// Returns the value of `package_vers` above for rustfmt - fn rustfmt_package_vers(&self) -> String { - self.package_vers(&self.release_num("rustfmt")) - } - - fn llvm_tools_package_vers(&self) -> String { - self.package_vers(&self.version) - } - fn llvm_tools_vers(&self) -> String { self.rust_version() } diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index c7e7d88c68fa8..b35f3a595fb38 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -252,7 +252,7 @@ impl Builder { } let manifest = self.build_manifest(); - let rust_version = self.versions.package_version(&PkgType::Rust).unwrap(); + let rust_version = self.versions.rustc_version(); self.write_channel_files(self.versions.channel(), &manifest); if self.versions.channel() != rust_version { self.write_channel_files(&rust_version, &manifest); diff --git a/src/tools/build-manifest/src/versions.rs b/src/tools/build-manifest/src/versions.rs index d949dff72798b..75b6979b54a78 100644 --- a/src/tools/build-manifest/src/versions.rs +++ b/src/tools/build-manifest/src/versions.rs @@ -38,23 +38,6 @@ impl PkgType { } } - /// The directory containing the `Cargo.toml` of this component inside the monorepo, to - /// retrieve the source code version. If `None` is returned Rust's version will be used. - fn rust_monorepo_path(&self) -> Option<&'static str> { - match self { - PkgType::Cargo => Some("src/tools/cargo"), - PkgType::Rls => Some("src/tools/rls"), - PkgType::RustAnalyzer => Some("src/tools/rust-analyzer/crates/rust-analyzer"), - PkgType::Clippy => Some("src/tools/clippy"), - PkgType::Rustfmt => Some("src/tools/rustfmt"), - PkgType::Miri => Some("src/tools/miri"), - PkgType::Rust => None, - PkgType::RustSrc => None, - PkgType::LlvmTools => None, - PkgType::Other(_) => None, - } - } - /// First part of the tarball name. fn tarball_component_name(&self) -> &str { match self { @@ -105,9 +88,7 @@ pub(crate) struct VersionInfo { pub(crate) struct Versions { channel: String, rustc_version: String, - monorepo_root: PathBuf, dist_path: PathBuf, - package_versions: HashMap, versions: HashMap, } @@ -123,9 +104,7 @@ impl Versions { .context("failed to read the rustc version from src/version")? .trim() .to_string(), - monorepo_root: monorepo_root.into(), dist_path: dist_path.into(), - package_versions: HashMap::new(), versions: HashMap::new(), }) } @@ -204,9 +183,13 @@ impl Versions { target: &str, ) -> Result { let component_name = package.tarball_component_name(); - let version = self.package_version(package).with_context(|| { - format!("failed to get the package version for component {:?}", package,) - })?; + let version = match self.channel.as_str() { + "stable" => self.rustc_version.clone(), + "beta" => "beta".into(), + "nightly" => "nightly".into(), + _ => format!("{}-dev", self.rustc_version), + }; + if package.target_independent() { Ok(format!("{}-{}.tar.gz", component_name, version)) } else { @@ -214,39 +197,7 @@ impl Versions { } } - pub(crate) fn package_version(&mut self, package: &PkgType) -> Result { - match self.package_versions.get(package) { - Some(release) => Ok(release.clone()), - None => { - let version = match package.rust_monorepo_path() { - Some(path) => { - let path = self.monorepo_root.join(path).join("Cargo.toml"); - let cargo_toml: CargoToml = toml::from_slice(&std::fs::read(path)?)?; - cargo_toml.package.version - } - None => self.rustc_version.clone(), - }; - - let release = match self.channel.as_str() { - "stable" => version, - "beta" => "beta".into(), - "nightly" => "nightly".into(), - _ => format!("{}-dev", version), - }; - - self.package_versions.insert(package.clone(), release.clone()); - Ok(release) - } - } + pub(crate) fn rustc_version(&self) -> &str { + &self.rustc_version } } - -#[derive(serde::Deserialize)] -struct CargoToml { - package: CargoTomlPackage, -} - -#[derive(serde::Deserialize)] -struct CargoTomlPackage { - version: String, -}