@@ -11,8 +11,8 @@ use once_cell::sync::OnceCell;
11
11
use xz2:: bufread:: XzDecoder ;
12
12
13
13
use crate :: {
14
- min_config:: RustfmtMetadata ,
15
14
llvm:: detect_llvm_sha,
15
+ min_config:: RustfmtMetadata ,
16
16
t,
17
17
util:: { check_run, exe, output, program_out_of_date, try_run} ,
18
18
Config , MinimalConfig ,
@@ -343,6 +343,99 @@ enum DownloadSource {
343
343
Dist ,
344
344
}
345
345
346
+ impl MinimalConfig {
347
+ pub fn download_bootstrap ( & self , commit : & str ) -> PathBuf {
348
+ self . verbose ( & format ! ( "downloading bootstrap from CI (commit {commit})" ) ) ;
349
+ let host = self . build . triple ;
350
+ let bin_root = self . out . join ( host) . join ( "bootstrap" ) ;
351
+ let stamp = bin_root. join ( ".bootstrap-stamp" ) ;
352
+ let bootstrap_bin = bin_root. join ( "bin" ) . join ( "bootstrap" ) ;
353
+
354
+ if !bootstrap_bin. exists ( ) || program_out_of_date ( & stamp, commit) {
355
+ let version = self . git_artifact_version_part ( commit) ;
356
+ let filename = format ! ( "bootstrap-{version}-{host}.tar.xz" ) ;
357
+ self . download_component ( DownloadSource :: CI , filename, "bootstrap" , commit, "" ) ;
358
+ if self . should_fix_bins_and_dylibs ( ) {
359
+ self . fix_bin_or_dylib ( & bootstrap_bin) ;
360
+ }
361
+ t ! ( fs:: write( stamp, commit) ) ;
362
+ }
363
+
364
+ bootstrap_bin
365
+ }
366
+
367
+ fn download_component (
368
+ & self ,
369
+ mode : DownloadSource ,
370
+ filename : String ,
371
+ prefix : & str ,
372
+ key : & str ,
373
+ destination : & str ,
374
+ ) {
375
+ let cache_dst = self . out . join ( "cache" ) ;
376
+ let cache_dir = cache_dst. join ( key) ;
377
+ if !cache_dir. exists ( ) {
378
+ t ! ( fs:: create_dir_all( & cache_dir) ) ;
379
+ }
380
+
381
+ let bin_root = self . out . join ( self . build . triple ) . join ( destination) ;
382
+ let tarball = cache_dir. join ( & filename) ;
383
+ let ( base_url, url, should_verify) = match mode {
384
+ DownloadSource :: CI => (
385
+ self . stage0_metadata . config . artifacts_server . clone ( ) ,
386
+ format ! ( "{key}/{filename}" ) ,
387
+ false ,
388
+ ) ,
389
+ DownloadSource :: Dist => {
390
+ let dist_server = env:: var ( "RUSTUP_DIST_SERVER" )
391
+ . unwrap_or ( self . stage0_metadata . config . dist_server . to_string ( ) ) ;
392
+ // NOTE: make `dist` part of the URL because that's how it's stored in src/stage0.json
393
+ ( dist_server, format ! ( "dist/{key}/{filename}" ) , true )
394
+ }
395
+ } ;
396
+
397
+ // For the beta compiler, put special effort into ensuring the checksums are valid.
398
+ // FIXME: maybe we should do this for download-rustc as well? but it would be a pain to update
399
+ // this on each and every nightly ...
400
+ let checksum = if should_verify {
401
+ let error = format ! (
402
+ "src/stage0.json doesn't contain a checksum for {url}. \
403
+ Pre-built artifacts might not be available for this \
404
+ target at this time, see https://doc.rust-lang.org/nightly\
405
+ /rustc/platform-support.html for more information."
406
+ ) ;
407
+ let sha256 = self . stage0_metadata . checksums_sha256 . get ( & url) . expect ( & error) ;
408
+ if tarball. exists ( ) {
409
+ if self . verify ( & tarball, sha256) {
410
+ self . unpack ( & tarball, & bin_root, prefix) ;
411
+ return ;
412
+ } else {
413
+ self . verbose ( & format ! (
414
+ "ignoring cached file {} due to failed verification" ,
415
+ tarball. display( )
416
+ ) ) ;
417
+ self . remove ( & tarball) ;
418
+ }
419
+ }
420
+ Some ( sha256)
421
+ } else if tarball. exists ( ) {
422
+ self . unpack ( & tarball, & bin_root, prefix) ;
423
+ return ;
424
+ } else {
425
+ None
426
+ } ;
427
+
428
+ self . download_file ( & format ! ( "{base_url}/{url}" ) , & tarball, "" ) ;
429
+ if let Some ( sha256) = checksum {
430
+ if !self . verify ( & tarball, sha256) {
431
+ panic ! ( "failed to verify {}" , tarball. display( ) ) ;
432
+ }
433
+ }
434
+
435
+ self . unpack ( & tarball, & bin_root, prefix) ;
436
+ }
437
+ }
438
+
346
439
/// Functions that are only ever called once, but named for clarify and to avoid thousand-line functions.
347
440
impl Config {
348
441
pub ( crate ) fn maybe_download_rustfmt ( & self ) -> Option < PathBuf > {
@@ -509,96 +602,3 @@ impl Config {
509
602
self . unpack ( & tarball, & llvm_root, "rust-dev" ) ;
510
603
}
511
604
}
512
-
513
- impl MinimalConfig {
514
- pub fn download_bootstrap ( & self , commit : & str ) -> PathBuf {
515
- self . verbose ( & format ! ( "downloading bootstrap from CI (commit {commit})" ) ) ;
516
- let host = self . build . triple ;
517
- let bin_root = self . out . join ( host) . join ( "bootstrap" ) ;
518
- let stamp = bin_root. join ( ".bootstrap-stamp" ) ;
519
- let bootstrap_bin = bin_root. join ( "bin" ) . join ( "bootstrap" ) ;
520
-
521
- if !bootstrap_bin. exists ( ) || program_out_of_date ( & stamp, commit) {
522
- let version = self . git_artifact_version_part ( commit) ;
523
- let filename = format ! ( "bootstrap-{version}-{host}.tar.xz" ) ;
524
- self . download_component ( DownloadSource :: CI , filename, "bootstrap" , commit, "" ) ;
525
- if self . should_fix_bins_and_dylibs ( ) {
526
- self . fix_bin_or_dylib ( & bootstrap_bin) ;
527
- }
528
- t ! ( fs:: write( stamp, commit) ) ;
529
- }
530
-
531
- bootstrap_bin
532
- }
533
-
534
- fn download_component (
535
- & self ,
536
- mode : DownloadSource ,
537
- filename : String ,
538
- prefix : & str ,
539
- key : & str ,
540
- destination : & str ,
541
- ) {
542
- let cache_dst = self . out . join ( "cache" ) ;
543
- let cache_dir = cache_dst. join ( key) ;
544
- if !cache_dir. exists ( ) {
545
- t ! ( fs:: create_dir_all( & cache_dir) ) ;
546
- }
547
-
548
- let bin_root = self . out . join ( self . build . triple ) . join ( destination) ;
549
- let tarball = cache_dir. join ( & filename) ;
550
- let ( base_url, url, should_verify) = match mode {
551
- DownloadSource :: CI => (
552
- self . stage0_metadata . config . artifacts_server . clone ( ) ,
553
- format ! ( "{key}/{filename}" ) ,
554
- false ,
555
- ) ,
556
- DownloadSource :: Dist => {
557
- let dist_server = env:: var ( "RUSTUP_DIST_SERVER" )
558
- . unwrap_or ( self . stage0_metadata . config . dist_server . to_string ( ) ) ;
559
- // NOTE: make `dist` part of the URL because that's how it's stored in src/stage0.json
560
- ( dist_server, format ! ( "dist/{key}/{filename}" ) , true )
561
- }
562
- } ;
563
-
564
- // For the beta compiler, put special effort into ensuring the checksums are valid.
565
- // FIXME: maybe we should do this for download-rustc as well? but it would be a pain to update
566
- // this on each and every nightly ...
567
- let checksum = if should_verify {
568
- let error = format ! (
569
- "src/stage0.json doesn't contain a checksum for {url}. \
570
- Pre-built artifacts might not be available for this \
571
- target at this time, see https://doc.rust-lang.org/nightly\
572
- /rustc/platform-support.html for more information."
573
- ) ;
574
- let sha256 = self . stage0_metadata . checksums_sha256 . get ( & url) . expect ( & error) ;
575
- if tarball. exists ( ) {
576
- if self . verify ( & tarball, sha256) {
577
- self . unpack ( & tarball, & bin_root, prefix) ;
578
- return ;
579
- } else {
580
- self . verbose ( & format ! (
581
- "ignoring cached file {} due to failed verification" ,
582
- tarball. display( )
583
- ) ) ;
584
- self . remove ( & tarball) ;
585
- }
586
- }
587
- Some ( sha256)
588
- } else if tarball. exists ( ) {
589
- self . unpack ( & tarball, & bin_root, prefix) ;
590
- return ;
591
- } else {
592
- None
593
- } ;
594
-
595
- self . download_file ( & format ! ( "{base_url}/{url}" ) , & tarball, "" ) ;
596
- if let Some ( sha256) = checksum {
597
- if !self . verify ( & tarball, sha256) {
598
- panic ! ( "failed to verify {}" , tarball. display( ) ) ;
599
- }
600
- }
601
-
602
- self . unpack ( & tarball, & bin_root, prefix) ;
603
- }
604
- }
0 commit comments