repo: automatically prune unneeded stage-packages
Metadata
Current evaluation
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.
Suggested action: —
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 |
|---|---|---|---|---|
| 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. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged a fix that automatically prunes unneeded stage-packages from snaps. Resolves an apt cache bug where alternative dependencies left behind unrequired packages by crawling cache changes and removing anything no longer needed. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #252 repo: fix_pkg_config trims prefixes more generically | craft-parts | merged | Merged. Updates fix_pkg_config to generically strip prefixes, including the stage directory, when normalizing pkg-config files from staged snaps. Resolves LP #1916281 and CRAFT-1215. Approved and passed CI. | |
| #2144 lifecycle: automatically stage dependencies | snapcraft | merged | Merged PR #2144 resolves LP: #1774018 by automatically staging dependencies when a part depends on another, preventing a RuntimeError during snapcraft pull. Approved, passed CI, and achieved 100% diff coverage. | |
| #3848 repo: fix_pkg_config removes prefixes from staged snap's .pc files. | snapcraft | merged | Merged a fix normalizing pkg-config prefixes in staged snaps by stripping prepended build directories. Squash-merged after review approval and full test coverage, resolving Launchpad #1916281 and CRAFT-1214. | |
| #251 repo: fix_pkg_config removes prefixes from staged snap's .pc files. | craft-parts | merged | Merged fix normalizing pkg-config files from staged snaps by stripping prepended build directories from the prefix parameter. Resolves Launchpad bug #1916281 and CRAFT-1215. Approved and merged. | |
| #3505 snaps: don't validate snaps before `SnapPackage.download()` | snapcraft | merged | Merged a fix that skips snap validation before SnapPackage.download(), resolving branch staging issues (LP#1901733). Approved by two reviewers, passed CI, and changed three files (+16/-11 lines). |