1
+ mod build_manifest;
1
2
mod config;
2
3
mod sign;
3
4
@@ -9,14 +10,18 @@ use std::process::Command;
9
10
use std:: time:: Instant ;
10
11
11
12
use anyhow:: Error ;
13
+ use build_manifest:: BuildManifest ;
14
+ use chrono:: Utc ;
12
15
use curl:: easy:: Easy ;
13
16
use fs2:: FileExt ;
14
17
use rayon:: prelude:: * ;
15
- use chrono:: Utc ;
16
18
use sign:: Signer ;
19
+ use xz2:: read:: XzDecoder ;
17
20
18
21
use crate :: config:: { Channel , Config } ;
19
22
23
+ const TARGET : & str = env ! ( "TARGET" ) ;
24
+
20
25
struct Context {
21
26
work : PathBuf ,
22
27
handle : Easy ,
@@ -51,7 +56,6 @@ impl Context {
51
56
52
57
fn run ( & mut self ) -> Result < ( ) , Error > {
53
58
let _lock = self . lock ( ) ?;
54
- self . update_repo ( ) ?;
55
59
self . do_release ( ) ?;
56
60
57
61
Ok ( ( ) )
@@ -73,7 +77,7 @@ impl Context {
73
77
74
78
/// Update the rust repository we have cached, either cloning a fresh one or
75
79
/// fetching remote references
76
- fn update_repo ( & mut self ) -> Result < ( ) , Error > {
80
+ fn legacy_update_repo ( & mut self ) -> Result < ( ) , Error > {
77
81
// Clone/update the repo
78
82
let dir = self . rust_dir ( ) ;
79
83
if dir. is_dir ( ) {
@@ -168,34 +172,23 @@ impl Context {
168
172
169
173
self . assert_all_components_present ( ) ?;
170
174
171
- // Ok we've now determined that a release needs to be done. Let's
172
- // configure rust, build a manifest and sign the artifacts we just downloaded, and upload the
173
- // signatures and manifest to the CI bucket.
174
-
175
- self . configure_rust ( & rev) ?;
175
+ // Ok we've now determined that a release needs to be done.
176
176
177
- let is_legacy_build_manifest = !self
178
- . rust_dir ( )
179
- . join ( "src/tools/build-manifest/src/manifest.rs" )
180
- . exists ( ) ;
181
- println ! ( "is legacy build-manifest: {}" , is_legacy_build_manifest) ;
182
-
183
- if is_legacy_build_manifest {
184
- self . sign_artifacts ( ) ?;
185
- } else {
186
- self . build_manifest ( ) ?;
187
- }
177
+ let build_manifest = BuildManifest :: new ( self ) ;
178
+ if build_manifest. exists ( ) {
179
+ // Generate the channel manifest
180
+ build_manifest. run ( ) ?;
188
181
189
- // Merge all the signatures with the download files, and then sync that
190
- // whole dir up to the release archives
191
- for file in self . build_dir ( ) . join ( "build/dist/" ) . read_dir ( ) ? {
192
- let file = file?;
193
- fs:: copy ( file. path ( ) , self . dl_dir ( ) . join ( file. file_name ( ) ) ) ?;
194
- }
195
-
196
- if !is_legacy_build_manifest {
182
+ // Generate checksums and sign all the files we're about to ship.
197
183
let signer = Signer :: new ( & self . config ) ?;
198
184
signer. sign_directory ( & self . dl_dir ( ) ) ?;
185
+ } else {
186
+ // For releases using the legacy build-manifest, we need to clone the rustc monorepo
187
+ // and invoke `./x.py dist hash-and-sign` in it. This won't be needed after 1.48.0 is
188
+ // out in the stable channel.
189
+ self . legacy_update_repo ( ) ?;
190
+ self . legacy_configure_rust ( & rev) ?;
191
+ self . legacy_sign_artifacts ( ) ?;
199
192
}
200
193
201
194
self . publish_archive ( ) ?;
@@ -211,7 +204,7 @@ impl Context {
211
204
Ok ( ( ) )
212
205
}
213
206
214
- fn configure_rust ( & mut self , rev : & str ) -> Result < ( ) , Error > {
207
+ fn legacy_configure_rust ( & mut self , rev : & str ) -> Result < ( ) , Error > {
215
208
let build = self . build_dir ( ) ;
216
209
// Only delete the dist artifacts when running the tool locally, to avoid rebuilding
217
210
// bootstrap over and over again.
@@ -428,7 +421,7 @@ upload-addr = \"{}/{}\"
428
421
println ! ( "recompressing {}..." , gz_path. display( ) ) ;
429
422
430
423
let xz = File :: open ( xz_path) ?;
431
- let mut xz = xz2 :: read :: XzDecoder :: new ( xz) ;
424
+ let mut xz = XzDecoder :: new ( xz) ;
432
425
let gz = File :: create ( gz_path) ?;
433
426
let mut gz = flate2:: write:: GzEncoder :: new ( gz, compression_level) ;
434
427
io:: copy ( & mut xz, & mut gz) ?;
@@ -448,20 +441,22 @@ upload-addr = \"{}/{}\"
448
441
}
449
442
450
443
/// Create manifest and sign the artifacts.
451
- fn sign_artifacts ( & mut self ) -> Result < ( ) , Error > {
444
+ fn legacy_sign_artifacts ( & mut self ) -> Result < ( ) , Error > {
452
445
let build = self . build_dir ( ) ;
453
446
// This calls `src/tools/build-manifest` from the rustc repo.
454
447
run ( Command :: new ( self . rust_dir ( ) . join ( "x.py" ) )
455
448
. current_dir ( & build)
456
449
. arg ( "dist" )
457
- . arg ( "hash-and-sign" ) )
458
- }
450
+ . arg ( "hash-and-sign" ) ) ?;
459
451
460
- fn build_manifest ( & mut self ) -> Result < ( ) , Error > {
461
- run ( Command :: new ( self . rust_dir ( ) . join ( "x.py" ) )
462
- . current_dir ( & self . build_dir ( ) )
463
- . arg ( "run" )
464
- . arg ( "src/tools/build-manifest" ) )
452
+ // Merge all the signatures with the download files, and then sync that
453
+ // whole dir up to the release archives
454
+ for file in self . build_dir ( ) . join ( "build/dist/" ) . read_dir ( ) ? {
455
+ let file = file?;
456
+ fs:: copy ( file. path ( ) , self . dl_dir ( ) . join ( file. file_name ( ) ) ) ?;
457
+ }
458
+
459
+ Ok ( ( ) )
465
460
}
466
461
467
462
fn publish_archive ( & mut self ) -> Result < ( ) , Error > {
0 commit comments