scripts: rename variable in scripts/get-wraps-from-cargo-registry.py
Do first the change that makes the diff larger than it should be. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo Bonzini committed
Jul 24, 2026 at 17:12 UTC
b2a94481fea56c082c401750b4d25f8409db6aa4
1 file changed
+16
-16
scripts/get-wraps-from-cargo-registry.py
+16
-16
@@ -47,20 +47,20 @@ class UpdateSubprojects:
47
matches = sorted(glob.glob(f"{path}.*"))
48
return os.path.basename(matches[0]) if matches else None
49
50
- def compare_build_rs(self, orig_dir: str, registry_namever: str) -> None:
50
+ def compare_build_rs(self, orig_dir: str, source_namever: str) -> None:
51
"""Warn if the build.rs in the original directory differs from the registry version."""
52
orig_build_rs = os.path.join(orig_dir, "build.rs")
53
- new_build_rs = os.path.join(self.cargo_registry, registry_namever, "build.rs")
53
+ new_build_rs = os.path.join(self.cargo_registry, source_namever, "build.rs")
54
55
msg = None
56
if os.path.isfile(orig_build_rs) != os.path.isfile(new_build_rs):
57
if os.path.isfile(orig_build_rs):
58
- msg = f"build.rs removed in {registry_namever}"
58
+ msg = f"build.rs removed in {source_namever}"
59
if os.path.isfile(new_build_rs):
60
- msg = f"build.rs added in {registry_namever}"
60
+ msg = f"build.rs added in {source_namever}"
61
62
elif os.path.isfile(orig_build_rs) and not filecmp.cmp(orig_build_rs, new_build_rs, shallow=False):
63
- msg = f"build.rs changed from {orig_dir} to {registry_namever}"
63
+ msg = f"build.rs changed from {orig_dir} to {source_namever}"
64
# diff exits non-zero when the files differ, which is expected here
65
subprocess.run(["diff", "-u", orig_build_rs, new_build_rs])
66
@@ -68,7 +68,7 @@ class UpdateSubprojects:
68
print(f"⚠️ Warning: {msg}")
69
print(" This may affect the build process - please review the differences.")
70
71
- def update_subproject(self, wrap_file: str, registry_namever: str) -> None:
71
+ def update_subproject(self, wrap_file: str, source_namever: str) -> None:
72
"""Modify [wrap-file] section to point to self.cargo_registry."""
73
assert wrap_file.endswith("-rs.wrap")
74
wrap_name = wrap_file[:-5]
@@ -83,18 +83,18 @@ class UpdateSubprojects:
83
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 != registry_namever:
87
- self.compare_build_rs(orig_dir, registry_namever)
86
+ if os.path.exists(orig_dir) and orig_dir != source_namever:
87
+ self.compare_build_rs(orig_dir, source_namever)
88
89
if self.dry_run:
90
- if orig_dir == registry_namever:
90
+ if orig_dir == source_namever:
91
print(f"Will install {orig_dir} from registry.")
92
else:
93
- print(f"Will replace {orig_dir} with {registry_namever}.")
93
+ print(f"Will replace {orig_dir} with {source_namever}.")
94
self.changes += 1
95
return
96
97
- config["wrap-file"]["directory"] = registry_namever
97
+ config["wrap-file"]["directory"] = source_namever
98
for key in list(config["wrap-file"].keys()):
99
if key.startswith("source"):
100
del config["wrap-file"][key]
@@ -111,10 +111,10 @@ class UpdateSubprojects:
111
with open(wrap_file, "w") as f:
112
config.write(f)
113
114
- if orig_dir == registry_namever:
114
+ if orig_dir == source_namever:
115
print(f"Installing {orig_dir} from registry.")
116
else:
117
- print(f"Replacing {orig_dir} with {registry_namever}.")
117
+ print(f"Replacing {orig_dir} with {source_namever}.")
118
119
subprocess.run(
120
["meson", "subprojects", "download", wrap_name],
@@ -162,12 +162,12 @@ class UpdateSubprojects:
162
for wrap_file in sorted(glob.glob("*-rs.wrap")):
163
namever = wrap_file[:-8] # Remove '-rs.wrap'
164
165
- registry_namever = self.find_installed_crate(namever)
166
- if not registry_namever:
165
+ source_namever = self.find_installed_crate(namever)
166
+ if not source_namever:
167
print(f"No installed crate found for {wrap_file}")
168
continue
169
170
- self.update_subproject(wrap_file, registry_namever)
170
+ self.update_subproject(wrap_file, source_namever)
171
172
if self.changes:
173
if self.dry_run: