Skip to content

fix(build): make %prep idempotent for hidden files#595

Open
traviswu-bigstack wants to merge 1 commit into
developfrom
fix/prep-idempotent-hidden-files
Open

fix(build): make %prep idempotent for hidden files#595
traviswu-bigstack wants to merge 1 commit into
developfrom
fix/prep-idempotent-hidden-files

Conversation

@traviswu-bigstack

@traviswu-bigstack traviswu-bigstack commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it

Resolves a build failure where rpmbuild %prep aborted with
mv: cannot move '.../.understand-anything' ...: Directory not empty.

Root cause: the repo had a committed code-indexer cache .understand-anything/
(5 files, ~46k lines). %prep cleaned the build dir with rm -rf ./* (a shell glob,
which skips dotfiles) but flattened the extracted source with find ... -name '*'
(which matches dotfiles). So .understand-anything was flattened into BUILD/,
survived the next rm -rf ./*, and collided on the next mv. It only surfaced once
the make-mtime always-rebuild bug (bigstack-oss/cubecos#1005) made %prep re-run
every build.

Two complementary fixes:

  1. Idempotent %prep (defense-in-depth): clear with
    find . -mindepth 1 -maxdepth 1 -exec rm -rf {} + — dotfile-inclusive, matching the
    flatten — so any stray hidden file is handled. POSIX find (not shopt dotglob)
    because rpm runs %prep under /bin/sh.
  2. Remove the root cause: delete the committed .understand-anything/ cache (local
    tooling state, not source — it rode into every git clone --depth 1 and the rpm
    source tarball) and add it to .gitignore so it can't be re-committed.

Linked issue

Refs bigstack-oss/cubecos#1005 (the build-incrementality bug that surfaced this).

The committed code-indexer cache .understand-anything (5 files) is a dotfile dir,
so %prep's `rm -rf ./*` skipped it while the `find ... -name '*'` flatten matched
it -> it leaked into BUILD/, survived the next clean, and collided on the next mv
("Directory not empty").

- Make %prep idempotent: clear with `find . -mindepth 1 -maxdepth 1 -exec rm -rf {} +`
  (dotfile-inclusive, matching the flatten), so any stray hidden file is handled.
- Remove the committed .understand-anything cache (local tooling state, not source)
  and gitignore it so it can't be re-committed.

Refs bigstack-oss/cubecos#1005

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Travis Wu <travis.wu@bigstack.co>
@traviswu-bigstack traviswu-bigstack force-pushed the fix/prep-idempotent-hidden-files branch from ebb9ec8 to 59d48e4 Compare June 25, 2026 04:20
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