Skip to content

Commit fea541f

Browse files
committed
Sanitize hidden vendored paths for PPA builds
1 parent 3eb2707 commit fea541f

4 files changed

Lines changed: 27 additions & 2 deletions

File tree

.github/workflows/launchpad_ppa.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,25 @@ jobs:
138138
mkdir -p .cargo
139139
cargo vendor --locked vendor > .cargo/config.toml
140140
python3 debian/sanitize-vendor.py
141+
python3 - <<'PY'
142+
import json
143+
from pathlib import Path, PurePosixPath
144+
145+
offenders = []
146+
for checksum_file in Path("vendor").rglob(".cargo-checksum.json"):
147+
data = json.loads(checksum_file.read_text())
148+
for rel_path in data.get("files", {}):
149+
if rel_path.endswith(".orig") or any(
150+
part.startswith(".") for part in PurePosixPath(rel_path).parts
151+
):
152+
offenders.append(f"{checksum_file}: {rel_path}")
153+
154+
if offenders:
155+
raise SystemExit(
156+
"vendor checksum still references hidden/orig files:\n"
157+
+ "\n".join(offenders[:50])
158+
)
159+
PY
141160
grep -q 'replace-with = "vendored-sources"' .cargo/config.toml
142161
grep -q '\[source.vendored-sources\]' .cargo/config.toml
143162
grep -q '^directory = "vendor"$' .cargo/config.toml
2.72 KB
Binary file not shown.

debian/prepare-source-package.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ echo "Vendoring Rust dependencies..."
2222
rm -rf vendor .cargo
2323
mkdir -p .cargo
2424
cargo vendor --locked vendor > .cargo/config.toml
25+
python3 debian/sanitize-vendor.py
2526

2627
if ! grep -q '^directory = "vendor"$' .cargo/config.toml; then
2728
echo "Error: cargo vendor did not generate the expected source replacement config"

debian/sanitize-vendor.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
from pathlib import Path
55

66

7+
def should_strip(rel_path: str) -> bool:
8+
path = Path(rel_path)
9+
return rel_path.endswith(".orig") or any(part.startswith(".") for part in path.parts)
10+
11+
712
def main() -> int:
813
vendor_root = Path("vendor")
914
if not vendor_root.is_dir():
@@ -17,7 +22,7 @@ def main() -> int:
1722

1823
removed = []
1924
for rel_path in list(files.keys()):
20-
if rel_path.endswith(".orig"):
25+
if should_strip(rel_path):
2126
removed.append(rel_path)
2227
files.pop(rel_path, None)
2328
target = crate_dir / rel_path
@@ -28,7 +33,7 @@ def main() -> int:
2833
checksum_file.write_text(
2934
json.dumps(data, separators=(",", ":"), sort_keys=True) + "\n"
3035
)
31-
print(f"sanitized {checksum_file} ({len(removed)} .orig entries)")
36+
print(f"sanitized {checksum_file} ({len(removed)} hidden/orig entries)")
3237

3338
return 0
3439

0 commit comments

Comments
 (0)