Skip to content

Commit f8d3459

Browse files
committed
Auto merge of #53803 - pietroalbini:fix-manifest-2, r=alexcrichton
Fix manifests for broken tools: take 2 This is a follow up of #53715, to avoid stripping unavailable components from the extensions list. This time I also figured out how to test the changes, so the produced manifest is correct. Along with the fix I added a README with instructions on how to test the tool, and a new `BUILD_MANIFEST_DISABLE_SIGNING` env var to avoid dealing with gpg while testing the tool. I chose an env var instead of a flag because it's more difficult to have it slip in by accident on CI, and there is also another protection that panics if that env var is set on CI, just to be sure we don't release unsigned artifacts. r? @alexcrichton cc rust-lang/rustup#1486
2 parents 685fb54 + 38e2d00 commit f8d3459

File tree

2 files changed

+68
-7
lines changed

2 files changed

+68
-7
lines changed

src/tools/build-manifest/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# build-manifest
2+
3+
This tool generates the manifests uploaded to static.rust-lang.org and used by
4+
rustup. The tool is invoked by the bootstrap tool.
5+
6+
## Testing changes locally
7+
8+
In order to test the changes locally you need to have a valid dist directory
9+
available locally. If you don't want to build all the compiler, you can easily
10+
create one from the nightly artifacts with:
11+
12+
```
13+
#!/bin/bash
14+
for cmpn in rust rustc rust-std rust-docs cargo; do
15+
wget https://static.rust-lang.org/dist/${cmpn}-nightly-x86_64-unknown-linux-gnu.tar.gz
16+
done
17+
```
18+
19+
Then, you can generate the manifest and all the packages from `path/to/dist` to
20+
`path/to/output` with:
21+
22+
```
23+
$ BUILD_MANIFEST_DISABLE_SIGNING=1 cargo +nightly run \
24+
path/to/dist path/to/output 1970-01-01 \
25+
nightly nightly nightly nightly nightly nightly nightly \
26+
http://example.com
27+
```
28+
29+
In the future, if the tool complains about missing arguments just add more
30+
`nightly`s in the middle.

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

+38-7
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,17 @@ static TARGETS: &'static [&'static str] = &[
121121
"x86_64-unknown-redox",
122122
];
123123

124+
static DOCS_TARGETS: &'static [&'static str] = &[
125+
"i686-apple-darwin",
126+
"i686-pc-windows-gnu",
127+
"i686-pc-windows-msvc",
128+
"i686-unknown-linux-gnu",
129+
"x86_64-apple-darwin",
130+
"x86_64-pc-windows-gnu",
131+
"x86_64-pc-windows-msvc",
132+
"x86_64-unknown-linux-gnu",
133+
];
134+
124135
static MINGW: &'static [&'static str] = &[
125136
"i686-pc-windows-gnu",
126137
"x86_64-pc-windows-gnu",
@@ -216,9 +227,23 @@ struct Builder {
216227
rustfmt_git_commit_hash: Option<String>,
217228
llvm_tools_git_commit_hash: Option<String>,
218229
lldb_git_commit_hash: Option<String>,
230+
231+
should_sign: bool,
219232
}
220233

221234
fn main() {
235+
// Avoid signing packages while manually testing
236+
// Do NOT set this envvar in CI
237+
let should_sign = env::var("BUILD_MANIFEST_DISABLE_SIGNING").is_err();
238+
239+
// Safety check to ensure signing is always enabled on CI
240+
// The CI environment variable is set by both Travis and AppVeyor
241+
if !should_sign && env::var("CI").is_ok() {
242+
println!("The 'BUILD_MANIFEST_DISABLE_SIGNING' env var can't be enabled on CI.");
243+
println!("If you're not running this on CI, unset the 'CI' env var.");
244+
panic!();
245+
}
246+
222247
let mut args = env::args().skip(1);
223248
let input = PathBuf::from(args.next().unwrap());
224249
let output = PathBuf::from(args.next().unwrap());
@@ -231,8 +256,12 @@ fn main() {
231256
let llvm_tools_release = args.next().unwrap();
232257
let lldb_release = args.next().unwrap();
233258
let s3_address = args.next().unwrap();
259+
260+
// Do not ask for a passphrase while manually testing
234261
let mut passphrase = String::new();
235-
t!(io::stdin().read_to_string(&mut passphrase));
262+
if should_sign {
263+
t!(io::stdin().read_to_string(&mut passphrase));
264+
}
236265

237266
Builder {
238267
rust_release,
@@ -265,6 +294,8 @@ fn main() {
265294
rustfmt_git_commit_hash: None,
266295
llvm_tools_git_commit_hash: None,
267296
lldb_git_commit_hash: None,
297+
298+
should_sign,
268299
}.build();
269300
}
270301

@@ -318,7 +349,7 @@ impl Builder {
318349
self.package("cargo", &mut manifest.pkg, HOSTS);
319350
self.package("rust-mingw", &mut manifest.pkg, MINGW);
320351
self.package("rust-std", &mut manifest.pkg, TARGETS);
321-
self.package("rust-docs", &mut manifest.pkg, TARGETS);
352+
self.package("rust-docs", &mut manifest.pkg, DOCS_TARGETS);
322353
self.package("rust-src", &mut manifest.pkg, &["*"]);
323354
self.package("rls-preview", &mut manifest.pkg, HOSTS);
324355
self.package("clippy-preview", &mut manifest.pkg, HOSTS);
@@ -402,11 +433,7 @@ impl Builder {
402433
Some(p) => p,
403434
None => return false,
404435
};
405-
let target = match pkg.target.get(&c.target) {
406-
Some(t) => t,
407-
None => return false,
408-
};
409-
target.available
436+
pkg.target.get(&c.target).is_some()
410437
};
411438
extensions.retain(&has_component);
412439
components.retain(&has_component);
@@ -588,6 +615,10 @@ impl Builder {
588615
}
589616

590617
fn sign(&self, path: &Path) {
618+
if !self.should_sign {
619+
return;
620+
}
621+
591622
let filename = path.file_name().unwrap().to_str().unwrap();
592623
let asc = self.output.join(format!("{}.asc", filename));
593624
println!("signing: {:?}", path);

0 commit comments

Comments
 (0)