How can I publish a snap that can provide binaries for all the supported architectures?

I’m currently trying to release a snap (that uses classic confinement) that provides binaries for all the supported architectures. See Classic confinement for austin. By this, I mean that, e.g., if my application is being installed on amd64, then the amd64 binary should be installed instead of the i386.

Presently, I’m using architecture: [ i386, amd64 ] in my snapcraft.yml file, but this seems to produce only a i386 binary. In I don’t seem to have the option of specifying multiple build configurations for different architectures.

How can I publish a snap that can provide binaries for all the supported architectures?

Just to clarify, do you want a single snap to have binaries for both amd64 and i386, or do you want to have an amd64 snap and an i386 snap?

Ideally, I’d prefer to have a single snap that knows what to install on each architecture. If this is not possible, I’m happy to have a “snap” and a “snap-i386” variant.

Sorry, what I meant was: you can have a snap that has architectures: [amd64, i386] that would end up being the same blob on either of those architectures, and it would need to have the smarts to figure out which binaries it needs to use in each case (you might want this for example if you want to support tracing a 386 binary on amd64). Or you can have architecture-specific revisions, that is, if you’re on amd64 you only get the amd64 builds. Both are possible.

I just noticed you said

I’m hoping that’s a typo, as 1. it’s architectures, not architecture; and it’s snapcraft.yaml, not snapcraft.yml.

If you give the architectures spec a read

You’ll see that example 6 says that

architectures: [ i386, amd64 ]

is the same as

  - build-on: [amd64, i386]
    run-on: [amd64, i386]

which means “if building on amd64 or i386, the resulting snap will work on amd64 and i386”. This is probably not what you want.

Also in particular from this note

you’ll notice that what you’re saying you want is something like

 - build-on: amd64
 - build-on: i386


Whatever you do, please don’t do that. The system is architected in such a way that this is not necessary.

If you build in an amd64 machine, it will build an amd64 snap. If you build on armhf you’ll get an armhf snap. At the other end, when a user does a snap install it will only show snaps which are appropriate for their host architecture.

Here’s an example.

The OBS Studio snap uses the architectures stanza to specify that the build service should only attempt to build on the listed architectures.

  - build-on: amd64
  - build-on: i386

The result is that builds only on those hosts:-

The result for me as the developer in the store is:-

root@snapcrafters:~# snapcraft status obs-studio
Track    Arch    Channel    Version    Revision
latest   amd64   stable     22.0.3     211
                 candidate  ^          ^
                 beta       ^          ^
                 edge       22.0.3     213
         i386    stable     22.0.3     210
                 candidate  ^          ^
                 beta       ^          ^
                 edge       22.0.3     212

So we have revision 211 in stable which contains amd64 binaries, and revision 210 in stable also, which contains i386 binaries.

For a user, on an amd64 machine, they see:-

alan@hal:~$ snap info obs-studio
name:    obs-studio
summary: OBS - Free and open source software for live streaming and screen recording  - 


snap-id:      6uLU2MJmBURfLNz4rmL4WT2CmtVULE2u
tracking:     edge
refresh-date: 3 days ago, at 09:55 GMT
  stable:    22.0.3 (211) 143MB -
  candidate: ↑                  
  beta:      ↑                  
  edge:      22.0.3 (213) 143MB -
installed:   22.0.3 (213) 143MB -

An i386 host user would see different revisions. Hope that helps.

@chipaca @popey Thanks for your help. Indeed architecture and snapcraft.yml were typos. Using

  - build-on: amd64
  - build-on: i386

triggers build jobs for both architectures, which is precisely what I was after:

Many thanks for you help.

1 Like