1 //! Build a dist manifest, hash and sign everything.
2 //! This gets called by `promote-release`
3 //! (https://github.com/rust-lang/rust-central-station/tree/master/promote-release)
4 //! via `x.py dist hash-and-sign`; the cmdline arguments are set up
5 //! by rustbuild (in `src/bootstrap/dist.rs`).
12 use std
::collections
::BTreeMap
;
14 use std
::fs
::{self, File}
;
15 use std
::io
::{self, Read, Write}
;
16 use std
::path
::{PathBuf, Path}
;
17 use std
::process
::{Command, Stdio}
;
18 use std
::collections
::HashMap
;
20 static HOSTS
: &[&str] = &[
21 "aarch64-unknown-linux-gnu",
22 "arm-unknown-linux-gnueabi",
23 "arm-unknown-linux-gnueabihf",
24 "armv7-unknown-linux-gnueabihf",
26 "i686-pc-windows-gnu",
27 "i686-pc-windows-msvc",
28 "i686-unknown-linux-gnu",
29 "mips-unknown-linux-gnu",
30 "mips64-unknown-linux-gnuabi64",
31 "mips64el-unknown-linux-gnuabi64",
32 "mipsel-unknown-linux-gnu",
33 "mipsisa32r6-unknown-linux-gnu",
34 "mipsisa32r6el-unknown-linux-gnu",
35 "mipsisa64r6-unknown-linux-gnuabi64",
36 "mipsisa64r6el-unknown-linux-gnuabi64",
37 "powerpc-unknown-linux-gnu",
38 "powerpc64-unknown-linux-gnu",
39 "powerpc64le-unknown-linux-gnu",
40 "s390x-unknown-linux-gnu",
41 "x86_64-apple-darwin",
42 "x86_64-pc-windows-gnu",
43 "x86_64-pc-windows-msvc",
44 "x86_64-unknown-freebsd",
45 "x86_64-unknown-linux-gnu",
46 "x86_64-unknown-linux-musl",
47 "x86_64-unknown-netbsd",
50 static TARGETS
: &[&str] = &[
53 "aarch64-linux-android",
54 "aarch64-pc-windows-msvc",
55 "aarch64-unknown-cloudabi",
56 "aarch64-unknown-hermit",
57 "aarch64-unknown-linux-gnu",
58 "aarch64-unknown-linux-musl",
59 "aarch64-unknown-redox",
60 "arm-linux-androideabi",
61 "arm-unknown-linux-gnueabi",
62 "arm-unknown-linux-gnueabihf",
63 "arm-unknown-linux-musleabi",
64 "arm-unknown-linux-musleabihf",
65 "armv5te-unknown-linux-gnueabi",
66 "armv5te-unknown-linux-musleabi",
68 "armv7-linux-androideabi",
69 "thumbv7neon-linux-androideabi",
70 "armv7-unknown-linux-gnueabi",
71 "armv7-unknown-linux-gnueabihf",
72 "thumbv7neon-unknown-linux-gnueabihf",
73 "armv7-unknown-linux-musleabi",
74 "armv7-unknown-linux-musleabihf",
76 "armebv7r-none-eabihf",
80 "asmjs-unknown-emscripten",
82 "i586-pc-windows-msvc",
83 "i586-unknown-linux-gnu",
84 "i586-unknown-linux-musl",
87 "i686-pc-windows-gnu",
88 "i686-pc-windows-msvc",
89 "i686-unknown-freebsd",
90 "i686-unknown-linux-gnu",
91 "i686-unknown-linux-musl",
92 "mips-unknown-linux-gnu",
93 "mips-unknown-linux-musl",
94 "mips64-unknown-linux-gnuabi64",
95 "mips64-unknown-linux-muslabi64",
96 "mips64el-unknown-linux-gnuabi64",
97 "mips64el-unknown-linux-muslabi64",
98 "mipsisa32r6-unknown-linux-gnu",
99 "mipsisa32r6el-unknown-linux-gnu",
100 "mipsisa64r6-unknown-linux-gnuabi64",
101 "mipsisa64r6el-unknown-linux-gnuabi64",
102 "mipsel-unknown-linux-gnu",
103 "mipsel-unknown-linux-musl",
104 "nvptx64-nvidia-cuda",
105 "powerpc-unknown-linux-gnu",
106 "powerpc64-unknown-linux-gnu",
107 "powerpc64le-unknown-linux-gnu",
108 "riscv32i-unknown-none-elf",
109 "riscv32imc-unknown-none-elf",
110 "riscv32imac-unknown-none-elf",
111 "riscv64imac-unknown-none-elf",
112 "riscv64gc-unknown-none-elf",
113 "s390x-unknown-linux-gnu",
114 "sparc64-unknown-linux-gnu",
115 "sparcv9-sun-solaris",
116 "thumbv6m-none-eabi",
117 "thumbv7em-none-eabi",
118 "thumbv7em-none-eabihf",
119 "thumbv7m-none-eabi",
120 "thumbv8m.base-none-eabi",
121 "thumbv8m.main-none-eabi",
122 "thumbv8m.main-none-eabihf",
123 "wasm32-unknown-emscripten",
124 "wasm32-unknown-unknown",
126 "x86_64-apple-darwin",
128 "x86_64-fortanix-unknown-sgx",
130 "x86_64-linux-android",
131 "x86_64-pc-windows-gnu",
132 "x86_64-pc-windows-msvc",
133 "x86_64-rumprun-netbsd",
134 "x86_64-sun-solaris",
136 "x86_64-unknown-cloudabi",
137 "x86_64-unknown-freebsd",
138 "x86_64-unknown-linux-gnu",
139 "x86_64-unknown-linux-gnux32",
140 "x86_64-unknown-linux-musl",
141 "x86_64-unknown-netbsd",
142 "x86_64-unknown-redox",
143 "x86_64-unknown-hermit",
146 static DOCS_TARGETS
: &[&str] = &[
148 "i686-pc-windows-gnu",
149 "i686-pc-windows-msvc",
150 "i686-unknown-linux-gnu",
151 "x86_64-apple-darwin",
152 "x86_64-pc-windows-gnu",
153 "x86_64-pc-windows-msvc",
154 "x86_64-unknown-linux-gnu",
157 static MINGW
: &[&str] = &[
158 "i686-pc-windows-gnu",
159 "x86_64-pc-windows-gnu",
163 #[serde(rename_all = "kebab-case")]
165 manifest_version
: String
,
167 pkg
: BTreeMap
<String
, Package
>,
168 renames
: BTreeMap
<String
, Rename
>,
169 profiles
: BTreeMap
<String
, Vec
<String
>>,
175 git_commit_hash
: Option
<String
>,
176 target
: BTreeMap
<String
, Target
>,
184 #[derive(Serialize, Default)]
188 hash
: Option
<String
>,
189 xz_url
: Option
<String
>,
190 xz_hash
: Option
<String
>,
191 components
: Option
<Vec
<Component
>>,
192 extensions
: Option
<Vec
<Component
>>,
196 fn unavailable() -> Self { Self::default() }
206 fn from_str(pkg
: &str, target
: &str) -> Self {
207 Self { pkg: pkg.to_string(), target: target.to_string() }
212 ($e
:expr
) => (match $e
{
214 Err(e
) => panic
!("{} failed with {}", stringify
!($e
), e
),
219 rust_release
: String
,
220 cargo_release
: String
,
222 clippy_release
: String
,
223 rustfmt_release
: String
,
224 llvm_tools_release
: String
,
225 lldb_release
: String
,
226 miri_release
: String
,
230 gpg_passphrase
: String
,
231 digests
: BTreeMap
<String
, String
>,
235 rust_version
: Option
<String
>,
236 cargo_version
: Option
<String
>,
237 rls_version
: Option
<String
>,
238 clippy_version
: Option
<String
>,
239 rustfmt_version
: Option
<String
>,
240 llvm_tools_version
: Option
<String
>,
241 lldb_version
: Option
<String
>,
242 miri_version
: Option
<String
>,
244 rust_git_commit_hash
: Option
<String
>,
245 cargo_git_commit_hash
: Option
<String
>,
246 rls_git_commit_hash
: Option
<String
>,
247 clippy_git_commit_hash
: Option
<String
>,
248 rustfmt_git_commit_hash
: Option
<String
>,
249 llvm_tools_git_commit_hash
: Option
<String
>,
250 lldb_git_commit_hash
: Option
<String
>,
251 miri_git_commit_hash
: Option
<String
>,
257 // Avoid signing packages while manually testing
258 // Do NOT set this envvar in CI
259 let should_sign
= env
::var("BUILD_MANIFEST_DISABLE_SIGNING").is_err();
261 // Safety check to ensure signing is always enabled on CI
262 // The CI environment variable is set by both Travis and AppVeyor
263 if !should_sign
&& env
::var("CI").is_ok() {
264 println
!("The 'BUILD_MANIFEST_DISABLE_SIGNING' env var can't be enabled on CI.");
265 println
!("If you're not running this on CI, unset the 'CI' env var.");
269 let mut args
= env
::args().skip(1);
270 let input
= PathBuf
::from(args
.next().unwrap());
271 let output
= PathBuf
::from(args
.next().unwrap());
272 let date
= args
.next().unwrap();
273 let rust_release
= args
.next().unwrap();
274 let s3_address
= args
.next().unwrap();
275 let cargo_release
= args
.next().unwrap();
276 let rls_release
= args
.next().unwrap();
277 let clippy_release
= args
.next().unwrap();
278 let miri_release
= args
.next().unwrap();
279 let rustfmt_release
= args
.next().unwrap();
280 let llvm_tools_release
= args
.next().unwrap();
281 let lldb_release
= args
.next().unwrap();
283 // Do not ask for a passphrase while manually testing
284 let mut passphrase
= String
::new();
286 // `x.py` passes the passphrase via stdin.
287 t
!(io
::stdin().read_to_string(&mut passphrase
));
302 gpg_passphrase
: passphrase
,
303 digests
: BTreeMap
::new(),
310 clippy_version
: None
,
311 rustfmt_version
: None
,
312 llvm_tools_version
: None
,
316 rust_git_commit_hash
: None
,
317 cargo_git_commit_hash
: None
,
318 rls_git_commit_hash
: None
,
319 clippy_git_commit_hash
: None
,
320 rustfmt_git_commit_hash
: None
,
321 llvm_tools_git_commit_hash
: None
,
322 lldb_git_commit_hash
: None
,
323 miri_git_commit_hash
: None
,
329 enum PkgType { RustSrc, Cargo, Rls, Clippy, Rustfmt, LlvmTools, Lldb, Miri, Other }
332 fn from_component(component
: &str) -> Self {
335 "rust-src" => RustSrc
,
337 "rls" | "rls-preview" => Rls
,
338 "clippy" | "clippy-preview" => Clippy
,
339 "rustfmt" | "rustfmt-preview" => Rustfmt
,
340 "llvm-tools" | "llvm-tools-preview" => LlvmTools
,
341 "lldb" | "lldb-preview" => Lldb
,
342 "miri" | "miri-preview" => Miri
,
349 fn build(&mut self) {
350 self.rust_version
= self.version("rust", "x86_64-unknown-linux-gnu");
351 self.cargo_version
= self.version("cargo", "x86_64-unknown-linux-gnu");
352 self.rls_version
= self.version("rls", "x86_64-unknown-linux-gnu");
353 self.clippy_version
= self.version("clippy", "x86_64-unknown-linux-gnu");
354 self.rustfmt_version
= self.version("rustfmt", "x86_64-unknown-linux-gnu");
355 self.llvm_tools_version
= self.version("llvm-tools", "x86_64-unknown-linux-gnu");
356 // lldb is only built for macOS.
357 self.lldb_version
= self.version("lldb", "x86_64-apple-darwin");
358 self.miri_version
= self.version("miri", "x86_64-unknown-linux-gnu");
360 self.rust_git_commit_hash
= self.git_commit_hash("rust", "x86_64-unknown-linux-gnu");
361 self.cargo_git_commit_hash
= self.git_commit_hash("cargo", "x86_64-unknown-linux-gnu");
362 self.rls_git_commit_hash
= self.git_commit_hash("rls", "x86_64-unknown-linux-gnu");
363 self.clippy_git_commit_hash
= self.git_commit_hash("clippy", "x86_64-unknown-linux-gnu");
364 self.rustfmt_git_commit_hash
= self.git_commit_hash("rustfmt", "x86_64-unknown-linux-gnu");
365 self.llvm_tools_git_commit_hash
= self.git_commit_hash("llvm-tools",
366 "x86_64-unknown-linux-gnu");
367 self.lldb_git_commit_hash
= self.git_commit_hash("lldb", "x86_64-unknown-linux-gnu");
368 self.miri_git_commit_hash
= self.git_commit_hash("miri", "x86_64-unknown-linux-gnu");
370 self.check_toolstate();
371 self.digest_and_sign();
372 let manifest
= self.build_manifest();
373 self.write_channel_files(&self.rust_release
, &manifest
);
375 if self.rust_release
!= "beta" && self.rust_release
!= "nightly" {
376 self.write_channel_files("stable", &manifest
);
380 /// If a tool does not pass its tests, don't ship it.
381 /// Right now, we do this only for Miri.
382 fn check_toolstate(&mut self) {
383 let toolstates
: Option
<HashMap
<String
, String
>> =
384 File
::open(self.input
.join("toolstates-linux.json")).ok()
385 .and_then(|f
| serde_json
::from_reader(&f
).ok());
386 let toolstates
= toolstates
.unwrap_or_else(|| {
387 println
!("WARNING: `toolstates-linux.json` missing/malformed; \
388 assuming all tools failed");
389 HashMap
::default() // Use empty map if anything went wrong.
391 // Mark some tools as missing based on toolstate.
392 if toolstates
.get("miri").map(|s
| &*s
as &str) != Some("test-pass") {
393 println
!("Miri tests are not passing, removing component");
394 self.miri_version
= None
;
395 self.miri_git_commit_hash
= None
;
399 /// Hash all files, compute their signatures, and collect the hashes in `self.digests`.
400 fn digest_and_sign(&mut self) {
401 for file
in t
!(self.input
.read_dir()).map(|e
| t
!(e
).path()) {
402 let filename
= file
.file_name().unwrap().to_str().unwrap();
403 let digest
= self.hash(&file
);
405 assert
!(self.digests
.insert(filename
.to_string(), digest
).is_none());
409 fn build_manifest(&mut self) -> Manifest
{
410 let mut manifest
= Manifest
{
411 manifest_version
: "2".to_string(),
412 date
: self.date
.to_string(),
413 pkg
: BTreeMap
::new(),
414 renames
: BTreeMap
::new(),
415 profiles
: BTreeMap
::new(),
417 self.add_packages_to(&mut manifest
);
418 self.add_profiles_to(&mut manifest
);
419 self.add_renames_to(&mut manifest
);
420 manifest
.pkg
.insert("rust".to_string(), self.rust_package(&manifest
));
424 fn add_packages_to(&mut self, manifest
: &mut Manifest
) {
425 let mut package
= |name
, targets
| self.package(name
, &mut manifest
.pkg
, targets
);
426 package("rustc", HOSTS
);
427 package("rustc-dev", HOSTS
);
428 package("cargo", HOSTS
);
429 package("rust-mingw", MINGW
);
430 package("rust-std", TARGETS
);
431 package("rust-docs", DOCS_TARGETS
);
432 package("rust-src", &["*"]);
433 package("rls-preview", HOSTS
);
434 package("clippy-preview", HOSTS
);
435 package("miri-preview", HOSTS
);
436 package("rustfmt-preview", HOSTS
);
437 package("rust-analysis", TARGETS
);
438 package("llvm-tools-preview", TARGETS
);
439 package("lldb-preview", TARGETS
);
442 fn add_profiles_to(&mut self, manifest
: &mut Manifest
) {
443 let mut profile
= |name
, pkgs
| self.profile(name
, &mut manifest
.profiles
, pkgs
);
444 profile("minimal", &["rustc", "cargo", "rust-std", "rust-mingw"]);
445 profile("default", &[
446 "rustc", "cargo", "rust-std", "rust-mingw",
447 "rust-docs", "rustfmt-preview", "clippy-preview"
449 profile("complete", &[
450 "rustc", "cargo", "rust-std", "rust-mingw",
451 "rust-docs", "rustfmt-preview", "clippy-preview",
452 "rls-preview", "rust-src", "llvm-tools-preview",
453 "lldb-preview", "rust-analysis", "miri-preview"
456 // The compiler libraries are not stable for end users, but `rustc-dev` was only recently
457 // split out of `rust-std`. We'll include it by default as a transition for nightly users.
458 if self.rust_release
== "nightly" {
459 self.extend_profile("default", &mut manifest
.profiles
, &["rustc-dev"]);
460 self.extend_profile("complete", &mut manifest
.profiles
, &["rustc-dev"]);
464 fn add_renames_to(&self, manifest
: &mut Manifest
) {
465 let mut rename
= |from
: &str, to
: &str| manifest
.renames
.insert(
467 Rename { to: to.to_owned() }
469 rename("rls", "rls-preview");
470 rename("rustfmt", "rustfmt-preview");
471 rename("clippy", "clippy-preview");
472 rename("miri", "miri-preview");
475 fn rust_package(&mut self, manifest
: &Manifest
) -> Package
{
476 let mut pkg
= Package
{
477 version
: self.cached_version("rust")
479 .expect("Couldn't find Rust version")
481 git_commit_hash
: self.cached_git_commit_hash("rust").clone(),
482 target
: BTreeMap
::new(),
485 if let Some(target
) = self.target_host_combination(host
, &manifest
) {
486 pkg
.target
.insert(host
.to_string(), target
);
488 pkg
.target
.insert(host
.to_string(), Target
::unavailable());
495 fn target_host_combination(&mut self, host
: &str, manifest
: &Manifest
) -> Option
<Target
> {
496 let filename
= self.filename("rust", host
);
497 let digest
= self.digests
.remove(&filename
)?
;
498 let xz_filename
= filename
.replace(".tar.gz", ".tar.xz");
499 let xz_digest
= self.digests
.remove(&xz_filename
);
500 let mut components
= Vec
::new();
501 let mut extensions
= Vec
::new();
503 let host_component
= |pkg
| Component
::from_str(pkg
, host
);
505 // rustc/rust-std/cargo/docs are all required,
506 // and so is rust-mingw if it's available for the target.
507 components
.extend(vec
![
508 host_component("rustc"),
509 host_component("rust-std"),
510 host_component("cargo"),
511 host_component("rust-docs"),
513 if host
.contains("pc-windows-gnu") {
514 components
.push(host_component("rust-mingw"));
517 // The compiler libraries are not stable for end users, but `rustc-dev` was only recently
518 // split out of `rust-std`. We'll include it by default as a transition for nightly users,
519 // but ship it as an optional component on the beta and stable channels.
520 if self.rust_release
== "nightly" {
521 components
.push(host_component("rustc-dev"));
523 extensions
.push(host_component("rustc-dev"));
526 // Tools are always present in the manifest,
527 // but might be marked as unavailable if they weren't built.
528 extensions
.extend(vec
![
529 host_component("clippy-preview"),
530 host_component("miri-preview"),
531 host_component("rls-preview"),
532 host_component("rustfmt-preview"),
533 host_component("llvm-tools-preview"),
534 host_component("lldb-preview"),
535 host_component("rust-analysis"),
540 .filter(|&&target
| target
!= host
)
541 .map(|target
| Component
::from_str("rust-std", target
))
545 .filter(|&&target
| target
!= host
)
546 .map(|target
| Component
::from_str("rustc-dev", target
))
548 extensions
.push(Component
::from_str("rust-src", "*"));
550 // If the components/extensions don't actually exist for this
551 // particular host/target combination then nix it entirely from our
553 let has_component
= |c
: &Component
| {
557 let pkg
= match manifest
.pkg
.get(&c
.pkg
) {
559 None
=> return false,
561 pkg
.target
.get(&c
.target
).is_some()
563 extensions
.retain(&has_component
);
564 components
.retain(&has_component
);
568 url
: Some(self.url(&filename
)),
570 xz_url
: xz_digest
.as_ref().map(|_
| self.url(&xz_filename
)),
572 components
: Some(components
),
573 extensions
: Some(extensions
),
577 fn profile(&mut self,
579 dst
: &mut BTreeMap
<String
, Vec
<String
>>,
581 dst
.insert(profile_name
.to_owned(), pkgs
.iter().map(|s
| (*s
).to_owned()).collect());
584 fn extend_profile(&mut self,
586 dst
: &mut BTreeMap
<String
, Vec
<String
>>,
588 dst
.get_mut(profile_name
).expect("existing profile")
589 .extend(pkgs
.iter().map(|s
| (*s
).to_owned()));
592 fn package(&mut self,
594 dst
: &mut BTreeMap
<String
, Package
>,
596 let (version
, mut is_present
) = self.cached_version(pkgname
)
599 .map(|version
| (version
, true))
600 .unwrap_or_default(); // `is_present` defaults to `false` here.
602 // Miri is nightly-only; never ship it for other trains.
603 if pkgname
== "miri-preview" && self.rust_release
!= "nightly" {
604 is_present
= false; // Pretend the component is entirely missing.
607 let targets
= targets
.iter().map(|name
| {
609 // The component generally exists, but it might still be missing for this target.
610 let filename
= self.filename(pkgname
, name
);
611 let digest
= match self.digests
.remove(&filename
) {
612 Some(digest
) => digest
,
613 // This component does not exist for this target -- skip it.
614 None
=> return (name
.to_string(), Target
::unavailable()),
616 let xz_filename
= filename
.replace(".tar.gz", ".tar.xz");
617 let xz_digest
= self.digests
.remove(&xz_filename
);
619 (name
.to_string(), Target
{
621 url
: Some(self.url(&filename
)),
623 xz_url
: xz_digest
.as_ref().map(|_
| self.url(&xz_filename
)),
629 // If the component is not present for this build add it anyway but mark it as
630 // unavailable -- this way rustup won't allow upgrades without --force
631 (name
.to_string(), Target
::unavailable())
635 dst
.insert(pkgname
.to_string(), Package
{
637 git_commit_hash
: self.cached_git_commit_hash(pkgname
).clone(),
642 fn url(&self, filename
: &str) -> String
{
649 fn filename(&self, component
: &str, target
: &str) -> String
{
651 match PkgType
::from_component(component
) {
652 RustSrc
=> format
!("rust-src-{}.tar.gz", self.rust_release
),
653 Cargo
=> format
!("cargo-{}-{}.tar.gz", self.cargo_release
, target
),
654 Rls
=> format
!("rls-{}-{}.tar.gz", self.rls_release
, target
),
655 Clippy
=> format
!("clippy-{}-{}.tar.gz", self.clippy_release
, target
),
656 Rustfmt
=> format
!("rustfmt-{}-{}.tar.gz", self.rustfmt_release
, target
),
657 LlvmTools
=> format
!("llvm-tools-{}-{}.tar.gz", self.llvm_tools_release
, target
),
658 Lldb
=> format
!("lldb-{}-{}.tar.gz", self.lldb_release
, target
),
659 Miri
=> format
!("miri-{}-{}.tar.gz", self.miri_release
, target
),
660 Other
=> format
!("{}-{}-{}.tar.gz", component
, self.rust_release
, target
),
664 fn cached_version(&self, component
: &str) -> &Option
<String
> {
666 match PkgType
::from_component(component
) {
667 Cargo
=> &self.cargo_version
,
668 Rls
=> &self.rls_version
,
669 Clippy
=> &self.clippy_version
,
670 Rustfmt
=> &self.rustfmt_version
,
671 LlvmTools
=> &self.llvm_tools_version
,
672 Lldb
=> &self.lldb_version
,
673 Miri
=> &self.miri_version
,
674 _
=> &self.rust_version
,
678 fn cached_git_commit_hash(&self, component
: &str) -> &Option
<String
> {
680 match PkgType
::from_component(component
) {
681 Cargo
=> &self.cargo_git_commit_hash
,
682 Rls
=> &self.rls_git_commit_hash
,
683 Clippy
=> &self.clippy_git_commit_hash
,
684 Rustfmt
=> &self.rustfmt_git_commit_hash
,
685 LlvmTools
=> &self.llvm_tools_git_commit_hash
,
686 Lldb
=> &self.lldb_git_commit_hash
,
687 Miri
=> &self.miri_git_commit_hash
,
688 _
=> &self.rust_git_commit_hash
,
692 fn version(&self, component
: &str, target
: &str) -> Option
<String
> {
693 self.untar(component
, target
, |filename
| format
!("{}/version", filename
))
696 fn git_commit_hash(&self, component
: &str, target
: &str) -> Option
<String
> {
697 self.untar(component
, target
, |filename
| format
!("{}/git-commit-hash", filename
))
700 fn untar
<F
>(&self, component
: &str, target
: &str, dir
: F
) -> Option
<String
>
702 F
: FnOnce(String
) -> String
704 let mut cmd
= Command
::new("tar");
705 let filename
= self.filename(component
, target
);
707 .arg(self.input
.join(&filename
))
708 .arg(dir(filename
.replace(".tar.gz", "")))
710 let output
= t
!(cmd
.output());
711 if output
.status
.success() {
712 Some(String
::from_utf8_lossy(&output
.stdout
).trim().to_string())
718 fn hash(&self, path
: &Path
) -> String
{
719 let sha
= t
!(Command
::new("shasum")
720 .arg("-a").arg("256")
721 .arg(path
.file_name().unwrap())
722 .current_dir(path
.parent().unwrap())
724 assert
!(sha
.status
.success());
726 let filename
= path
.file_name().unwrap().to_str().unwrap();
727 let sha256
= self.output
.join(format
!("{}.sha256", filename
));
728 t
!(fs
::write(&sha256
, &sha
.stdout
));
730 let stdout
= String
::from_utf8_lossy(&sha
.stdout
);
731 stdout
.split_whitespace().next().unwrap().to_string()
734 fn sign(&self, path
: &Path
) {
735 if !self.should_sign
{
739 let filename
= path
.file_name().unwrap().to_str().unwrap();
740 let asc
= self.output
.join(format
!("{}.asc", filename
));
741 println
!("signing: {:?}", path
);
742 let mut cmd
= Command
::new("gpg");
743 cmd
.arg("--pinentry-mode=loopback")
747 .arg("--passphrase-fd").arg("0")
748 .arg("--personal-digest-preferences").arg("SHA512")
750 .arg("--output").arg(&asc
)
751 .arg("--detach-sign").arg(path
)
752 .stdin(Stdio
::piped());
753 let mut child
= t
!(cmd
.spawn());
754 t
!(child
.stdin
.take().unwrap().write_all(self.gpg_passphrase
.as_bytes()));
755 assert
!(t
!(child
.wait()).success());
758 fn write_channel_files(&self, channel_name
: &str, manifest
: &Manifest
) {
759 self.write(&toml
::to_string(&manifest
).unwrap(), channel_name
, ".toml");
760 self.write(&manifest
.date
, channel_name
, "-date.txt");
761 self.write(manifest
.pkg
["rust"].git_commit_hash
.as_ref().unwrap(),
762 channel_name
, "-git-commit-hash.txt");
765 fn write(&self, contents
: &str, channel_name
: &str, suffix
: &str) {
766 let dst
= self.output
.join(format
!("channel-rust-{}{}", channel_name
, suffix
));
767 t
!(fs
::write(&dst
, contents
));