#!/usr/bin/env python3 """Blank the file lists in a vendor directory's .cargo-checksum.json files. Cargo refuses to use a vendored crate whose files do not match the checksums recorded there, which breaks two things at once: the quilt patches applied to debian/rust-vendor, and any crate shipping a file dpkg-source strips from the .debian.tar (.gitmodules, .gitignore, ...). An empty "files" map turns the check off; "package" is kept because cargo still reads it. """ import json import pathlib import sys vendor = pathlib.Path(sys.argv[1] if len(sys.argv) > 1 else "debian/rust-vendor") for path in sorted(vendor.glob("*/.cargo-checksum.json")): data = json.loads(path.read_text()) if data.get("files") == {}: continue blanked = {"files": {}} if "package" in data: blanked["package"] = data["package"] path.write_text(json.dumps(blanked, separators=(",", ":")))