Skip to content

android: rebuild the drm artifacts on every package, and fail on a failed build - #34

Merged
joshuatam merged 1 commit into
gamenativefrom
fix/package-rebuild-drm-always
Nov 6, 2026
Merged

joshuatam merged 1 commit into
gamenativefrom
fix/package-rebuild-drm-always

Conversation

@joshuatam

Copy link
Copy Markdown
Collaborator

What this does

The payload's freshness guard compared mtimes: it failed if any file under an artifact's crates was newer than the artifact. Ages answer the wrong question, and they did so in both directions on the same day.

False positive, which is what started this. A branch switch rewrote modules/gndrm-android/Cargo.toml and modules/gndrm-daemon/Cargo.toml with byte-identical content, so they were newer than libgamenative_drm.so; cargo compares content hashes, correctly reported everything fresh, and left the artifact from three days earlier. The guard called it stale — and rerunning the package could never clear it, because nothing rewrites an artifact that cargo considers current:

error: …/libgamenative_drm.so is older than …/modules/gndrm-android/Cargo.toml

False negative, which is worse and silent. If a builder did not rewrite an artifact — because it failed, or skipped one — the old artifact was newer than the sources, so the guard passed and the payload carried it. A failed build-android.sh was not even checked: its exit code was ignored.

Change

The artifacts are always built by the run that packages them:

  • the Rust side is forced to recompile by touching the workspace's own *.rs and Cargo.toml — third-party crates stay cached, which holds this to ~53 s; the C shim and the C++ engine rebuild unconditionally anyway;
  • each builder's exit code is checked (build-lsfg.sh, build-shim.sh, build-android.sh);
  • every shipped artifact (libgndrm_shim.so, libgamenative_drm.so, libadrenotools_gamescope.so, liblsfg_engine.so) must be newer than a mark taken before the builders ran.

That is the only claim the guard has to make: the payload carries what this run built. check_fresh and its per-artifact source lists are gone.

Cost: a package run goes from ~60 s to ~111 s on a warm tree (measured; 53 s of it the forced drm rebuild).

Verified

case before after
identical content, newer mtime (the report) fails, unclearable packages, exit 0
syntax error in gndrm-uapi/src/lib.rs packages the previous artifact exit 1, error: build-android.sh failed
restored source — packages, exit 0

File

android/package-gamescope.sh only — the builder invocations, the freshness guard, and the artifact checks.

…iled build

The freshness guard compared mtimes: it failed if any file under an artifact's
crates was newer than the artifact itself. Ages answer the wrong question, and
they did so in both directions the same day.

It fired on a tree that was current. A branch switch rewrote
modules/gndrm-android/Cargo.toml and modules/gndrm-daemon/Cargo.toml with
byte-identical content, so they were newer than libgamenative_drm.so; cargo
compares content hashes, correctly reported everything fresh, and left the
artifact from three days before. The guard called it stale, and rerunning the
package could never clear it because nothing rewrites an artifact that cargo
considers current.

The other direction was worse and silent: if a builder did not rewrite an
artifact — because it failed, or because it skipped one — the old artifact was
newer than the sources, so the guard passed and the payload carried it. A
failed `build-android.sh` was not even checked; its exit code was ignored.

So the artifacts are now always built by the run that packages them. The Rust
side is forced to recompile by touching the workspace's own *.rs and
Cargo.toml (third-party crates stay cached, which is what holds this to ~53 s;
the C shim and the C++ engine rebuild unconditionally anyway), each builder's
exit code is checked, and every shipped artifact must be newer than a mark
taken before the builders ran. That is the only claim the guard needs to make:
the payload carries what this run built.

Cost: a package run goes from ~60 s to ~111 s on a warm tree.

Verified: the reported failure (identical content, newer mtime) packages and
exits 0; appending a syntax error to modules/gndrm-uapi/src/lib.rs exits 1 with
"error: build-android.sh failed" instead of packaging the previous artifact;
restoring the file and repacking exits 0.

File: android/package-gamescope.sh (the freshness guard, the builder
invocations and the artifact checks; check_fresh and its per-artifact source
lists are gone).
@joshuatam
joshuatam merged commit 6c38178 into gamenative Nov 6, 2026
1 check passed
@joshuatam
joshuatam deleted the fix/package-rebuild-drm-always branch November 6, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant