With the advanced grammar, only the last `- to` clause is respected
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
https://github.com/canonical/lxd-pkg-snap/blob/f3327146996d52e66f8726a88766021f678e2575/snapcraft.yaml
Relevant log output
Running pull phase...
Initialising lifecycle
Installing build-packages
Cannot find package listed in 'build-packages': librbd-dev
Additional context
No response
Thanks for the report @simondeziel.
I've made a bug for the upstream work: https://github.com/canonical/craft-grammar/issues/89
Thank you for reporting your feedback to us!
The internal ticket has been created: https://warthogs.atlassian.net/browse/SNAPCRAFT-1036.
This message was autogenerated
Can we get this fixed next pulse?
I've added it to the pulse. We still need to scope the work.