Skip to content

Commit

Permalink
Backfill MAJOR.MINOR Rustup channel manifests
Browse files Browse the repository at this point in the history
Now that rust-lang/rust#76107 has been merged,
new releases will also write their manifests to channel-rust-1.x.toml as
well as channel-rust-1.x.y.toml to enable `rustup install 1.48` to get
the latest patch release in a minor release series.

This commit adds an idempotent function to copy manifests for the last
patch release in every minor release series to the corresponding
minor manifest so that past minor versions will work with the rustup
functionality too.

This function should only need to be run once, but should be safe to run
more than once.
  • Loading branch information
carols10cents committed Oct 6, 2020
1 parent 9ad4659 commit 945325c
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions promote-release/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ extern crate tar;
extern crate toml;
extern crate xz2;

use std::collections::HashMap;
use std::env;
use std::fs::{self, File, OpenOptions};
use std::io::{self, Read, Write};
Expand Down Expand Up @@ -53,6 +54,7 @@ fn main() {
impl Context {
fn run(&mut self) {
let _lock = self.lock();
self.backfill_major_minor_channels();
self.update_repo();

let override_var = env::var("PROMOTE_RELEASE_OVERRIDE_BRANCH");
Expand Down Expand Up @@ -578,6 +580,53 @@ upload-addr = \"{}/{}\"
assert_eq!(t!(self.handle.response_code()), 200);
t!(t!(String::from_utf8(result)).parse())
}

// This function can be removed after it has been run successfully at least once in the
// production environment such that a manifest exists for every 1.x stable version. It is
// idempontent and safe to run more than once.
fn backfill_major_minor_channels(&mut self) {
let bucket = self.secrets["dist"]["upload-bucket"].as_str().unwrap();
let dir = self.secrets["dist"]["upload-dir"].as_str().unwrap();

// All the Rust versions that have had non-zero patch releases
let minor_versions_with_patch_releases: HashMap<u8, u8> = vec![
(12, 1),
(15, 1),
(22, 1),
(24, 1),
(26, 2),
(27, 2),
(29, 2),
(30, 1),
(31, 1),
(34, 2),
(41, 1),
(43, 1),
(44, 1),
(45, 2),
]
.into_iter()
.collect();

for minor in 0..=47 {
let last_patch = minor_versions_with_patch_releases
.get(&minor)
.copied()
.unwrap_or(0);
let src = format!(
"s3://{}/{}/channel-rust-1.{}.{}.toml",
bucket, dir, minor, last_patch
);
let dst = format!("s3://{}/{}/channel-rust-1.{}.toml", bucket, dir, minor);

run(self
.aws_s3()
.arg("cp")
.arg("--only-show-errors")
.arg(&src)
.arg(&dst));
}
}
}

fn run(cmd: &mut Command) {
Expand Down

0 comments on commit 945325c

Please sign in to comment.