[PATCH 7/9] scripts: add the possibility of a quick update of the pacakge

Paolo Bonzini <[email protected]>
Newsgroups org.nongnu.qemu-rust,org.nongnu.qemu-devel
Message-ID <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
---
 scripts/get-wraps-from-cargo-registry.py | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/scripts/get-wraps-from-cargo-registry.py b/scripts/get-wraps-from-cargo-registry.py
index b3ae5a2c284..a26fe135eb9 100755
--- a/scripts/get-wraps-from-cargo-registry.py
+++ b/scripts/get-wraps-from-cargo-registry.py
@@ -166,10 +166,13 @@ def update_subproject(self, wrap_file: str, source_namever: str) -> None:
         orig_dir = section["directory"]
 
         if self.dry_run:
-            if orig_dir == source_namever:
-                print(f"Will install {orig_dir} from registry.")
-            else:
+            if orig_dir != source_namever:
                 print(f"Will replace {orig_dir} with {source_namever}.")
+            elif not os.path.exists(orig_dir) or self.cargo_registry:
+                print(f"Will install {orig_dir} from {self.source.origin}.")
+            else:
+                print(f"Will update {orig_dir} from cache.")
+                return
             self.changes += 1
             return
 
@@ -181,10 +184,19 @@ def update_subproject(self, wrap_file: str, source_namever: str) -> None:
         with open(wrap_file, "w") as f:
             config.write(f)
 
-        if orig_dir == source_namever:
+        if orig_dir != source_namever:
+            print(f"👉 Replacing {orig_dir} with {source_namever}.")
+        elif not os.path.exists(orig_dir) or self.cargo_registry:
             print(f"👉 Installing {orig_dir} from {self.source.origin}.")
         else:
-            print(f"👉 Replacing {orig_dir} with {source_namever}.")
+            print(f"👉 Updating {orig_dir} from cache.")
+            subprocess.run(
+                ["meson", "subprojects", "update", "--reset", wrap_name],
+                cwd=self.top_srcdir,
+                env=env,
+                check=True,
+            )
+            return
 
         subprocess.run(
             ["meson", "subprojects", "download", wrap_name],
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.