setup: fetch mesa from the release tarball and apply patches idempotently #391

Open
github-bot wants to merge 3 commits from github-bot/gh-391 into main AGit
Owner

@⁠cerealfordinner on GitHub · 2026-12-03 23:50 UTC · original
cerealfordinner:upstream/mesa-setup → main · +54 −4 · 1 files · 3 commits · open

The gitlab.freedesktop.org shallow clone fails with early EOF and an unexpected disconnect often enough to make setup unreliable. Use the release tarball from archive.mesa3d.org instead, then apply the same mesa.patch (and mesa.*.patch siblings) in a git repository made from the extracted source.

The tarball and patches are stamped: when either changes, setup resets to the extracted source and applies the patches again. The old path applied them only while extracting, so a re-run over an already-extracted tree could silently build unpatched mesa.

**@⁠cerealfordinner** on GitHub · 2026-12-03 23:50 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/391) `cerealfordinner:upstream/mesa-setup` → `main` · +54 −4 · 1 files · 3 commits · open The gitlab.freedesktop.org shallow clone fails with early EOF and an unexpected disconnect often enough to make setup unreliable. Use the release tarball from archive.mesa3d.org instead, then apply the same mesa.patch (and mesa.*.patch siblings) in a git repository made from the extracted source. The tarball and patches are stamped: when either changes, setup resets to the extracted source and applies the patches again. The old path applied them only while extracting, so a re-run over an already-extracted tree could silently build unpatched mesa.
The gitlab.freedesktop.org shallow clone fails with early EOF and an
unexpected disconnect often enough to make setup unreliable. Use the
release tarball from archive.mesa3d.org instead, then apply the same
mesa.patch (and mesa.*.patch siblings) in a git repository made from the
extracted source.

The tarball and patches are stamped: when either changes, setup resets to
the extracted source and applies the patches again. The old path applied
them only while extracting, so a re-run over an already-extracted tree
could silently build unpatched mesa.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 23:52:08 +00:00
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 11:28 UTC · original

Two things stop this merging, both quick:

  • setup.sh:163 is if [ ! -d "$src_dir/meson.build" ]. meson.build is a file, so -d is always false and the block always runs: deps/mesa is removed, re-extracted and re-git init-ed on every ./setup.sh, and since the build directory lives inside that tree (setup.sh:154) mesa is rebuilt from scratch every time. -f — and that is the opposite of what the title promises.
  • setup.sh:175/:178 run git -C "$src_dir" commit. On a fresh machine there is no user.name/user.email, so it exits 128 "Author identity unknown" and set -euo pipefail aborts setup before mesa is built. Pass git -c user.name=… -c user.email=… commit (or the GIT_AUTHOR_*/GIT_COMMITTER_* env) for that call. The old clone path never needed a commit, so this is a new failure mode for exactly the audience setup.sh has.

Then, before it is idempotent in the sense the title means:

  • Extraction never looks at which tarball is on disk: bumping MESA[1]/MESA[2] leaves the old tree in place, re-applies patches, and the stamp (setup.sh:161) matches while the source is stale. Store the tarball sum (.tarball-sum) and re-extract when it differs.
  • The guard that used to stop setup when deps/mesa had edits the patch does not (upstream/main:setup.sh:58-65, "keep them with tools/patch.sh") is gone; step_mesa now does a bare git reset --hard, so in-progress work is silently discarded. tools/patch.sh mesa still works, which makes the silent reset worse.

Also check setup.sh:176's recovery branch: after a kill between git init and git commit it is reachable, and git add -A there will sweep in deps/mesa/build unless the tree's .gitignore excludes it.

**@⁠Luxuride** on GitHub · 2026-12-04 11:28 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/391#issuecomment-7410146668) Two things stop this merging, both quick: - `setup.sh:163` is `if [ ! -d "$src_dir/meson.build" ]`. `meson.build` is a file, so `-d` is always false and the block always runs: `deps/mesa` is removed, re-extracted and re-`git init`-ed on *every* `./setup.sh`, and since the build directory lives inside that tree (`setup.sh:154`) mesa is rebuilt from scratch every time. `-f` — and that is the opposite of what the title promises. - `setup.sh:175`/`:178` run `git -C "$src_dir" commit`. On a fresh machine there is no `user.name`/`user.email`, so it exits 128 "Author identity unknown" and `set -euo pipefail` aborts setup before mesa is built. Pass `git -c user.name=… -c user.email=… commit` (or the `GIT_AUTHOR_*`/`GIT_COMMITTER_*` env) for that call. The old clone path never needed a commit, so this is a new failure mode for exactly the audience setup.sh has. Then, before it is idempotent in the sense the title means: - Extraction never looks at *which* tarball is on disk: bumping `MESA[1]`/`MESA[2]` leaves the old tree in place, re-applies patches, and the stamp (`setup.sh:161`) matches while the source is stale. Store the tarball sum (`.tarball-sum`) and re-extract when it differs. - The guard that used to stop setup when `deps/mesa` had edits the patch does not (`upstream/main:setup.sh:58-65`, "keep them with tools/patch.sh") is gone; `step_mesa` now does a bare `git reset --hard`, so in-progress work is silently discarded. `tools/patch.sh mesa` still works, which makes the silent reset worse. Also check `setup.sh:176`'s recovery branch: after a kill between `git init` and `git commit` it is reachable, and `git add -A` there will sweep in `deps/mesa/build` unless the tree's `.gitignore` excludes it.
Author
Owner

@⁠cerealfordinner on GitHub · 2026-12-04 22:42 UTC · original

Fixed the review items (-d→-f, git identity on commit, tarball-sum stamp) and rebased onto current main.

**@⁠cerealfordinner** on GitHub · 2026-12-04 22:42 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/391#issuecomment-7426239176) Fixed the review items (`-d`→`-f`, git identity on commit, tarball-sum stamp) and rebased onto current main.
github-bot force-pushed github-bot/gh-391 from ad4541b466 to 9a49ab35ce 2026-12-04 22:48:12 +00:00 Compare
Per review: the bare reset --hard silently discarded in-progress mesa
edits, and the recovery commit's git add -A could sweep in deps/mesa/build.
Add a git diff --quiet guard that stops with the tools/patch.sh hint before
resetting, and write a .gitignore excluding /build/ before the commit.

Signed-off-by: cerealfordinner <[email protected]>
Author
Owner

@⁠cerealfordinner on GitHub · 2026-12-04 23:15 UTC · original

Pushed the two remaining review items:

  • Silent reset — step_mesa now runs git diff --quiet before the reset --hard and stops with deps/mesa has changes the patch does not: keep them with tools/patch.sh mesa if there are unstaged edits, so in-progress work isn't dropped without a word.
  • Build dir sweep — a .gitignore excluding /build/ is written before the init/commit, so the recovery git add -A (kill between init and commit) can't pull deps/mesa/build into the history.

Verified the guard/gitignore logic in a throwaway tree (clean tree passes, unstaged edit trips the guard, staged patches fall through to re-apply) and bash -n setup.sh is clean.

**@⁠cerealfordinner** on GitHub · 2026-12-04 23:15 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/391#issuecomment-7426879762) Pushed the two remaining review items: - **Silent reset** — `step_mesa` now runs `git diff --quiet` before the `reset --hard` and stops with `deps/mesa has changes the patch does not: keep them with tools/patch.sh mesa` if there are unstaged edits, so in-progress work isn't dropped without a word. - **Build dir sweep** — a `.gitignore` excluding `/build/` is written before the init/commit, so the recovery `git add -A` (kill between init and commit) can't pull `deps/mesa/build` into the history. Verified the guard/gitignore logic in a throwaway tree (clean tree passes, unstaged edit trips the guard, staged patches fall through to re-apply) and `bash -n setup.sh` is clean.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/391/head:github-bot/gh-391'
git switch 'github-bot/gh-391'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-391'
git switch 'github-bot/gh-391'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-391'
git switch 'github-bot/gh-391'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-391'
git switch 'main'
git merge --squash 'github-bot/gh-391'
git switch 'main'
git merge --ff-only 'github-bot/gh-391'
git switch 'main'
git merge 'github-bot/gh-391'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.