]> git.lizzy.rs Git - rust.git/blob - src/tools/build-manifest/src/main.rs
Integrate miri into build-manifest
[rust.git] / src / tools / build-manifest / src / main.rs
1 extern crate toml;
2 #[macro_use]
3 extern crate serde_derive;
4
5 use std::collections::BTreeMap;
6 use std::env;
7 use std::fs;
8 use std::io::{self, Read, Write};
9 use std::path::{PathBuf, Path};
10 use std::process::{Command, Stdio};
11
12 static HOSTS: &'static [&'static str] = &[
13     "aarch64-unknown-linux-gnu",
14     "arm-unknown-linux-gnueabi",
15     "arm-unknown-linux-gnueabihf",
16     "armv7-unknown-linux-gnueabihf",
17     "i686-apple-darwin",
18     "i686-pc-windows-gnu",
19     "i686-pc-windows-msvc",
20     "i686-unknown-linux-gnu",
21     "mips-unknown-linux-gnu",
22     "mips64-unknown-linux-gnuabi64",
23     "mips64el-unknown-linux-gnuabi64",
24     "mipsel-unknown-linux-gnu",
25     "powerpc-unknown-linux-gnu",
26     "powerpc64-unknown-linux-gnu",
27     "powerpc64le-unknown-linux-gnu",
28     "s390x-unknown-linux-gnu",
29     "x86_64-apple-darwin",
30     "x86_64-pc-windows-gnu",
31     "x86_64-pc-windows-msvc",
32     "x86_64-unknown-freebsd",
33     "x86_64-unknown-linux-gnu",
34     "x86_64-unknown-netbsd",
35 ];
36
37 static TARGETS: &'static [&'static str] = &[
38     "aarch64-apple-ios",
39     "aarch64-fuchsia",
40     "aarch64-linux-android",
41     "aarch64-pc-windows-msvc",
42     "aarch64-unknown-cloudabi",
43     "aarch64-unknown-linux-gnu",
44     "aarch64-unknown-linux-musl",
45     "arm-linux-androideabi",
46     "arm-unknown-linux-gnueabi",
47     "arm-unknown-linux-gnueabihf",
48     "arm-unknown-linux-musleabi",
49     "arm-unknown-linux-musleabihf",
50     "armv5te-unknown-linux-gnueabi",
51     "armv5te-unknown-linux-musleabi",
52     "armv7-apple-ios",
53     "armv7-linux-androideabi",
54     "thumbv7neon-linux-androideabi",
55     "armv7-unknown-linux-gnueabihf",
56     "thumbv7neon-unknown-linux-gnueabihf",
57     "armv7-unknown-linux-musleabihf",
58     "armebv7r-none-eabi",
59     "armebv7r-none-eabihf",
60     "armv7r-none-eabi",
61     "armv7r-none-eabihf",
62     "armv7s-apple-ios",
63     "asmjs-unknown-emscripten",
64     "i386-apple-ios",
65     "i586-pc-windows-msvc",
66     "i586-unknown-linux-gnu",
67     "i586-unknown-linux-musl",
68     "i686-apple-darwin",
69     "i686-linux-android",
70     "i686-pc-windows-gnu",
71     "i686-pc-windows-msvc",
72     "i686-unknown-freebsd",
73     "i686-unknown-linux-gnu",
74     "i686-unknown-linux-musl",
75     "mips-unknown-linux-gnu",
76     "mips-unknown-linux-musl",
77     "mips64-unknown-linux-gnuabi64",
78     "mips64el-unknown-linux-gnuabi64",
79     "mipsel-unknown-linux-gnu",
80     "mipsel-unknown-linux-musl",
81     "powerpc-unknown-linux-gnu",
82     "powerpc64-unknown-linux-gnu",
83     "powerpc64le-unknown-linux-gnu",
84     "riscv32imc-unknown-none-elf",
85     "riscv32imac-unknown-none-elf",
86     "s390x-unknown-linux-gnu",
87     "sparc64-unknown-linux-gnu",
88     "sparcv9-sun-solaris",
89     "thumbv6m-none-eabi",
90     "thumbv7em-none-eabi",
91     "thumbv7em-none-eabihf",
92     "thumbv7m-none-eabi",
93     "wasm32-unknown-emscripten",
94     "wasm32-unknown-unknown",
95     "x86_64-apple-darwin",
96     "x86_64-apple-ios",
97     "x86_64-fuchsia",
98     "x86_64-linux-android",
99     "x86_64-pc-windows-gnu",
100     "x86_64-pc-windows-msvc",
101     "x86_64-rumprun-netbsd",
102     "x86_64-sun-solaris",
103     "x86_64-unknown-cloudabi",
104     "x86_64-unknown-freebsd",
105     "x86_64-unknown-linux-gnu",
106     "x86_64-unknown-linux-gnux32",
107     "x86_64-unknown-linux-musl",
108     "x86_64-unknown-netbsd",
109     "x86_64-unknown-redox",
110 ];
111
112 static DOCS_TARGETS: &'static [&'static str] = &[
113     "i686-apple-darwin",
114     "i686-pc-windows-gnu",
115     "i686-pc-windows-msvc",
116     "i686-unknown-linux-gnu",
117     "x86_64-apple-darwin",
118     "x86_64-pc-windows-gnu",
119     "x86_64-pc-windows-msvc",
120     "x86_64-unknown-linux-gnu",
121 ];
122
123 static MINGW: &'static [&'static str] = &[
124     "i686-pc-windows-gnu",
125     "x86_64-pc-windows-gnu",
126 ];
127
128 #[derive(Serialize)]
129 #[serde(rename_all = "kebab-case")]
130 struct Manifest {
131     manifest_version: String,
132     date: String,
133     pkg: BTreeMap<String, Package>,
134     renames: BTreeMap<String, Rename>
135 }
136
137 #[derive(Serialize)]
138 struct Package {
139     version: String,
140     git_commit_hash: Option<String>,
141     target: BTreeMap<String, Target>,
142 }
143
144 #[derive(Serialize)]
145 struct Rename {
146     to: String,
147 }
148
149 #[derive(Serialize)]
150 struct Target {
151     available: bool,
152     url: Option<String>,
153     hash: Option<String>,
154     xz_url: Option<String>,
155     xz_hash: Option<String>,
156     components: Option<Vec<Component>>,
157     extensions: Option<Vec<Component>>,
158 }
159
160 impl Target {
161     fn unavailable() -> Target {
162         Target {
163             available: false,
164             url: None,
165             hash: None,
166             xz_url: None,
167             xz_hash: None,
168             components: None,
169             extensions: None,
170         }
171     }
172 }
173
174 #[derive(Serialize)]
175 struct Component {
176     pkg: String,
177     target: String,
178 }
179
180 macro_rules! t {
181     ($e:expr) => (match $e {
182         Ok(e) => e,
183         Err(e) => panic!("{} failed with {}", stringify!($e), e),
184     })
185 }
186
187 struct Builder {
188     rust_release: String,
189     cargo_release: String,
190     rls_release: String,
191     clippy_release: String,
192     rustfmt_release: String,
193     llvm_tools_release: String,
194     lldb_release: String,
195     miri_release: String,
196
197     input: PathBuf,
198     output: PathBuf,
199     gpg_passphrase: String,
200     digests: BTreeMap<String, String>,
201     s3_address: String,
202     date: String,
203
204     rust_version: Option<String>,
205     cargo_version: Option<String>,
206     rls_version: Option<String>,
207     clippy_version: Option<String>,
208     rustfmt_version: Option<String>,
209     llvm_tools_version: Option<String>,
210     lldb_version: Option<String>,
211     miri_version: Option<String>,
212
213     rust_git_commit_hash: Option<String>,
214     cargo_git_commit_hash: Option<String>,
215     rls_git_commit_hash: Option<String>,
216     clippy_git_commit_hash: Option<String>,
217     rustfmt_git_commit_hash: Option<String>,
218     llvm_tools_git_commit_hash: Option<String>,
219     lldb_git_commit_hash: Option<String>,
220     miri_git_commit_hash: Option<String>,
221
222     should_sign: bool,
223 }
224
225 fn main() {
226     // Avoid signing packages while manually testing
227     // Do NOT set this envvar in CI
228     let should_sign = env::var("BUILD_MANIFEST_DISABLE_SIGNING").is_err();
229
230     // Safety check to ensure signing is always enabled on CI
231     // The CI environment variable is set by both Travis and AppVeyor
232     if !should_sign && env::var("CI").is_ok() {
233         println!("The 'BUILD_MANIFEST_DISABLE_SIGNING' env var can't be enabled on CI.");
234         println!("If you're not running this on CI, unset the 'CI' env var.");
235         panic!();
236     }
237
238     let mut args = env::args().skip(1);
239     let input = PathBuf::from(args.next().unwrap());
240     let output = PathBuf::from(args.next().unwrap());
241     let date = args.next().unwrap();
242     let rust_release = args.next().unwrap();
243     let s3_address = args.next().unwrap();
244     let cargo_release = args.next().unwrap();
245     let rls_release = args.next().unwrap();
246     let clippy_release = args.next().unwrap();
247     let miri_release = args.next().unwrap();
248     let rustfmt_release = args.next().unwrap();
249     let llvm_tools_release = args.next().unwrap();
250     let lldb_release = args.next().unwrap();
251
252     // Do not ask for a passphrase while manually testing
253     let mut passphrase = String::new();
254     if should_sign {
255         t!(io::stdin().read_to_string(&mut passphrase));
256     }
257
258     Builder {
259         rust_release,
260         cargo_release,
261         rls_release,
262         clippy_release,
263         rustfmt_release,
264         llvm_tools_release,
265         lldb_release,
266         miri_release,
267
268         input,
269         output,
270         gpg_passphrase: passphrase,
271         digests: BTreeMap::new(),
272         s3_address,
273         date,
274
275         rust_version: None,
276         cargo_version: None,
277         rls_version: None,
278         clippy_version: None,
279         rustfmt_version: None,
280         llvm_tools_version: None,
281         lldb_version: None,
282         miri_version: None,
283
284         rust_git_commit_hash: None,
285         cargo_git_commit_hash: None,
286         rls_git_commit_hash: None,
287         clippy_git_commit_hash: None,
288         rustfmt_git_commit_hash: None,
289         llvm_tools_git_commit_hash: None,
290         lldb_git_commit_hash: None,
291         miri_git_commit_hash: None,
292
293         should_sign,
294     }.build();
295 }
296
297 impl Builder {
298     fn build(&mut self) {
299         self.rust_version = self.version("rust", "x86_64-unknown-linux-gnu");
300         self.cargo_version = self.version("cargo", "x86_64-unknown-linux-gnu");
301         self.rls_version = self.version("rls", "x86_64-unknown-linux-gnu");
302         self.clippy_version = self.version("clippy", "x86_64-unknown-linux-gnu");
303         self.rustfmt_version = self.version("rustfmt", "x86_64-unknown-linux-gnu");
304         self.llvm_tools_version = self.version("llvm-tools", "x86_64-unknown-linux-gnu");
305         // lldb is only built for macOS.
306         self.lldb_version = self.version("lldb", "x86_64-apple-darwin");
307         self.miri_version = self.version("miri", "x86_64-unknown-linux-gnu");
308
309         self.rust_git_commit_hash = self.git_commit_hash("rust", "x86_64-unknown-linux-gnu");
310         self.cargo_git_commit_hash = self.git_commit_hash("cargo", "x86_64-unknown-linux-gnu");
311         self.rls_git_commit_hash = self.git_commit_hash("rls", "x86_64-unknown-linux-gnu");
312         self.clippy_git_commit_hash = self.git_commit_hash("clippy", "x86_64-unknown-linux-gnu");
313         self.rustfmt_git_commit_hash = self.git_commit_hash("rustfmt", "x86_64-unknown-linux-gnu");
314         self.llvm_tools_git_commit_hash = self.git_commit_hash("llvm-tools",
315                                                                "x86_64-unknown-linux-gnu");
316         self.lldb_git_commit_hash = self.git_commit_hash("lldb", "x86_64-unknown-linux-gnu");
317         self.miri_git_commit_hash = self.git_commit_hash("miri", "x86_64-unknown-linux-gnu");
318
319         self.digest_and_sign();
320         let manifest = self.build_manifest();
321         self.write_channel_files(&self.rust_release, &manifest);
322
323         if self.rust_release != "beta" && self.rust_release != "nightly" {
324             self.write_channel_files("stable", &manifest);
325         }
326     }
327
328     fn digest_and_sign(&mut self) {
329         for file in t!(self.input.read_dir()).map(|e| t!(e).path()) {
330             let filename = file.file_name().unwrap().to_str().unwrap();
331             let digest = self.hash(&file);
332             self.sign(&file);
333             assert!(self.digests.insert(filename.to_string(), digest).is_none());
334         }
335     }
336
337     fn build_manifest(&mut self) -> Manifest {
338         let mut manifest = Manifest {
339             manifest_version: "2".to_string(),
340             date: self.date.to_string(),
341             pkg: BTreeMap::new(),
342             renames: BTreeMap::new(),
343         };
344
345         self.package("rustc", &mut manifest.pkg, HOSTS);
346         self.package("cargo", &mut manifest.pkg, HOSTS);
347         self.package("rust-mingw", &mut manifest.pkg, MINGW);
348         self.package("rust-std", &mut manifest.pkg, TARGETS);
349         self.package("rust-docs", &mut manifest.pkg, DOCS_TARGETS);
350         self.package("rust-src", &mut manifest.pkg, &["*"]);
351         self.package("rls-preview", &mut manifest.pkg, HOSTS);
352         self.package("clippy-preview", &mut manifest.pkg, HOSTS);
353         self.package("rustfmt-preview", &mut manifest.pkg, HOSTS);
354         self.package("rust-analysis", &mut manifest.pkg, TARGETS);
355         self.package("llvm-tools-preview", &mut manifest.pkg, TARGETS);
356         self.package("lldb-preview", &mut manifest.pkg, TARGETS);
357
358         manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() });
359         manifest.renames.insert("rustfmt".to_owned(), Rename { to: "rustfmt-preview".to_owned() });
360         manifest.renames.insert("clippy".to_owned(), Rename { to: "clippy-preview".to_owned() });
361
362         let mut pkg = Package {
363             version: self.cached_version("rust")
364                          .as_ref()
365                          .expect("Couldn't find Rust version")
366                          .clone(),
367             git_commit_hash: self.cached_git_commit_hash("rust").clone(),
368             target: BTreeMap::new(),
369         };
370         for host in HOSTS {
371             let filename = self.filename("rust", host);
372             let digest = match self.digests.remove(&filename) {
373                 Some(digest) => digest,
374                 None => {
375                     pkg.target.insert(host.to_string(), Target::unavailable());
376                     continue
377                 }
378             };
379             let xz_filename = filename.replace(".tar.gz", ".tar.xz");
380             let xz_digest = self.digests.remove(&xz_filename);
381             let mut components = Vec::new();
382             let mut extensions = Vec::new();
383
384             // rustc/rust-std/cargo/docs are all required, and so is rust-mingw
385             // if it's available for the target.
386             components.extend(vec![
387                 Component { pkg: "rustc".to_string(), target: host.to_string() },
388                 Component { pkg: "rust-std".to_string(), target: host.to_string() },
389                 Component { pkg: "cargo".to_string(), target: host.to_string() },
390                 Component { pkg: "rust-docs".to_string(), target: host.to_string() },
391             ]);
392             if host.contains("pc-windows-gnu") {
393                 components.push(Component {
394                     pkg: "rust-mingw".to_string(),
395                     target: host.to_string(),
396                 });
397             }
398
399             // Tools are always present in the manifest, but might be marked as unavailable if they
400             // weren't built
401             extensions.extend(vec![
402                 Component { pkg: "clippy-preview".to_string(), target: host.to_string() },
403                 Component { pkg: "rls-preview".to_string(), target: host.to_string() },
404                 Component { pkg: "rustfmt-preview".to_string(), target: host.to_string() },
405                 Component { pkg: "llvm-tools-preview".to_string(), target: host.to_string() },
406                 Component { pkg: "lldb-preview".to_string(), target: host.to_string() },
407                 Component { pkg: "rust-analysis".to_string(), target: host.to_string() },
408             ]);
409
410             for target in TARGETS {
411                 if target != host {
412                     extensions.push(Component {
413                         pkg: "rust-std".to_string(),
414                         target: target.to_string(),
415                     });
416                 }
417             }
418             extensions.push(Component {
419                 pkg: "rust-src".to_string(),
420                 target: "*".to_string(),
421             });
422
423             // If the components/extensions don't actually exist for this
424             // particular host/target combination then nix it entirely from our
425             // lists.
426             {
427                 let has_component = |c: &Component| {
428                     if c.target == "*" {
429                         return true
430                     }
431                     let pkg = match manifest.pkg.get(&c.pkg) {
432                         Some(p) => p,
433                         None => return false,
434                     };
435                     pkg.target.get(&c.target).is_some()
436                 };
437                 extensions.retain(&has_component);
438                 components.retain(&has_component);
439             }
440
441             pkg.target.insert(host.to_string(), Target {
442                 available: true,
443                 url: Some(self.url(&filename)),
444                 hash: Some(digest),
445                 xz_url: xz_digest.as_ref().map(|_| self.url(&xz_filename)),
446                 xz_hash: xz_digest,
447                 components: Some(components),
448                 extensions: Some(extensions),
449             });
450         }
451         manifest.pkg.insert("rust".to_string(), pkg);
452
453         return manifest;
454     }
455
456     fn package(&mut self,
457                pkgname: &str,
458                dst: &mut BTreeMap<String, Package>,
459                targets: &[&str]) {
460         let (version, is_present) = match *self.cached_version(pkgname) {
461             Some(ref version) => (version.clone(), true),
462             None => (String::new(), false),
463         };
464
465         let targets = targets.iter().map(|name| {
466             if is_present {
467                 let filename = self.filename(pkgname, name);
468                 let digest = match self.digests.remove(&filename) {
469                     Some(digest) => digest,
470                     None => return (name.to_string(), Target::unavailable()),
471                 };
472                 let xz_filename = filename.replace(".tar.gz", ".tar.xz");
473                 let xz_digest = self.digests.remove(&xz_filename);
474
475                 (name.to_string(), Target {
476                     available: true,
477                     url: Some(self.url(&filename)),
478                     hash: Some(digest),
479                     xz_url: xz_digest.as_ref().map(|_| self.url(&xz_filename)),
480                     xz_hash: xz_digest,
481                     components: None,
482                     extensions: None,
483                 })
484             } else {
485                 // If the component is not present for this build add it anyway but mark it as
486                 // unavailable -- this way rustup won't allow upgrades without --force
487                 (name.to_string(), Target {
488                     available: false,
489                     url: None,
490                     hash: None,
491                     xz_url: None,
492                     xz_hash: None,
493                     components: None,
494                     extensions: None,
495                 })
496             }
497         }).collect();
498
499         dst.insert(pkgname.to_string(), Package {
500             version,
501             git_commit_hash: self.cached_git_commit_hash(pkgname).clone(),
502             target: targets,
503         });
504     }
505
506     fn url(&self, filename: &str) -> String {
507         format!("{}/{}/{}",
508                 self.s3_address,
509                 self.date,
510                 filename)
511     }
512
513     fn filename(&self, component: &str, target: &str) -> String {
514         if component == "rust-src" {
515             format!("rust-src-{}.tar.gz", self.rust_release)
516         } else if component == "cargo" {
517             format!("cargo-{}-{}.tar.gz", self.cargo_release, target)
518         } else if component == "rls" || component == "rls-preview" {
519             format!("rls-{}-{}.tar.gz", self.rls_release, target)
520         } else if component == "clippy" || component == "clippy-preview" {
521             format!("clippy-{}-{}.tar.gz", self.clippy_release, target)
522         } else if component == "rustfmt" || component == "rustfmt-preview" {
523             format!("rustfmt-{}-{}.tar.gz", self.rustfmt_release, target)
524         } else if component == "llvm-tools" || component == "llvm-tools-preview" {
525             format!("llvm-tools-{}-{}.tar.gz", self.llvm_tools_release, target)
526         } else if component == "lldb" || component == "lldb-preview" {
527             format!("lldb-{}-{}.tar.gz", self.lldb_release, target)
528         } else if component == "miri" || component == "miri-preview" {
529             format!("miri-{}-{}.tar.gz", self.miri_release, target)
530         } else {
531             format!("{}-{}-{}.tar.gz", component, self.rust_release, target)
532         }
533     }
534
535     fn cached_version(&self, component: &str) -> &Option<String> {
536         if component == "cargo" {
537             &self.cargo_version
538         } else if component == "rls" || component == "rls-preview" {
539             &self.rls_version
540         } else if component == "clippy" || component == "clippy-preview" {
541             &self.clippy_version
542         } else if component == "rustfmt" || component == "rustfmt-preview" {
543             &self.rustfmt_version
544         } else if component == "llvm-tools" || component == "llvm-tools-preview" {
545             &self.llvm_tools_version
546         } else if component == "lldb" || component == "lldb-preview" {
547             &self.lldb_version
548         } else if component == "miri" || component == "miri-preview" {
549             &self.miri_version
550         } else {
551             &self.rust_version
552         }
553     }
554
555     fn cached_git_commit_hash(&self, component: &str) -> &Option<String> {
556         if component == "cargo" {
557             &self.cargo_git_commit_hash
558         } else if component == "rls" || component == "rls-preview" {
559             &self.rls_git_commit_hash
560         } else if component == "clippy" || component == "clippy-preview" {
561             &self.clippy_git_commit_hash
562         } else if component == "rustfmt" || component == "rustfmt-preview" {
563             &self.rustfmt_git_commit_hash
564         } else if component == "llvm-tools" || component == "llvm-tools-preview" {
565             &self.llvm_tools_git_commit_hash
566         } else if component == "lldb" || component == "lldb-preview" {
567             &self.lldb_git_commit_hash
568         } else if component == "miri" || component == "miri-preview" {
569             &self.miri_git_commit_hash
570         } else {
571             &self.rust_git_commit_hash
572         }
573     }
574
575     fn version(&self, component: &str, target: &str) -> Option<String> {
576         let mut cmd = Command::new("tar");
577         let filename = self.filename(component, target);
578         cmd.arg("xf")
579            .arg(self.input.join(&filename))
580            .arg(format!("{}/version", filename.replace(".tar.gz", "")))
581            .arg("-O");
582         let output = t!(cmd.output());
583         if output.status.success() {
584             Some(String::from_utf8_lossy(&output.stdout).trim().to_string())
585         } else {
586             // Perhaps we didn't build this package.
587             None
588         }
589     }
590
591     fn git_commit_hash(&self, component: &str, target: &str) -> Option<String> {
592         let mut cmd = Command::new("tar");
593         let filename = self.filename(component, target);
594         cmd.arg("xf")
595            .arg(self.input.join(&filename))
596            .arg(format!("{}/git-commit-hash", filename.replace(".tar.gz", "")))
597            .arg("-O");
598         let output = t!(cmd.output());
599         if output.status.success() {
600             Some(String::from_utf8_lossy(&output.stdout).trim().to_string())
601         } else {
602             None
603         }
604     }
605
606     fn hash(&self, path: &Path) -> String {
607         let sha = t!(Command::new("shasum")
608                         .arg("-a").arg("256")
609                         .arg(path.file_name().unwrap())
610                         .current_dir(path.parent().unwrap())
611                         .output());
612         assert!(sha.status.success());
613
614         let filename = path.file_name().unwrap().to_str().unwrap();
615         let sha256 = self.output.join(format!("{}.sha256", filename));
616         t!(fs::write(&sha256, &sha.stdout));
617
618         let stdout = String::from_utf8_lossy(&sha.stdout);
619         stdout.split_whitespace().next().unwrap().to_string()
620     }
621
622     fn sign(&self, path: &Path) {
623         if !self.should_sign {
624             return;
625         }
626
627         let filename = path.file_name().unwrap().to_str().unwrap();
628         let asc = self.output.join(format!("{}.asc", filename));
629         println!("signing: {:?}", path);
630         let mut cmd = Command::new("gpg");
631         cmd.arg("--pinentry-mode=loopback")
632             .arg("--no-tty")
633             .arg("--yes")
634             .arg("--batch")
635             .arg("--passphrase-fd").arg("0")
636             .arg("--personal-digest-preferences").arg("SHA512")
637             .arg("--armor")
638             .arg("--output").arg(&asc)
639             .arg("--detach-sign").arg(path)
640             .stdin(Stdio::piped());
641         let mut child = t!(cmd.spawn());
642         t!(child.stdin.take().unwrap().write_all(self.gpg_passphrase.as_bytes()));
643         assert!(t!(child.wait()).success());
644     }
645
646     fn write_channel_files(&self, channel_name: &str, manifest: &Manifest) {
647         self.write(&toml::to_string(&manifest).unwrap(), channel_name, ".toml");
648         self.write(&manifest.date, channel_name, "-date.txt");
649         self.write(manifest.pkg["rust"].git_commit_hash.as_ref().unwrap(),
650                    channel_name, "-git-commit-hash.txt");
651     }
652
653     fn write(&self, contents: &str, channel_name: &str, suffix: &str) {
654         let dst = self.output.join(format!("channel-rust-{}{}", channel_name, suffix));
655         t!(fs::write(&dst, contents));
656         self.hash(&dst);
657         self.sign(&dst);
658     }
659 }