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