diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2026-08-21 09:46:16 +0200 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2026-08-21 10:16:10 +0200 |
| commit | 68b042953b0d0ce31c9a38402f2fabc1a02a04a4 (patch) | |
| tree | 3bc09503bb329a6aa659cb3a4b179a8431a361ad /scripts | |
| parent | b2a94481fea56c082c401750b4d25f8409db6aa4 (diff) | |
| download | qemu-68b042953b0d0ce31c9a38402f2fabc1a02a04a4.tar.gz qemu-68b042953b0d0ce31c9a38402f2fabc1a02a04a4.zip | |
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>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/get-wraps-from-cargo-registry.py | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/scripts/get-wraps-from-cargo-registry.py b/scripts/get-wraps-from-cargo-registry.py index 0095bd937e..8b45c1551f 100755 --- a/scripts/get-wraps-from-cargo-registry.py +++ b/scripts/get-wraps-from-cargo-registry.py @@ -15,6 +15,7 @@ import configparser import filecmp import glob import os +import shutil import subprocess import sys @@ -50,7 +51,7 @@ class UpdateSubprojects: def compare_build_rs(self, orig_dir: str, source_namever: str) -> None: """Warn if the build.rs in the original directory differs from the registry version.""" orig_build_rs = os.path.join(orig_dir, "build.rs") - new_build_rs = os.path.join(self.cargo_registry, source_namever, "build.rs") + new_build_rs = os.path.join(source_namever, "build.rs") msg = None if os.path.isfile(orig_build_rs) != os.path.isfile(new_build_rs): @@ -81,10 +82,7 @@ class UpdateSubprojects: if "wrap-file" not in config: return - # do not download the wrap, always use the local copy orig_dir = config["wrap-file"]["directory"] - if os.path.exists(orig_dir) and orig_dir != source_namever: - self.compare_build_rs(orig_dir, source_namever) if self.dry_run: if orig_dir == source_namever: @@ -99,15 +97,6 @@ class UpdateSubprojects: if key.startswith("source"): del config["wrap-file"][key] - # replace existing directory with installed version - if os.path.exists(orig_dir): - subprocess.run( - ["meson", "subprojects", "purge", "--confirm", wrap_name], - cwd=self.top_srcdir, - env=env, - check=True, - ) - with open(wrap_file, "w") as f: config.write(f) @@ -124,6 +113,10 @@ class UpdateSubprojects: ) self.changes += 1 + if os.path.exists(orig_dir) and orig_dir != source_namever: + self.compare_build_rs(orig_dir, source_namever) + shutil.rmtree(orig_dir) + @staticmethod def parse_cmdline() -> argparse.Namespace: parser = argparse.ArgumentParser( |
