I’ve updated to snapcraft 3 to take advantage of the new
multipass goodness – big thank you to the team for your work!
Using core18 as a base permits me to use
stage-packages instead of the
ruby plugin, which didn’t have cross-compilation support. My snap targets
armhf, and I’d like to cross-compile for
armhf on my
amd64 machine to speed up development.
What’s the best practice for cross-compiling a snap with snapcraft v3 and Multipass?
Gathered from other topics, I’ve modified my snapcraft.yaml to include:
# top level architectures: - build-on: [amd64, armhf] run-on: [amd64, armhf] # example part parts: nginx: source: src/nginx stage-packages: - on amd64 to armhf: - "nginx:armhf" - "gettext-base:armhf" - "libatm1:armhf" - "libxtables12:armhf" - else: - nginx - gettext-base - libatm1 - libxtables12 plugin: dump
I also added the
ubuntu-ports repository to the Multipass VM’s sources.list via
apt edit-sources and ran
apt update in the VM:
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports bionic main universe deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports bionic-security main universe deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports bionic-updates main universe deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports bionic-backports main universe
snapcraft in my snap directory, snapcraft fetches the
armhf repositories, but no actual package with
_armhf.deb suffix. The resulting snap has the
multi suffix, but attempting to install it on an ARM device results in
Exec format error during the install hook (I’m invoking
envsubst from the gettext-base package there).
snapcraft --target-arch=armhf prints
Setting target machine to 'armhf', but doesn’t seem to do anything else.
snapcraft version: snapcraft, version 3.1 (same result with snapcraft 3.0.1 on stable channel)