Skip to content

build-packages: drop a stale cached package after a same-version rebuild - #875

Merged
derekross merged 3 commits into
derekross:mainfrom
kdegeek:tools-build-cache
Nov 18, 2026
Merged

derekross merged 3 commits into
derekross:mainfrom
kdegeek:tools-build-cache

Conversation

@kdegeek

@kdegeek kdegeek commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

What and why

A forced rebuild can replace a package's bytes and keep its file name. tools/build-packages and tools/build-rootfs share one pacman cache ($ALARM_CACHE/pkg, mounted as /var/cache/pacman/pkg). That cache still holds the old file under the same name, so the next pacstrap takes the cached copy, and its checksum no longer matches the rebuilt repository's database.

add_to_repo now removes a cached file of the same name, with its detached signature, when its bytes differ from the package just added. Identical cache entries and other packages are left alone.

Device and build

  • Phone: none: tools only (runs on the build machine)
  • Kernel release: n/a
  • Packages changed: none

Checks (no phone needed)

  • tools/pr-check upstream/main passes
  • tests/build-packages-cache (new, added to tests/all): passes, and it fails (an assertion) against main's tools/build-packages. It runs the real add_to_repo on synthetic package files. A differing cache entry and its signature are removed, an identical one is kept with its signature, an unrelated package is kept, and a local import keeps the signature it came with.
  • bash -n and shellcheck -S warning on the touched scripts: no new warnings against main
  • Full tests/all: not run, only the new test and the touched scripts' checks above

On the phone

Nothing here runs on a phone.

🤖 Generated with Claude Code

A forced rebuild can replace a package's bytes without changing its
file name. The pacman cache that tools/build-packages and
tools/build-rootfs share ($ALARM_CACHE/pkg, mounted as
/var/cache/pacman/pkg) still holds the old file under that name, so the
next pacstrap takes the cached copy, whose checksum no longer matches
the rebuilt repository's database. add_to_repo now removes a cached file
of the same name, and its detached signature, when its bytes differ from
the package just added; identical cache entries and other packages are
left alone.

tests/build-packages-cache runs the real add_to_repo with synthetic
package files: a differing cache entry and its signature are removed, an
identical one is kept with its signature, an unrelated package is kept,
and a local import keeps the signature it came with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derekross

Copy link
Copy Markdown
Owner

Thank you, @kdegeek. The bug is real: the cache on my laptop holds our own packages with their signatures under exactly these names, so a --force rebuild leaves the old bytes there and the next pacstrap stops on the checksum. The fix is in the right place (every way into the repository goes through add_to_repo), it can only name a file directly in the cache, it leaves identical entries and the pinned upstream packages alone, and removing a cache entry costs a re-fetch that pacman verifies. On your branch merged with today's main the new test passes, and it fails with main's tools/build-packages, as you say.

Two small things in the tests before I merge:

  1. tests/all: please don't add the suite to the long loop line. Every pull request that adds one there conflicts with every other (yours does with tools: phone-gesture-test, on-phone gesture tests of the quick-settings pages #652 today). The file ends with a block for new suites, one per line; add it there instead:

    echo "# tests/build-packages-cache"   # a forced same-version rebuild drops the stale cached package
    tests/build-packages-cache
  2. tests/pinned-packages and tests/local-builds run the real tools/build-packages without setting ALARM_CACHE, so add_to_repo now looks their fixture names up in the developer's own ~/.cache/omamobile-rootfs/pkg, and would remove a same-named file there. Nothing matches today (I ran both and my cache was untouched), but a fixture named after a real package would delete from the build machine's cache during a test run. Please give both suites export ALARM_CACHE=$t/cache, as tests/build-packages-host-tools does.

I'll approve the CI run now; with those two in and the run green this goes in.

@derekross derekross left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI ran on this head and both jobs pass, your new suite among them (and shellcheck, which I didn't have locally).

The two test changes from this morning are still open, and both are small, so I'll push them to your branch myself rather than hold this: the suite's line moves to the one-per-line block at the end of tests/all (your branch now conflicts there with #900 as well), and tests/pinned-packages and tests/local-builds get export ALARM_CACHE=$t/cache. I ran all three suites with those changes on your branch merged with today's main and they pass. I'll merge when CI is green on that push. If you'd rather make them yourself, say so and I'll wait.

derekross and others added 2 commits November 18, 2026 13:06
…oper's package cache

tests/build-packages-cache moves to the one-suite-per-line block at the end
of tests/all, and tests/local-builds and tests/pinned-packages set
ALARM_CACHE to their scratch folder, since add_to_repo now removes from
the cache.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@derekross
derekross merged commit b7c3579 into derekross:main Nov 18, 2026
2 checks passed
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.

2 participants