With the advanced grammar, only the last `- to` clause is respected
Metadata
Current evaluation
No evaluation has been recorded for this issue yet.
Issue body
### Bug Description
In the LXD snap, we have some parts that are meant to be supported on some arches only. For example, we don't want to ship QEMU for `armhf` nor `riscv64`. As such, the `qemu` part is constructed to avoid installing the `build-packages` and the `stage-packages` when building for `armhf`/`riscv64`:
```
qemu:
build-packages:
- to armhf:
- cmake # placeholder pkg (actually used by lxd part) to avoid installing build-packages on unsupported arches
- to riscv64:
- cmake # placeholder pkg (actually used by lxd part) to avoid installing build-packages on unsupported arches
- else:
- bison
- ...
- librbd-dev
stage-packages:
- to armhf:
- acl # placeholder pkg (actually used by lxd part) to avoid installing stage-packages on unsupported arches
- to riscv64:
- acl # placeholder pkg (actually used by lxd part) to avoid installing stage-packages on unsupported arches
- else:
- genisoimage
- ...
- qemu-system-data # This is needed due to --disable-install-blobs.
...
```
However, only the last `- to $ARCH:` clause seems to be respected as on `armhf`, the builds on LP builders always fail complaining that `librbd-dev` is not available. `librbd-dev` is indeed not available for `armhf` which is the whole reason why we try to exclude it with the `- to`/`- else` clauses.
The exclusion works for the `- to riscv64:` as neither `librbd-dev` nor `qemu-system-data` are found in the `riscv64` build logs.
**important**: Inverting the `- to armhf:` and `- to riscv64:` made the `armhf` build work as it then stops trying to pull `librbd-dev`
### To Reproduce
`snapcraft remote-build --platform amd64,armhf,riscv64` on a cloned repo from https://github.com/canonical/lxd-pkg-snap
### Environment
```
$ snap list snapcraft
Name Version Rev Tracking Publisher Notes
snapcraft 8.6.1 13459 latest/stable canonical✓ classic
```
### snapcraft.yaml
```yaml
https://github.com/canonical/lxd-pkg-snap/blob/f3327146996d52e66f8726a88766021f678e2575/snapcraft.yaml
```
### Relevant log output
```shell
Running pull phase...
Initialising lifecycle
Installing build-packages
Cannot find package listed in 'build-packages': librbd-dev
```
### Additional context
_No response_
Evaluation history
No evaluation history available.