Skip to content

Commit 51777b1

Browse files
committed
Auto merge of #53715 - pietroalbini:missing-components-manifest, r=alexcrichton
Include missing tools in the manifest and mark them as unavailable This PR changes the `build-manifest` tool to always include the missing components in the manifest, marking them as `available = false`. This blocks rustup from updating to a different nightly if the component is installed. The code builds and _should_ be correct, but I don't know a way to test the changes locally. r? @alexcrichton cc @kennytm rust-lang/rustup#1486
2 parents 7219130 + dc03139 commit 51777b1

File tree

1 file changed

+46
-66
lines changed
  • src/tools/build-manifest/src

1 file changed

+46
-66
lines changed

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

+46-66
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,7 @@ impl Builder {
324324
self.package("llvm-tools-preview", &mut manifest.pkg, TARGETS);
325325
self.package("lldb-preview", &mut manifest.pkg, TARGETS);
326326

327-
let clippy_present = manifest.pkg.contains_key("clippy-preview");
328-
let rls_present = manifest.pkg.contains_key("rls-preview");
329-
let rustfmt_present = manifest.pkg.contains_key("rustfmt-preview");
330-
let llvm_tools_present = manifest.pkg.contains_key("llvm-tools-preview");
331-
let lldb_present = manifest.pkg.contains_key("lldb-preview");
332-
333-
if rls_present {
334-
manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() });
335-
}
327+
manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() });
336328

337329
let mut pkg = Package {
338330
version: self.cached_version("rust")
@@ -371,40 +363,17 @@ impl Builder {
371363
});
372364
}
373365

374-
if clippy_present {
375-
extensions.push(Component {
376-
pkg: "clippy-preview".to_string(),
377-
target: host.to_string(),
378-
});
379-
}
380-
if rls_present {
381-
extensions.push(Component {
382-
pkg: "rls-preview".to_string(),
383-
target: host.to_string(),
384-
});
385-
}
386-
if rustfmt_present {
387-
extensions.push(Component {
388-
pkg: "rustfmt-preview".to_string(),
389-
target: host.to_string(),
390-
});
391-
}
392-
if llvm_tools_present {
393-
extensions.push(Component {
394-
pkg: "llvm-tools-preview".to_string(),
395-
target: host.to_string(),
396-
});
397-
}
398-
if lldb_present {
399-
extensions.push(Component {
400-
pkg: "lldb-preview".to_string(),
401-
target: host.to_string(),
402-
});
403-
}
404-
extensions.push(Component {
405-
pkg: "rust-analysis".to_string(),
406-
target: host.to_string(),
407-
});
366+
// Tools are always present in the manifest, but might be marked as unavailable if they
367+
// weren't built
368+
extensions.extend(vec![
369+
Component { pkg: "clippy-preview".to_string(), target: host.to_string() },
370+
Component { pkg: "rls-preview".to_string(), target: host.to_string() },
371+
Component { pkg: "rustfmt-preview".to_string(), target: host.to_string() },
372+
Component { pkg: "llvm-tools-preview".to_string(), target: host.to_string() },
373+
Component { pkg: "lldb-preview".to_string(), target: host.to_string() },
374+
Component { pkg: "rust-analysis".to_string(), target: host.to_string() },
375+
]);
376+
408377
for target in TARGETS {
409378
if target != host {
410379
extensions.push(Component {
@@ -459,32 +428,43 @@ impl Builder {
459428
pkgname: &str,
460429
dst: &mut BTreeMap<String, Package>,
461430
targets: &[&str]) {
462-
let version = match *self.cached_version(pkgname) {
463-
Some(ref version) => version.clone(),
464-
None => {
465-
println!("Skipping package {}", pkgname);
466-
return;
467-
}
431+
let (version, is_present) = match *self.cached_version(pkgname) {
432+
Some(ref version) => (version.clone(), true),
433+
None => (String::new(), false),
468434
};
469435

470436
let targets = targets.iter().map(|name| {
471-
let filename = self.filename(pkgname, name);
472-
let digest = match self.digests.remove(&filename) {
473-
Some(digest) => digest,
474-
None => return (name.to_string(), Target::unavailable()),
475-
};
476-
let xz_filename = filename.replace(".tar.gz", ".tar.xz");
477-
let xz_digest = self.digests.remove(&xz_filename);
478-
479-
(name.to_string(), Target {
480-
available: true,
481-
url: Some(self.url(&filename)),
482-
hash: Some(digest),
483-
xz_url: xz_digest.as_ref().map(|_| self.url(&xz_filename)),
484-
xz_hash: xz_digest,
485-
components: None,
486-
extensions: None,
487-
})
437+
if is_present {
438+
let filename = self.filename(pkgname, name);
439+
let digest = match self.digests.remove(&filename) {
440+
Some(digest) => digest,
441+
None => return (name.to_string(), Target::unavailable()),
442+
};
443+
let xz_filename = filename.replace(".tar.gz", ".tar.xz");
444+
let xz_digest = self.digests.remove(&xz_filename);
445+
446+
(name.to_string(), Target {
447+
available: true,
448+
url: Some(self.url(&filename)),
449+
hash: Some(digest),
450+
xz_url: xz_digest.as_ref().map(|_| self.url(&xz_filename)),
451+
xz_hash: xz_digest,
452+
components: None,
453+
extensions: None,
454+
})
455+
} else {
456+
// If the component is not present for this build add it anyway but mark it as
457+
// unavailable -- this way rustup won't allow upgrades without --force
458+
(name.to_string(), Target {
459+
available: false,
460+
url: None,
461+
hash: None,
462+
xz_url: None,
463+
xz_hash: None,
464+
components: None,
465+
extensions: None,
466+
})
467+
}
488468
}).collect();
489469

490470
dst.insert(pkgname.to_string(), Package {

0 commit comments

Comments
 (0)