[PATCH 3/9] scripts: do not assume the new version of the crate is present
Paolo Bonzini <[email protected]>
| Newsgroups | org.nongnu.qemu-rust,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> --- scripts/get-wraps-from-cargo-registry.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/scripts/get-wraps-from-cargo-registry.py b/scripts/get-wraps-from-cargo-registry.py index 0095bd937ec..8b45c1551f5 100755 --- a/scripts/get-wraps-from-cargo-registry.py +++ b/scripts/get-wraps-from-cargo-registry.py @@ -15,6 +15,7 @@ import filecmp import glob import os +import shutil import subprocess import sys @@ -50,7 +51,7 @@ def find_installed_crate(self, namever: str) -> str | None: 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 @@ def update_subproject(self, wrap_file: str, source_namever: str) -> None: 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 @@ def update_subproject(self, wrap_file: str, source_namever: str) -> None: 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 @@ def update_subproject(self, wrap_file: str, source_namever: str) -> None: ) 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( -- 2.55.0