From 4c99b78366f14dc29e6dcc0113b3f27be9632b7c Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Thu, 9 Jul 2026 12:52:26 +0200 Subject: [PATCH] =?UTF-8?q?fix(flatpak):=20prune=20pf-client-core's=20wind?= =?UTF-8?q?ows-rs=20git=20dep=20from=20the=20sandbox=20manifest=20?= =?UTF-8?q?=E2=80=94=20offline=20build=20broken=20since=20a69a83b5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- packaging/flatpak/io.unom.Punktfunk.yml | 22 ++++---- packaging/flatpak/prune-windows-lock.py | 15 +++--- packaging/flatpak/prune-windows-toml.py | 71 +++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 16 deletions(-) create mode 100644 packaging/flatpak/prune-windows-toml.py diff --git a/packaging/flatpak/io.unom.Punktfunk.yml b/packaging/flatpak/io.unom.Punktfunk.yml index 7c325e12..46d8a5bf 100644 --- a/packaging/flatpak/io.unom.Punktfunk.yml +++ b/packaging/flatpak/io.unom.Punktfunk.yml @@ -172,17 +172,19 @@ modules: # invocation doesn't inherit the SDK's default include search, so pass it explicitly). PF_FFVK_VULKAN_INCLUDE: /app/include build-commands: - # Drop the Windows client from the workspace before building. It pins windows-rs as a - # git dependency (cfg(windows)-gated, but cargo resolves it for the whole workspace - # regardless of target), and that git source is deliberately NOT vendored into - # cargo-sources.json — see packaging/flatpak/prune-windows-lock.py, which strips it so - # flatpak-builder doesn't full-clone the multi-GB windows-rs repo. Without removing the - # member, `cargo --offline` would try to load the un-vendored windows-rs source and fail - # ("can't checkout ... you are in the offline mode"). The flatpak never compiles the - # Windows client; this edits only the sandbox copy of Cargo.toml. (No --locked: the lock - # no longer matches the reduced member set; --offline still pins every crate to the - # vendored cargo-sources.json, so the build stays reproducible.) + # Drop every reference to the windows-rs GIT dependency before building. That git + # source is deliberately NOT vendored into cargo-sources.json — see + # packaging/flatpak/prune-windows-lock.py, which strips it so flatpak-builder doesn't + # full-clone the multi-GB windows-rs repo. But `cargo --offline` needs every DECLARED + # dependency's source just to build the unit graph (cfg(windows)-gated or not), so any + # manifest still pinning it fails with "can't checkout ... you are in the offline + # mode". Two declare it: the Windows client (removed from the workspace members) and + # pf-client-core's D3D11VA backend (entry pruned in place — nothing cfg(windows) + # compiles here). Both edits touch only the sandbox copies. (No --locked: the lock no + # longer matches the reduced graph; --offline still pins every crate to the vendored + # cargo-sources.json, so the build stays reproducible.) - sed -i '\#"clients/windows",#d' Cargo.toml + - python3 packaging/flatpak/prune-windows-toml.py crates/pf-client-core/Cargo.toml # One cargo invocation for both binaries: the shell and the Vulkan session binary it # execs for --connect/--browse. Building them together keeps skia-bindings' feature # unification identical to a workspace build (the pinned skia-binaries archive's diff --git a/packaging/flatpak/prune-windows-lock.py b/packaging/flatpak/prune-windows-lock.py index 8978f356..8877544f 100755 --- a/packaging/flatpak/prune-windows-lock.py +++ b/packaging/flatpak/prune-windows-lock.py @@ -1,12 +1,15 @@ #!/usr/bin/env python3 """Write a copy of a Cargo.lock with the microsoft/windows-rs git packages removed. -The punktfunk workspace lockfile includes `punktfunk-client-windows`' git dependencies — the -whole microsoft/windows-rs tree (windows-reactor + ~13 `windows-*` crates, all pinned to one -git rev). The flatpak builds ONLY the Linux client (`-p punktfunk-client-linux`), which never -references 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 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 diff --git a/packaging/flatpak/prune-windows-toml.py b/packaging/flatpak/prune-windows-toml.py new file mode 100644 index 00000000..5e81871b --- /dev/null +++ b/packaging/flatpak/prune-windows-toml.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +"""Strip microsoft/windows-rs git dependency entries from a Cargo.toml, in place. + +The sibling of prune-windows-lock.py, for the OTHER place the un-vendored windows-rs git +source leaks into the flatpak's offline build: `crates/pf-client-core` declares +`windows = { git = ... }` under `[target.'cfg(windows)'.dependencies]` (the D3D11VA decode +backend). The dependency is cfg-gated and never COMPILES on Linux, but `cargo --offline` +still needs every declared dependency's source available just to build the unit graph — and +windows-rs is deliberately not vendored into cargo-sources.json (flatpak-builder would +full-clone the multi-GB repo; see prune-windows-lock.py). Removing the entry from the +sandbox copy of the manifest is safe for a Linux-only build: nothing behind cfg(windows) +is compiled, so nothing misses the crate. + +Removes any top-level `name = { ... git = "...github.com/microsoft/windows-rs..." ... }` +entry, single- or multi-line (pf-client-core's spans a features array; the entry ends at +the first line that closes back to depth 0). Registry deps in the same table (wasapi, +sdl3) are kept — they vendor normally. + +Dependency-free (no tomlkit) so it also runs inside the flatpak build sandbox and on the +Steam Deck's stock python. + +Usage: prune-windows-toml.py [ ...] +""" + +import sys + +WINDOWS_RS = "github.com/microsoft/windows-rs" + + +def prune(text: str) -> tuple[str, int]: + lines = text.splitlines(keepends=True) + kept: list[str] = [] + removed = 0 + i = 0 + while i < len(lines): + line = lines[i] + stripped = line.strip() + # A dependency entry opening an inline table that pins the windows-rs git repo. + # Single-line entries contain the URL and balance their braces on the same line; + # multi-line entries (features arrays) run until the braces balance again. + if "=" in stripped and "{" in stripped and not stripped.startswith("#"): + depth = stripped.count("{") - stripped.count("}") + entry = [line] + j = i + 1 + while depth > 0 and j < len(lines): + s = lines[j] + depth += s.count("{") - s.count("}") + entry.append(s) + j += 1 + if any(WINDOWS_RS in e for e in entry): + removed += 1 + i = j + continue + kept.append(line) + i += 1 + return "".join(kept), removed + + +def main() -> None: + for path in sys.argv[1:]: + text = open(path).read() + out, removed = prune(text) + if removed == 0: + sys.exit(f"{path}: no windows-rs git entry found — already pruned, or the " + "dependency moved (update this script's callers)") + open(path, "w").write(out) + print(f"{path}: removed {removed} windows-rs git dependenc{'y' if removed == 1 else 'ies'}") + + +if __name__ == "__main__": + main()