Skip to content

Commit 1661f77

Browse files
committed
Auto merge of rust-lang#77336 - pietroalbini:pkgname, r=Mark-Simulacrum
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 PR 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. r? `@Mark-Simulacrum`
2 parents 38d911d + 8d2b159 commit 1661f77

File tree

4 files changed

+11
-111
lines changed

4 files changed

+11
-111
lines changed

src/bootstrap/dist.rs

+1-18
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,7 @@ use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS};
2626
use time::{self, Timespec};
2727

2828
pub fn pkgname(builder: &Builder<'_>, component: &str) -> String {
29-
if component == "cargo" {
30-
format!("{}-{}", component, builder.cargo_package_vers())
31-
} else if component == "rls" {
32-
format!("{}-{}", component, builder.rls_package_vers())
33-
} else if component == "rust-analyzer" {
34-
format!("{}-{}", component, builder.rust_analyzer_package_vers())
35-
} else if component == "clippy" {
36-
format!("{}-{}", component, builder.clippy_package_vers())
37-
} else if component == "miri" {
38-
format!("{}-{}", component, builder.miri_package_vers())
39-
} else if component == "rustfmt" {
40-
format!("{}-{}", component, builder.rustfmt_package_vers())
41-
} else if component == "llvm-tools" {
42-
format!("{}-{}", component, builder.llvm_tools_package_vers())
43-
} else {
44-
assert!(component.starts_with("rust"));
45-
format!("{}-{}", component, builder.rust_package_vers())
46-
}
29+
format!("{}-{}", component, builder.rust_package_vers())
4730
}
4831

4932
pub(crate) fn distdir(builder: &Builder<'_>) -> PathBuf {

src/bootstrap/lib.rs

-34
Original file line numberDiff line numberDiff line change
@@ -1051,40 +1051,6 @@ impl Build {
10511051
self.package_vers(&self.version)
10521052
}
10531053

1054-
/// Returns the value of `package_vers` above for Cargo
1055-
fn cargo_package_vers(&self) -> String {
1056-
self.package_vers(&self.release_num("cargo"))
1057-
}
1058-
1059-
/// Returns the value of `package_vers` above for rls
1060-
fn rls_package_vers(&self) -> String {
1061-
self.package_vers(&self.release_num("rls"))
1062-
}
1063-
1064-
/// Returns the value of `package_vers` above for rust-analyzer
1065-
fn rust_analyzer_package_vers(&self) -> String {
1066-
self.package_vers(&self.release_num("rust-analyzer/crates/rust-analyzer"))
1067-
}
1068-
1069-
/// Returns the value of `package_vers` above for clippy
1070-
fn clippy_package_vers(&self) -> String {
1071-
self.package_vers(&self.release_num("clippy"))
1072-
}
1073-
1074-
/// Returns the value of `package_vers` above for miri
1075-
fn miri_package_vers(&self) -> String {
1076-
self.package_vers(&self.release_num("miri"))
1077-
}
1078-
1079-
/// Returns the value of `package_vers` above for rustfmt
1080-
fn rustfmt_package_vers(&self) -> String {
1081-
self.package_vers(&self.release_num("rustfmt"))
1082-
}
1083-
1084-
fn llvm_tools_package_vers(&self) -> String {
1085-
self.package_vers(&self.version)
1086-
}
1087-
10881054
fn llvm_tools_vers(&self) -> String {
10891055
self.rust_version()
10901056
}

src/tools/build-manifest/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ impl Builder {
252252
}
253253
let manifest = self.build_manifest();
254254

255-
let rust_version = self.versions.package_version(&PkgType::Rust).unwrap();
255+
let rust_version = self.versions.rustc_version();
256256
self.write_channel_files(self.versions.channel(), &manifest);
257257
if self.versions.channel() != rust_version {
258258
self.write_channel_files(&rust_version, &manifest);

src/tools/build-manifest/src/versions.rs

+9-58
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,6 @@ impl PkgType {
3838
}
3939
}
4040

41-
/// The directory containing the `Cargo.toml` of this component inside the monorepo, to
42-
/// retrieve the source code version. If `None` is returned Rust's version will be used.
43-
fn rust_monorepo_path(&self) -> Option<&'static str> {
44-
match self {
45-
PkgType::Cargo => Some("src/tools/cargo"),
46-
PkgType::Rls => Some("src/tools/rls"),
47-
PkgType::RustAnalyzer => Some("src/tools/rust-analyzer/crates/rust-analyzer"),
48-
PkgType::Clippy => Some("src/tools/clippy"),
49-
PkgType::Rustfmt => Some("src/tools/rustfmt"),
50-
PkgType::Miri => Some("src/tools/miri"),
51-
PkgType::Rust => None,
52-
PkgType::RustSrc => None,
53-
PkgType::LlvmTools => None,
54-
PkgType::Other(_) => None,
55-
}
56-
}
57-
5841
/// First part of the tarball name.
5942
fn tarball_component_name(&self) -> &str {
6043
match self {
@@ -105,9 +88,7 @@ pub(crate) struct VersionInfo {
10588
pub(crate) struct Versions {
10689
channel: String,
10790
rustc_version: String,
108-
monorepo_root: PathBuf,
10991
dist_path: PathBuf,
110-
package_versions: HashMap<PkgType, String>,
11192
versions: HashMap<PkgType, VersionInfo>,
11293
}
11394

@@ -123,9 +104,7 @@ impl Versions {
123104
.context("failed to read the rustc version from src/version")?
124105
.trim()
125106
.to_string(),
126-
monorepo_root: monorepo_root.into(),
127107
dist_path: dist_path.into(),
128-
package_versions: HashMap::new(),
129108
versions: HashMap::new(),
130109
})
131110
}
@@ -204,49 +183,21 @@ impl Versions {
204183
target: &str,
205184
) -> Result<String, Error> {
206185
let component_name = package.tarball_component_name();
207-
let version = self.package_version(package).with_context(|| {
208-
format!("failed to get the package version for component {:?}", package,)
209-
})?;
186+
let version = match self.channel.as_str() {
187+
"stable" => self.rustc_version.clone(),
188+
"beta" => "beta".into(),
189+
"nightly" => "nightly".into(),
190+
_ => format!("{}-dev", self.rustc_version),
191+
};
192+
210193
if package.target_independent() {
211194
Ok(format!("{}-{}.tar.gz", component_name, version))
212195
} else {
213196
Ok(format!("{}-{}-{}.tar.gz", component_name, version, target))
214197
}
215198
}
216199

217-
pub(crate) fn package_version(&mut self, package: &PkgType) -> Result<String, Error> {
218-
match self.package_versions.get(package) {
219-
Some(release) => Ok(release.clone()),
220-
None => {
221-
let version = match package.rust_monorepo_path() {
222-
Some(path) => {
223-
let path = self.monorepo_root.join(path).join("Cargo.toml");
224-
let cargo_toml: CargoToml = toml::from_slice(&std::fs::read(path)?)?;
225-
cargo_toml.package.version
226-
}
227-
None => self.rustc_version.clone(),
228-
};
229-
230-
let release = match self.channel.as_str() {
231-
"stable" => version,
232-
"beta" => "beta".into(),
233-
"nightly" => "nightly".into(),
234-
_ => format!("{}-dev", version),
235-
};
236-
237-
self.package_versions.insert(package.clone(), release.clone());
238-
Ok(release)
239-
}
240-
}
200+
pub(crate) fn rustc_version(&self) -> &str {
201+
&self.rustc_version
241202
}
242203
}
243-
244-
#[derive(serde::Deserialize)]
245-
struct CargoToml {
246-
package: CargoTomlPackage,
247-
}
248-
249-
#[derive(serde::Deserialize)]
250-
struct CargoTomlPackage {
251-
version: String,
252-
}

0 commit comments

Comments
 (0)