Files
punktfunk/packaging/flatpak/prune-windows-lock.py
T
enricobuehler 4c99b78366
apple / swift (push) Successful in 1m8s
apple / screenshots (push) Successful in 5m26s
android / android (push) Successful in 9m51s
arch / build-publish (push) Successful in 9m53s
deb / build-publish (push) Successful in 51s
decky / build-publish (push) Successful in 26s
docker / build-push (., web/Dockerfile, punktfunk-web) (push) Successful in 34s
docker / build-push (docs-site, docs-site/Dockerfile, punktfunk-docs) (push) Successful in 55s
docker / build-push (--build-arg FEDORA_VERSION=44, ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora44-rpm) (push) Successful in 2m42s
docker / build-push (ci, ci/rust-ci.Dockerfile, punktfunk-rust-ci) (push) Successful in 2m34s
docker / build-push (ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora-rpm) (push) Successful in 2m43s
flatpak / build-publish (push) Successful in 6m59s
docker / deploy-docs (push) Successful in 26s
ci / web (push) Successful in 52s
ci / docs-site (push) Successful in 1m2s
ci / bench (push) Successful in 5m16s
rpm / build-publish (43, bazzite, punktfunk-fedora-rpm) (push) Successful in 12m21s
ci / rust (push) Successful in 16m57s
rpm / build-publish (44, fedora-44, punktfunk-fedora44-rpm) (push) Successful in 12m59s
fix(flatpak): prune pf-client-core's windows-rs git dep from the sandbox manifest — offline build broken since a69a83b5
The flatpak's offline cargo build has failed on every run since the D3D11VA push:
pf-client-core now declares the same git-pinned `windows` dependency as the Windows
client (cfg(windows)-gated, never compiled on Linux), and `cargo --offline` needs
every DECLARED dependency's source just to build the unit graph — but windows-rs is
deliberately not vendored into cargo-sources.json (flatpak-builder would full-clone
the multi-GB repo; the reason prune-windows-lock.py exists). Removing the workspace
member alone no longer covers it.

New packaging/flatpak/prune-windows-toml.py (dependency-free, like its lock sibling)
strips windows-rs git entries from a manifest in place — single- or multi-line —
and the flatpak manifest runs it on crates/pf-client-core/Cargo.toml right after the
existing clients/windows member sed. Registry deps in the same cfg(windows) table
(wasapi, sdl3) are kept; they vendor normally.

Verified in a scratch worktree with both prunes applied: the TOML stays valid and
`cargo metadata` resolves ZERO windows-rs packages and zero git-source declarations
— nothing left for --offline to fetch. End-to-end proof is the flatpak CI run on
this push.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 12:52:26 +02:00

56 lines
2.3 KiB
Python
Executable File

#!/usr/bin/env python3
"""Write a copy of a Cargo.lock with the microsoft/windows-rs git packages removed.
The punktfunk workspace lockfile includes the windows-rs git dependencies — the whole
microsoft/windows-rs tree (windows-reactor + ~13 `windows-*` crates, all pinned to one git
rev) declared by `punktfunk-client-windows` and `pf-client-core` (D3D11VA). The flatpak
builds ONLY the Linux binaries, which never compile them, but `flatpak-cargo-generator.py`
walks the whole lock and emits a `type: git` source for windows-rs; `flatpak-builder` then
FULL-clones that multi-GB repo at "Downloading sources" → "No space left on device",
failing the build. (The manifests that DECLARE the git dep are neutralized in the build
sandbox too — see prune-windows-toml.py — since `cargo --offline` needs every declared
dependency's source even for cfg(windows)-gated entries it never compiles.)
Stripping those packages from the lock the generator sees is safe: the committed Cargo.lock is
left untouched for the `--locked` build, and `cargo --offline` only needs vendored sources for
the crates it actually compiles (none of the windows-rs crates are in the Linux client's
dependency closure).
Dependency-free (no tomlkit) so it also runs on the Steam Deck's stock python. Matches on the
`source =` line specifically, so a crate that merely *lists* a windows-rs dependency is kept.
Usage: prune-windows-lock.py <in Cargo.lock> <out lock>
"""
import sys
WINDOWS_RS = "github.com/microsoft/windows-rs"
def is_windows_rs(block: str) -> bool:
for line in block.splitlines():
s = line.strip()
if s.startswith("source = ") and WINDOWS_RS in s:
return True
return False
def main() -> None:
src, dst = sys.argv[1], sys.argv[2]
text = open(src).read()
# Cargo.lock (v3+) is a header followed by `[[package]]` blocks, no trailing [metadata].
parts = text.split("\n[[package]]\n")
header = parts[0]
kept, removed = [], 0
for block in parts[1:]:
if is_windows_rs(block):
removed += 1
else:
kept.append(block)
out = header + "".join("\n[[package]]\n" + b for b in kept)
open(dst, "w").write(out)
print(f"prune-windows-lock: removed {removed} windows-rs git crates ({src} -> {dst})")
if __name__ == "__main__":
main()