Skip to content

Commit d4928ad

Browse files
committed
build-manifest: keep legacy behavior when invoking through ./x.py dist
1 parent e05e2f9 commit d4928ad

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

src/bootstrap/dist.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2371,6 +2371,7 @@ impl Step for HashSign {
23712371
cmd.arg(addr);
23722372
cmd.arg(&builder.config.channel);
23732373
cmd.arg(&builder.src);
2374+
cmd.env("BUILD_MANIFEST_LEGACY", "1");
23742375

23752376
builder.create_dir(&distdir(builder));
23762377

src/tools/build-manifest/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ Then, you can generate the manifest and all the packages from `path/to/dist` to
2020
`path/to/output` with:
2121

2222
```
23-
$ BUILD_MANIFEST_DISABLE_SIGNING=1 cargo +nightly run \
24-
path/to/dist path/to/output 1970-01-01 http://example.com \
23+
$ cargo +nightly run path/to/dist path/to/output 1970-01-01 http://example.com \
2524
CHANNEL path/to/rust/repo
2625
```
2726

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

+19-18
Original file line numberDiff line numberDiff line change
@@ -232,26 +232,27 @@ struct Builder {
232232

233233
input: PathBuf,
234234
output: PathBuf,
235-
gpg_passphrase: String,
236235
digests: BTreeMap<String, String>,
237236
s3_address: String,
238237
date: String,
239238

240-
should_sign: bool,
239+
legacy: bool,
240+
legacy_gpg_passphrase: String,
241241
}
242242

243243
fn main() {
244-
// Avoid signing packages while manually testing
245-
// Do NOT set this envvar in CI
246-
let should_sign = env::var("BUILD_MANIFEST_DISABLE_SIGNING").is_err();
247-
248-
// Safety check to ensure signing is always enabled on CI
249-
// The CI environment variable is set by both Travis and AppVeyor
250-
if !should_sign && env::var("CI").is_ok() {
251-
println!("The 'BUILD_MANIFEST_DISABLE_SIGNING' env var can't be enabled on CI.");
252-
println!("If you're not running this on CI, unset the 'CI' env var.");
253-
panic!();
254-
}
244+
// Up until Rust 1.48 the release process relied on build-manifest to create the SHA256
245+
// checksums of released files and to sign the tarballs. That was moved over to promote-release
246+
// in time for the branching of Rust 1.48, but the old release process still had to work the
247+
// old way.
248+
//
249+
// When running build-manifest through the old ./x.py dist hash-and-sign the environment
250+
// variable will be set, enabling the legacy behavior of generating the .sha256 files and
251+
// signing the tarballs.
252+
//
253+
// Once the old release process is fully decommissioned, the environment variable, all the
254+
// related code in this tool and ./x.py dist hash-and-sign can be removed.
255+
let legacy = env::var("BUILD_MANIFEST_LEGACY").is_ok();
255256

256257
let mut args = env::args().skip(1);
257258
let input = PathBuf::from(args.next().unwrap());
@@ -263,7 +264,7 @@ fn main() {
263264

264265
// Do not ask for a passphrase while manually testing
265266
let mut passphrase = String::new();
266-
if should_sign {
267+
if legacy {
267268
// `x.py` passes the passphrase via stdin.
268269
t!(io::stdin().read_to_string(&mut passphrase));
269270
}
@@ -273,12 +274,12 @@ fn main() {
273274

274275
input,
275276
output,
276-
gpg_passphrase: passphrase,
277277
digests: BTreeMap::new(),
278278
s3_address,
279279
date,
280280

281-
should_sign,
281+
legacy,
282+
legacy_gpg_passphrase: passphrase,
282283
}
283284
.build();
284285
}
@@ -604,7 +605,7 @@ impl Builder {
604605
}
605606

606607
fn sign(&self, path: &Path) {
607-
if !self.should_sign {
608+
if !self.legacy {
608609
return;
609610
}
610611

@@ -627,7 +628,7 @@ impl Builder {
627628
.arg(path)
628629
.stdin(Stdio::piped());
629630
let mut child = t!(cmd.spawn());
630-
t!(child.stdin.take().unwrap().write_all(self.gpg_passphrase.as_bytes()));
631+
t!(child.stdin.take().unwrap().write_all(self.legacy_gpg_passphrase.as_bytes()));
631632
assert!(t!(child.wait()).success());
632633
}
633634

0 commit comments

Comments
 (0)