@samitouri / QOSamiQemu / commits / 68b042953b

scripts: do not assume the new version of the crate is present

Until now, the new version of the crate was always there in the registry. This will be different when crates are downloaded from Cargo.lock, so delay the comparison of build.rs until a point at which both source directories have been extracted. Since the .wrap file at this point points to the new directory, delete the old one "by hand" with shutil.rmtree instead of asking Meson to do it before the .wrap file is changed. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo Bonzini committed Aug 21, 2026 at 09:46 UTC 68b042953b0d0ce31c9a38402f2fabc1a02a04a4
1 file changed +6 -13
scripts/get-wraps-from-cargo-registry.py
+6 -13
@@ -15,6 +15,7 @@ import configparser
15 import filecmp
16 import glob
17 import os
18 +import shutil
19 import subprocess
20 import sys
21
@@ -50,7 +51,7 @@ class UpdateSubprojects:
51 def compare_build_rs(self, orig_dir: str, source_namever: str) -> None:
52 """Warn if the build.rs in the original directory differs from the registry version."""
53 orig_build_rs = os.path.join(orig_dir, "build.rs")
53 - new_build_rs = os.path.join(self.cargo_registry, source_namever, "build.rs")
54 + new_build_rs = os.path.join(source_namever, "build.rs")
55
56 msg = None
57 if os.path.isfile(orig_build_rs) != os.path.isfile(new_build_rs):
@@ -81,10 +82,7 @@ class UpdateSubprojects:
82 if "wrap-file" not in config:
83 return
84
84 - # do not download the wrap, always use the local copy
85 orig_dir = config["wrap-file"]["directory"]
86 - if os.path.exists(orig_dir) and orig_dir != source_namever:
87 - self.compare_build_rs(orig_dir, source_namever)
86
87 if self.dry_run:
88 if orig_dir == source_namever:
@@ -99,15 +97,6 @@ class UpdateSubprojects:
97 if key.startswith("source"):
98 del config["wrap-file"][key]
99
102 - # replace existing directory with installed version
103 - if os.path.exists(orig_dir):
104 - subprocess.run(
105 - ["meson", "subprojects", "purge", "--confirm", wrap_name],
106 - cwd=self.top_srcdir,
107 - env=env,
108 - check=True,
109 - )
110 -
100 with open(wrap_file, "w") as f:
101 config.write(f)
102
@@ -124,6 +113,10 @@ class UpdateSubprojects:
113 )
114 self.changes += 1
115
116 + if os.path.exists(orig_dir) and orig_dir != source_namever:
117 + self.compare_build_rs(orig_dir, source_namever)
118 + shutil.rmtree(orig_dir)
119 +
120 @staticmethod
121 def parse_cmdline() -> argparse.Namespace:
122 parser = argparse.ArgumentParser(