@@ -327,35 +327,48 @@ python do_update_snapshot() {
327
327
328
328
from collections import defaultdict
329
329
330
- with open (os . path . join (d . getVar ("S" ), "src" , "stage0.json" )) as f :
331
- j = json . load (f )
332
-
333
- config_dist_server = j ['config' ]['dist_server' ]
334
- compiler_date = j ['compiler' ]['date' ]
335
- compiler_version = j ['compiler' ]['version' ]
330
+ key_value_pairs = {}
331
+ with open (os . path . join (d . getVar ("S" ), "src" , "stage0" )) as f :
332
+ for line in f :
333
+ # Skip empty lines or comments
334
+ if not line . strip () or line . startswith ("#" ):
335
+ continue
336
+ # Split the line into key and value using '=' as separator
337
+ match = re . match (r '(\S+)\s*=\s*(\S+)' , line . strip ())
338
+ if match :
339
+ key = match . group (1 )
340
+ value = match . group (2 )
341
+ key_value_pairs [key ] = value
342
+ # Extract the required values from key_value_pairs
343
+ config_dist_server = key_value_pairs . get ('dist_server' , '' )
344
+ compiler_date = key_value_pairs . get ('compiler_date' , '' )
345
+ compiler_version = key_value_pairs . get ('compiler_version' , '' )
336
346
337
347
src_uri = defaultdict (list )
338
- for k , v in j ['checksums_sha256' ]. items ():
339
- m = re . search (f "dist/{compiler_date}/(?P<component>.*)-{compiler_version}-(?P<arch>.*)-unknown-linux-gnu\\.tar\\.xz" , k )
340
- if m :
341
- component = m . group ('component' )
342
- arch = m . group ('arch' )
343
- src_uri [arch ]. append (f "SRC_URI[{component}-snapshot-{arch}.sha256sum] = \" {v}\" " )
344
-
348
+ # Assuming checksums_sha256 is now a key-value pair like: checksum_key = checksum_value
349
+ for k , v in key_value_pairs . items ():
350
+ # Match the pattern for checksums
351
+ if "dist" in k and "tar.xz" in k :
352
+ m = re . search (f "dist/{compiler_date}/(?P<component>.*)-{compiler_version}-(?P<arch>.*)-unknown-linux-gnu\\.tar\\.xz" , k )
353
+ if m :
354
+ component = m . group ('component' )
355
+ arch = m . group ('arch' )
356
+ src_uri [arch ]. append (f "SRC_URI[{component}-snapshot-{arch}.sha256sum] = \" {v}\" " )
357
+ # Create the snapshot string with the extracted values
345
358
snapshot = """\
346
359
## This is information on the rust-snapshot (binary) used to build our current release.
347
- ## snapshot info is taken from rust/src/stage0.json
360
+ ## snapshot info is taken from rust/src/stage0
348
361
## Rust is self-hosting and bootstraps itself with a pre-built previous version of itself.
349
362
## The exact (previous) version that has been used is specified in the source tarball.
350
363
## The version is replicated here.
351
364
352
365
SNAPSHOT_VERSION = "%s"
353
366
354
367
""" % compiler_version
355
-
368
+ # Add the checksum components to the snapshot
356
369
for arch , components in src_uri . items ():
357
370
snapshot += "\n" . join (components ) + "\n\n"
358
-
371
+ # Add the additional snapshot URIs
359
372
snapshot += """\
360
373
SRC_URI += " \\
361
374
${RUST_DIST_SERVER} /dist/${RUST_STD_SNAPSHOT} .tar.xz;name=rust-std-snapshot-${RUST_BUILD_ARCH} ;subdir=rust-snapshot-components \\
@@ -369,7 +382,7 @@ RUST_STD_SNAPSHOT = "rust-std-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-lin
369
382
RUSTC_SNAPSHOT = "rustc-${SNAPSHOT_VERSION} -${RUST_BUILD_ARCH} -unknown-linux-gnu"
370
383
CARGO_SNAPSHOT = "cargo-${SNAPSHOT_VERSION} -${RUST_BUILD_ARCH} -unknown-linux-gnu"
371
384
""" % config_dist_server
372
-
385
+ # Write the updated snapshot information to the rust-snapshot.inc file
373
386
with open (os . path . join (d . getVar ("THISDIR" ), "rust-snapshot.inc" ), "w" ) as f :
374
387
f . write (snapshot )
375
388
}
0 commit comments