canonical / snapcraft

Package, distribute, and update any app for Linux and IoT.
https://snapcraft.io
GNU General Public License v3.0
1.18k stars 445 forks source link

architectures: allow same arch in multiple build-ons in core20 #4341

Open mr-cal opened 1 year ago

mr-cal commented 1 year ago

What needs to get done

core20 snaps should allow the same architecture in multiple build-ons, when a target arch is supplied with snapcraft --target-arch armhf --enable-experimental-target-arch --destructive-mode.

Caevaets:

Why it needs to get done

Currently, core20 snaps do not allow the same architecture to be present in multiple build-ons.

Consider the following snapcraft.yaml:

base: core20
architectures:
  - build-on: [amd64, arm64, armhf]
    run-on: armhf
  - build-on: [amd64, arm64]
    run-on: arm64

Running snapcraft with or without a target arch produces the following error: Issues while validating snapcraft.yaml: The 'architectures' property does not match the required schema: 'amd64' and 'arm64' are present in the 'build-on' of multiple items, which means snapcraft doesn't know which 'run-on' to use when building on those architectures

When a target arch is supplied, snapcraft has enough information to determine which build-on/run-on tuple to use.

source: https://bugs.launchpad.net/snapcraft/+bug/2009520

dilyn-corner commented 1 year ago

I believe this is also an issue for core22 snaps, and extending this to supporting those bases would also be nice.

mr-cal commented 1 year ago

I believe this is also an issue for core22 snaps, and extending this to supporting those bases would also be nice.

Can you double-check?

The same yaml should work on core22 and create 2 snaps by default. It can also take --build-for=<arch> to create one snap.

base: core22
architectures:
  - build-on: [amd64, arm64, armhf]
    build-for: armhf
  - build-on: [amd64, arm64]
    build-for: arm64
dilyn-corner commented 1 year ago

Seems you're right... Perhaps I'm misremembering. I'll see if I can dig up what I was doing.