Skip to content

Commit af60b5d

Browse files
committed
build: stop tmp/go.mod sentinel churn from clean targets
tmp/go.mod is a committed sentinel module that keeps `go list ./...` out of the QEMU/Docker Go module caches under tmp/ (else `make ze-verify` fails with 'directory outside main module'). Two clean targets deleted it, and because it is tracked, git reported a phantom ` D tmp/go.mod` that sessions kept re-committing (commit 89d383c added a band-aid comment). - `clean` (rm -rf bin/ tmp/) now recreates tmp/go.mod byte-identically from HEAD after the rm. - `ze-clean-tmp` (deletes tmp/ files older than 24h) now spares go.mod via -not -name go.mod, matching how it already spares the cache dirs. The sentinel's comment is corrected: it is tracked (not 'local-only') and recreated by both clean and qemu-run.py. TMP_SENTINEL in qemu-run.py is kept byte-identical to tmp/go.mod (verified, 914 bytes each), so recreation never produces a diff. Verified: ze-clean-tmp scratch-dir test keeps go.mod while deleting stale files; make -n clean shows the recreation; byte-identity MATCH.
1 parent be0bda3 commit af60b5d

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎Makefile‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,18 @@ ze-regen-check: ze-regen
426426
ze-doc-links:
427427
@python3 scripts/dev/check_doc_links.py
428428

429+
# clean wipes bin/ and tmp/, then restores the tmp/ sentinel module
430+
# (tmp/go.mod) byte-identically from git so clearing scratch never shows up
431+
# as a phantom "deleted tmp/go.mod" in git status. See tmp/go.mod.
429432
clean:
430433
@echo "Cleaning..."
431434
rm -rf bin/ tmp/
432435
rm -f coverage.out coverage.html
436+
@mkdir -p tmp && git show HEAD:tmp/go.mod > tmp/go.mod 2>/dev/null || true
433437

434438
ze-clean-tmp:
435439
@echo "Cleaning tmp/ scratch files older than 24h..."
436-
@find tmp/ -maxdepth 1 -type f -mmin +1440 -delete 2>/dev/null || true
440+
@find tmp/ -maxdepth 1 -type f -not -name go.mod -mmin +1440 -delete 2>/dev/null || true
437441
@find tmp/ -maxdepth 1 -type d -not -name tmp -not -name session \
438442
-not -name go-cache -not -name golangci-lint-cache -not -name kernel \
439443
-mmin +1440 -exec rm -rf {} + 2>/dev/null || true

‎scripts/evidence/qemu-run.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,14 @@ def repo_root() -> Path:
5454
// (e.g. tmp/qemu/gomodcache, tmp/linux-gomodcache). Without this sentinel,
5555
// `go list ./...` descends into those caches and fails with
5656
// "directory ... outside main module or its selected dependencies", which
57-
// breaks `make ze-verify`. tmp/ is .gitignored, so this file is local-only;
58-
// scripts/evidence/qemu-run.py recreates it on each run.
57+
// breaks `make ze-verify`.
58+
//
59+
// This file is committed (tracked) so it is always present, including on a
60+
// fresh checkout before any QEMU/Docker run; everything else under tmp/ is
61+
// .gitignored. `make clean` wipes tmp/ and then recreates this file
62+
// byte-identically, and qemu-run.py's ensure_tmp_sentinel() recreates it
63+
// too, so clearing tmp/ never shows up as a git change. Keep this content
64+
// in sync with TMP_SENTINEL in scripts/evidence/qemu-run.py.
5965
module ze-tmp-scratch
6066
6167
go 1.25

‎tmp/go.mod‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55
// (e.g. tmp/qemu/gomodcache, tmp/linux-gomodcache). Without this sentinel,
66
// `go list ./...` descends into those caches and fails with
77
// "directory ... outside main module or its selected dependencies", which
8-
// breaks `make ze-verify`. tmp/ is .gitignored, so this file is local-only;
9-
// scripts/evidence/qemu-run.py recreates it on each run.
8+
// breaks `make ze-verify`.
9+
//
10+
// This file is committed (tracked) so it is always present, including on a
11+
// fresh checkout before any QEMU/Docker run; everything else under tmp/ is
12+
// .gitignored. `make clean` wipes tmp/ and then recreates this file
13+
// byte-identically, and qemu-run.py's ensure_tmp_sentinel() recreates it
14+
// too, so clearing tmp/ never shows up as a git change. Keep this content
15+
// in sync with TMP_SENTINEL in scripts/evidence/qemu-run.py.
1016
module ze-tmp-scratch
1117

1218
go 1.25

0 commit comments

Comments
 (0)