How to set up snapcraft inside a container running on Ubuntu Core
You can set up snapcraft on your PC with Ubuntu, and you’ll be able to compile and build snap packages there, but you won’t be able to run them on the snappy Ubuntu Core running on your Raspi2, because the hardware architecture is not the same. Apps that go into your snap need to be compiled for the ARM cpu in the raspi.
The best option I found for this is installing a full Ubuntu inside a container running on top of my Ubuntu Core in the raspi, and to install snapcraft there. Here’s how you can do it:
First you need to install the lxd container hypervisor, and import an Ubuntu image:
With that you’ll have an old-style Ubuntu running inside the container, where you can install every deb package that exists. We now need to get a shell into the container, to be able to install snapcraft and any other thing we may need:
We’ll try installing snapcraft from the snappy-dev/tools ppa:
It will take some time installing every package in the lxc inside the raspi, but when done we’ll have all the tools there to build snap packages.
I suggest an extra step, to be able to easily retrieve files built in the lxc container. So starting in the Ubuntu Core prompt, let’s create a link to the home folder inside the container root filesystem:
With that we’ll be able to access any file created inside the container with the shortcut ~/my-ubuntu-home
This post is part 2 in a series of posts on how to get started writting IoT apps for the snappy Ubuntu Core.