@@ -6,10 +6,11 @@ extern crate rand;
66extern crate serde_json;
77extern crate tar;
88extern crate toml;
9+ extern crate xz2;
910
1011use std:: env;
1112use std:: fs:: { self , File , OpenOptions } ;
12- use std:: io:: { Read , Write } ;
13+ use std:: io:: { self , Read , Write } ;
1314use std:: path:: { PathBuf , Path } ;
1415use std:: process:: Command ;
1516
@@ -304,14 +305,32 @@ upload-addr = \"{}/{}\"
304305 // 2. We're making a stable release. The stable release is first signed
305306 // with the dev key and then it's signed with the prod key later. We
306307 // want the prod key to overwrite the dev key signatures.
308+ //
309+ // Also, generate *.gz from *.xz if the former is missing. Since the gz
310+ // and xz tarballs have the same content, we did not deploy the gz files
311+ // from the CI. But rustup users may still expect to get gz files, so we
312+ // are recompressing the xz files as gz here.
307313 for file in t ! ( dl. read_dir( ) ) {
308314 let file = t ! ( file) ;
309315 let path = file. path ( ) ;
310316 match path. extension ( ) . and_then ( |s| s. to_str ( ) ) {
317+ // Delete signature/hash files...
311318 Some ( "asc" ) |
312319 Some ( "sha256" ) => {
313320 t ! ( fs:: remove_file( & path) ) ;
314321 }
322+ // Generate *.gz from *.xz...
323+ Some ( "xz" ) => {
324+ let gz_path = path. with_extension ( "gz" ) ;
325+ if !gz_path. is_file ( ) {
326+ println ! ( "recompressing {}..." , gz_path. display( ) ) ;
327+ let xz = t ! ( File :: open( path) ) ;
328+ let mut xz = xz2:: read:: XzDecoder :: new ( xz) ;
329+ let gz = t ! ( File :: create( gz_path) ) ;
330+ let mut gz = flate2:: write:: GzEncoder :: new ( gz, flate2:: Compression :: best ( ) ) ;
331+ t ! ( io:: copy( & mut xz, & mut gz) ) ;
332+ }
333+ }
315334 _ => { }
316335 }
317336 }
0 commit comments