Skip to content

Commit 568810a

Browse files
Yashinde145rpurdie
authored andcommitted
rust: Update "do_update_snapshot" task for rust-snapshot.inc
The 'do_update_snapshot' task is failed with below error: Exception: FileNotFoundError: [Errno 2] No such file or directory: '.../rustc-1.83.0-src/src/stage0.json' There are changes in use of key-value format in stage0 file in rust sources and the rust recipe should be apdated for that. Changes in rust: rust-lang/rust@1adfffd (From OE-Core rev: 5f25af08ec364d5ed834c5b67ac8609459419fbf) Signed-off-by: Yash Shinde <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
1 parent e521e4f commit 568810a

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

meta/recipes-devtools/rust/rust_1.84.1.bb

+30-17
Original file line numberDiff line numberDiff line change
@@ -327,35 +327,48 @@ python do_update_snapshot() {
327327

328328
from collections import defaultdict
329329

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', '')
336346

337347
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
345358
snapshot = """\
346359
## 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
348361
## Rust is self-hosting and bootstraps itself with a pre-built previous version of itself.
349362
## The exact (previous) version that has been used is specified in the source tarball.
350363
## The version is replicated here.
351364
352365
SNAPSHOT_VERSION = "%s"
353366
354367
""" % compiler_version
355-
368+
# Add the checksum components to the snapshot
356369
for arch, components in src_uri.items():
357370
snapshot += "\n".join(components) + "\n\n"
358-
371+
# Add the additional snapshot URIs
359372
snapshot += """\
360373
SRC_URI += " \\
361374
${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
369382
RUSTC_SNAPSHOT = "rustc-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu"
370383
CARGO_SNAPSHOT = "cargo-${SNAPSHOT_VERSION}-${RUST_BUILD_ARCH}-unknown-linux-gnu"
371384
""" % config_dist_server
372-
385+
# Write the updated snapshot information to the rust-snapshot.inc file
373386
with open(os.path.join(d.getVar("THISDIR"), "rust-snapshot.inc"), "w") as f:
374387
f.write(snapshot)
375388
}

0 commit comments

Comments
 (0)