repo: automatically prune unneeded stage-packages
Metadata
Current evaluation
Merged as b9faf80bd, adding APT cache analysis to remove automatically installed stage-packages left unneeded after alternative dependency resolution.
Resolution: closed resolved
Reason: PR #2119 was approved and merged as commit b9faf80bd. The change crawls APT cache changes and removes packages that became unnecessary during stage-package resolution.
Evaluated by: mr-cal-bot
No scores available.
Issue body
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?
- [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?
- [x] Have you successfully run `./runtests.sh static`?
- [x] Have you successfully run `./runtests.sh unit`?
-----
The apt cache doesn't do any hand-holding when it comes to alternative dependencies. As a result, it's possible for the snapcraft CLI to get into the following situation:
- A depends on B OR C
- B depends on D
- C conflicts with B
- A and C are `stage-packages`
If A is handled first, apt defaults to the first alternate (which is sensible), and marks both A and B (and, by extension, D) to be installed. Then C is handled, which automatically unmarks B, but doesn't do anything to D. As a result, A, C, and D are installed into the snap, even though D is no longer required.
Fix this by crawling the set of changes in the cache and taking care of anything that can be automatically removed.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged as b9faf80bd, adding APT cache analysis to remove automatically installed stage-packages left unneeded after alternative dependency resolution. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged in canonical/snapcraft#2119 (commit b9faf80bd), adding apt-cache traversal to remove stage-packages orphaned by alternative dependencies and conflict resolution. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged a fix that automatically prunes unneeded stage-packages from snaps by crawling the apt cache to remove orphaned dependencies from alternative resolution and conflict handling. Approved and passed CI. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged a fix that automatically prunes unneeded stage-packages from the apt cache during alternative dependency resolution. The change crawls pending changes to remove orphaned packages, preventing unnecessary snap bloat. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #3030 repo: drop _AptCache and add migrate to install_stage_packages() | snapcraft | merged | Merged in PR #3030 as commit 66467629d, replacing custom _AptCache handling with install_stage_packages() and updating package staging, tests, and ROS plugins. | |
| #1122 repo: cache stage packages for faster future use. | snapcraft | merged | Merged PR #1122 (20b422459), reusing cached stage packages and copying the apt cache into cleanbuild containers to fix LP #1661383. | |
| #3086 repo: restore marked-install strategy for apt-cache | snapcraft | merged | Merged PR #3086 (17cc75aae), restoring AptCache marked installs for build and stage packages and fixing primed-stage-packages name/version parsing from ':' to '='. | |
| #1113 repo: cache stage packages for faster future use. | snapcraft | closed | Closed unmerged in favor of #1122, which merged the stage-package caching and cleanbuild improvements as commit 20b422459. | |
| #1752 fix: Make `stage-packages` deterministic | craft-parts | merged | Merged PR #1752 in commit 26f4b35e, preserving stage-packages input order during deduplication and APT marking to make resolution deterministic; fixes #1751. |