Skip to content
This repository was archived by the owner on Nov 26, 2020. It is now read-only.

Commit 99de474

Browse files
committed
Recompress *.xz to *.gz if the *.gz is missing.
This is the first step to stop uploading *.gz into the internal S3 bucket.
1 parent ab4c52f commit 99de474

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

Cargo.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

promote-release/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ fs2 = "0.4"
1010
serde_json = "1"
1111
tar = "0.4"
1212
toml = "0.4"
13-
rand = "0.4"
13+
rand = "0.4"
14+
xz2 = "0.1"

promote-release/src/main.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ extern crate rand;
66
extern crate serde_json;
77
extern crate tar;
88
extern crate toml;
9+
extern crate xz2;
910

1011
use std::env;
1112
use std::fs::{self, File, OpenOptions};
12-
use std::io::{Read, Write};
13+
use std::io::{self, Read, Write};
1314
use std::path::{PathBuf, Path};
1415
use 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

Comments
 (0)