Incorrect architecture with snapcraft 7.x and build-for/build-on

I have a snap, which carries some non-architecture specific content. The snapcraft.yaml looks like this:

name: silly-hello
summary: hello
description: random content
version: '1.0'

grade: stable
confinement: strict
base: bare                                                                                                                                                                                                                                                                                                                                                   
build-base: core22

architectures:
  - build-on: [amd64, arm64]
    build-for: all

parts:
  hello:
    plugin: dump
    source: .

We have some self hosted arm64 builders, but folks also use their amd64 hosts for building the snap, hence it lists both arches. Since the resulting content is non-arch-specific, I’m expecting the snap to list all in the architectures field in meta/snap.yaml. However, this is what I get:

name: silly-hello
version: '1.0'
summary: hello
description: random content
architectures:
- amd64
base: bare
confinement: strict
grade: stable
environment:
  LD_LIBRARY_PATH: ${SNAP_LIBRARY_PATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
  PATH: $SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH

The snap is tied to a specific architecture and snapd running on arm64 host rightfully rejects artifacts built on amd64. Funnily enough, the *.snap file is named: silly-hello_1.0_all.snap, suggesting that something somewhere did assume all architectures.

I suspected that maybe something is wrong with interpretation of base: bare (despite having build-base: core22) which doesn’t trigger the right behavior, but I can reproduce that even with base: core22.

The problem is only visible after switching to snapcraft 7.x branch.

maciek@galeon:~ snap list snapcraft   
Name       Version  Rev   Tracking       Publisher   Notes
snapcraft  7.2.9    8619  latest/stable  canonical✓  classic

Same this with the candidate/edge.

I believe this is the same problem reported by @zyga.

I’ve triaged it and made a launchpad bug here: https://bugs.launchpad.net/snapcraft/+bug/1999580

Indeed! Thanks for the link, added myself to subscribers.

2 Likes

is this possibly due to https://github.com/snapcore/snapcraft/blob/2f2d1eac63de39dbd4f9bbfab8ffa5df0ac9ca62/snapcraft/parts/parts.py#L88

1 Like

Bingo! That was a line of code I added when first adding support for the architectures keyword for core22 snaps. I have proposed a fix for this issue.