repo: cache stage packages for faster future use.
Metadata
Current evaluation
Superseded by pull request #1122. The stage package caching changes were abandoned in favor of an alternative implementation to improve build performance and cleanbuild compatibility.
Suggested action: —
No scores available.
Issue body
Snapcraft currently caches stage packages, but doesn't actually use them. This PR fixes LP: [#1661383](https://bugs.launchpad.net/snapcraft/+bug/1661383) by using them, and making sure cleanbuild can use the cache as well.
The way this ended up being done isn't ideal. Since `apt.Cache().fetch_archives()` seems to mangle (some) package names for no apparent reason, it's impossible to fetch stage packages with it and later determine which packages were pulled as the filenames on disk don't match up to the filenames in the archive. The settled-upon solution was to pull stage-packages using `apt.package.Version().fetch_binary()`. This works well and actually simplifies the caching mechanism, but has a few drawbacks:
- It prints directly to stdout when a package is already cached.
- Fetching stage packages one-by-one means one loses a sense of how long the overall process will actually take.
Note also that this PR **copies** the cache into the cleanbuild container as opposed to bind-mounting read-only. This was done so the caching code was more robust. Otherwise it would need to account for being unable to do the following things:
- Being unable to clean the cache when sources changes
- Being unable to update the index
- Being unable to fetch packages
And have backup plans. Such code would be complex and difficult to test, and it seemed it wasn't worth it for a relatively small efficiency gain, particularly considering that ideally the cache would be editable from the container anyway, that just doesn't seem possible today without modifications to /`etc/subgid`. Of course this is up for debate!
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Superseded by pull request #1122. The stage package caching changes were abandoned in favor of an alternative implementation to improve build performance and cleanbuild compatibility. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Implemented stage package caching to accelerate builds and support cleanbuild. Copies cache into containers instead of bind-mounting. Closed in favor of PR #1122, which supersedes this implementation. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Superseded by PR #1122. The stage package caching implementation was abandoned in favor of an alternative approach that achieves the same cleanbuild optimization without the noted drawbacks. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1122 repo: cache stage packages for faster future use. | snapcraft | merged | Merged to fix Snapcraft ignoring cached stage packages. The implementation uses fetch_binary for reliable retrieval and copies the cache into cleanbuild containers for robustness. Approved by two reviewers. | |
| #3110 repo: use persistent cache for fetching stage packages | snapcraft | closed | Proposed persistent caching for stage packages was closed without merging. Unresolved design questions regarding cache purging and location, alongside a lack of reviewer feedback, resulted in the changes being abandoned. |