3
3
import contextlib
4
4
import datetime
5
5
import hashlib
6
- import json
7
6
import os
8
7
import re
9
8
import shutil
@@ -52,7 +51,7 @@ def get(base, url, path, checksums, verbose=False):
52
51
53
52
try :
54
53
if url not in checksums :
55
- raise RuntimeError (("src/stage0.json doesn't contain a checksum for {}. "
54
+ raise RuntimeError (("src/stage0 doesn't contain a checksum for {}. "
56
55
"Pre-built artifacts might not be available for this "
57
56
"target at this time, see https://doc.rust-lang.org/nightly"
58
57
"/rustc/platform-support.html for more information." )
@@ -421,9 +420,9 @@ def output(filepath):
421
420
422
421
423
422
class Stage0Toolchain :
424
- def __init__ (self , stage0_payload ):
425
- self .date = stage0_payload [ " date" ]
426
- self .version = stage0_payload [ " version" ]
423
+ def __init__ (self , date , version ):
424
+ self .date = date
425
+ self .version = version
427
426
428
427
def channel (self ):
429
428
return self .version + "-" + self .date
@@ -439,7 +438,7 @@ def __init__(
439
438
bin_root ,
440
439
tarball_path ,
441
440
tarball_suffix ,
442
- checksums_sha256 ,
441
+ stage0_data ,
443
442
pattern ,
444
443
verbose ,
445
444
):
@@ -448,7 +447,7 @@ def __init__(
448
447
self .bin_root = bin_root
449
448
self .tarball_path = tarball_path
450
449
self .tarball_suffix = tarball_suffix
451
- self .checksums_sha256 = checksums_sha256
450
+ self .stage0_data = stage0_data
452
451
self .pattern = pattern
453
452
self .verbose = verbose
454
453
@@ -458,7 +457,7 @@ def download_component(download_info):
458
457
download_info .base_download_url ,
459
458
download_info .download_path ,
460
459
download_info .tarball_path ,
461
- download_info .checksums_sha256 ,
460
+ download_info .stage0_data ,
462
461
verbose = download_info .verbose ,
463
462
)
464
463
@@ -510,11 +509,12 @@ def __init__(self, config_toml="", args=None):
510
509
build_dir = args .build_dir or self .get_toml ('build-dir' , 'build' ) or 'build'
511
510
self .build_dir = os .path .abspath (build_dir )
512
511
513
- with open (os .path .join (self .rust_root , "src" , "stage0.json" )) as f :
514
- data = json .load (f )
515
- self .checksums_sha256 = data ["checksums_sha256" ]
516
- self .stage0_compiler = Stage0Toolchain (data ["compiler" ])
517
- self .download_url = os .getenv ("RUSTUP_DIST_SERVER" ) or data ["config" ]["dist_server" ]
512
+ self .stage0_data = parse_stage0_file (os .path .join (self .rust_root , "src" , "stage0" ))
513
+ self .stage0_compiler = Stage0Toolchain (
514
+ self .stage0_data ["compiler_date" ],
515
+ self .stage0_data ["compiler_version" ]
516
+ )
517
+ self .download_url = os .getenv ("RUSTUP_DIST_SERVER" ) or self .stage0_data ["dist_server" ]
518
518
519
519
self .build = args .build or self .build_triple ()
520
520
@@ -581,7 +581,7 @@ def download_toolchain(self):
581
581
bin_root = self .bin_root (),
582
582
tarball_path = os .path .join (rustc_cache , filename ),
583
583
tarball_suffix = tarball_suffix ,
584
- checksums_sha256 = self .checksums_sha256 ,
584
+ stage0_data = self .stage0_data ,
585
585
pattern = pattern ,
586
586
verbose = self .verbose ,
587
587
)
@@ -1071,6 +1071,16 @@ def parse_args(args):
1071
1071
1072
1072
return parser .parse_known_args (args )[0 ]
1073
1073
1074
+ def parse_stage0_file (path ):
1075
+ result = {}
1076
+ with open (path , 'r' ) as file :
1077
+ for line in file :
1078
+ line = line .strip ()
1079
+ if line and not line .startswith ('#' ):
1080
+ key , value = line .split ('=' , 1 )
1081
+ result [key .strip ()] = value .strip ()
1082
+ return result
1083
+
1074
1084
def bootstrap (args ):
1075
1085
"""Configure, fetch, build and run the initial bootstrap"""
1076
1086
rust_root = os .path .abspath (os .path .join (__file__ , '../../..' ))
0 commit comments