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

Commit

Permalink
Recompress *.xz to *.gz if the *.gz is missing.
Browse files Browse the repository at this point in the history
This is the first step to stop uploading *.gz into the internal S3 bucket.
  • Loading branch information
kennytm committed Jan 27, 2018
1 parent ab4c52f commit 99de474
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion promote-release/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ fs2 = "0.4"
serde_json = "1"
tar = "0.4"
toml = "0.4"
rand = "0.4"
rand = "0.4"
xz2 = "0.1"
21 changes: 20 additions & 1 deletion promote-release/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ extern crate rand;
extern crate serde_json;
extern crate tar;
extern crate toml;
extern crate xz2;

use std::env;
use std::fs::{self, File, OpenOptions};
use std::io::{Read, Write};
use std::io::{self, Read, Write};
use std::path::{PathBuf, Path};
use std::process::Command;

Expand Down Expand Up @@ -304,14 +305,32 @@ upload-addr = \"{}/{}\"
// 2. We're making a stable release. The stable release is first signed
// with the dev key and then it's signed with the prod key later. We
// want the prod key to overwrite the dev key signatures.
//
// Also, generate *.gz from *.xz if the former is missing. Since the gz
// and xz tarballs have the same content, we did not deploy the gz files
// from the CI. But rustup users may still expect to get gz files, so we
// are recompressing the xz files as gz here.
for file in t!(dl.read_dir()) {
let file = t!(file);
let path = file.path();
match path.extension().and_then(|s| s.to_str()) {
// Delete signature/hash files...
Some("asc") |
Some("sha256") => {
t!(fs::remove_file(&path));
}
// Generate *.gz from *.xz...
Some("xz") => {
let gz_path = path.with_extension("gz");
if !gz_path.is_file() {
println!("recompressing {}...", gz_path.display());
let xz = t!(File::open(path));
let mut xz = xz2::read::XzDecoder::new(xz);
let gz = t!(File::create(gz_path));
let mut gz = flate2::write::GzEncoder::new(gz, flate2::Compression::best());
t!(io::copy(&mut xz, &mut gz));
}
}
_ => {}
}
}
Expand Down

0 comments on commit 99de474

Please sign in to comment.