← Back to issue list

pluginhandler: support more complex stage-packages.

View original Github issue

Metadata

Project
snapcraft
Number
#1059
Type
pull request
State
merged
Author
kyrofa
Labels
Created
Updated
Closed

Current evaluation

Merged. Adds a complex grammar for stage-packages using on and try/else clauses to filter packages by selectors like target architecture, resolving LP #1637282. Approved by reviewer and passed CI.

Suggested action:

No scores available.

Issue body

Currently snapcraft only supports a flat list of stage packages to be staged regardless of target architecture. This PR resolves LP: [#1637282](https://bugs.launchpad.net/snapcraft/+bug/1637282) by introducing a more complex grammar that allows one to filter stage packages depending on various selectors (target arch for right now), as well as specify optional packages. The grammar is made up of two statements: `on` and `try`. ```yaml - on <selector>[,<selector>...]: - ... - else[ fail]: - ... ``` The body of the `on` clause is taken into account if every (AND, not OR) selector is true for the target build environment. Currently the only selectors supported are target architectures (e.g. amd64). If the `on` clause doesn't match and it's immediately followed by an `else` clause, the `else` clause must be satisfied. An `on` clause without an `else` clause is considered satisfied even if no selector matched. The `else fail` form allows erroring out if an `on` clause was not matched. ```yaml - try: - ... - else: - ... ``` The body of the `try` clause is taken into account only when all packages contained within it are valid. If not, if it's immediately followed by `else` clauses they are tried in order, and one of them must be satisfied. A `try` clause with no `else` clause is considered satisfied even if it contains invalid packages. This PR is larger than I'd like it to be, I'm sorry about that-- I didn't see a logical place to split. Lots of the line count is tests. Note also that I tried to test a number of combinations, but the grammar is recursive, allowing for unlimited combinations. This could use some good poking.

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged. Adds a complex grammar for stage-packages using on and try/else clauses to filter packages by selectors like target architecture, resolving LP #1637282. Approved by reviewer and passed CI.
qwen3.6-35b-a3b-mtp-q6 Merged changes adding complex stage-packages filtering via on and try/else YAML clauses, enabling architecture-based selection and optional packages. Resolves Launchpad bug 1637282. Includes grammar validation, tests, and addresses review edge cases.
qwen3.6-35b-a3b-mtp-q6 Merged. Implements architecture-specific and optional stage-packages filtering via on and try/else YAML clauses, resolving LP: #1637282. The maintainer added the grammar and tests, addressing review feedback on validation and error messaging.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#2632 pluginhandler, repo: find stage-packages from DT_NEEDED on host snapcraft merged Merged. Adds DT_NEEDED analysis to primed files, automatically suggesting missing stage-packages. Addressed reviewer feedback on caching optimization, passed all CI checks, and maintained 98.14% test coverage.
73%
#1511 project_loader: support grammar on build-packages snapcraft merged Merged: Added grammar support for build-packages at part and global levels. Approved by one reviewer, passed CI, and modified 19 files. Builds on issue #1492 and depends on PR #1509.
73%
#2792 pluginhandler: use well-formed build package/snap lists snapcraft merged Merged implementation using the grammar processor for build_packages and build_snaps to ensure well-formed lists and prevent raw unprocessed properties in pull state info. Added verification tests, approved by reviewer, and passed CI.
71%
#920 pluginhandler: ensure staged files are included in the prime step. snapcraft merged Merged into master. Resolves Launchpad bugs #1623279 and #1605164 by ensuring the prime step correctly includes staged files when using wildcards or exclusions. Approved, passed CI, and includes new tests.
70%