Building classic snap on Ubuntu Core

Hello,

currently we are trying to setup our application on a raspberry with Ubuntu Core with snap. We have a python application which calls other applications in subprocesses.
In our Ubuntu 17.10 environment this works with snap when we install our application as a classical snap. The other applications are not yet as snaps available (might be coming up in the future) and are directly installed in the system.

Now when we move to the raspberry architecture we are not able to build our snap on Ubuntu Core in a classic confinement (I’ve read somewhere that this is not possible). Therefore our question is, what is the best approach to solve our problem?

  1. Somehow build our application for raspberry in classic confirnement in a different way? Are there alternatives to launchpad?
  2. Not using a classic confinement for our application? In this case, how would we access the other applications? snap interfaces?
  3. …

It would be great to get your support.

Thanks a lot,
Florian

I build arm snaps on a core device (beagle bone black in my case, but it would work for rpi also) using the ‘classic’ snap.

$ sudo snap install classic --edge --devmode
$ sudo classic

The first run of ‘sudo classic’ will create a chroot of a traditional Ubuntu system (ie, with apt), then chroot into it where you can install snapcraft, build tools, etc. The second run of sudo classic will use an existing chroot. You can use sudo classic.reset to delete the chroot.

@getty23 We disallow classic snaps on Ubuntu Core because it is very different from any typical Linux distribution, and most “classic” assumptions would break.

There are two ways out here:

  1. You can confine it, so you indeed need interfaces to use system resources or resources from other applications.

  2. We may at some point implement a classic-like functionality that would work on Ubuntu Core. It would be similar to classic, in that it needs reviewing and need good motivation for why the application cannot be strictly confined, but it would preserve the snap on its own namespace instead of behaving like a classic snap. That would probably be done via a more permissive interface, and it would also work on classic distributions.

Thanks for your replies.
I tried to use interfaces (process-control) but it was not working as I expected. What interface do I need to use in order to call other applications (e.g. ffmpeg)? My python application uses sp.Popen to access the other application.

Your snap won’t be able to reach binaries which exist outside the world that snapd presents to it. So typically you would bundle whatever binaries are required in the snap. These could either be built from source, or if you prefer - and they’re available - use stage-packages: to pull from the archive. e.g.

`parts:
my-part:
(…)
stage-packages:
- ffmpeg

Thanks for your help. I’ve now setup a separate snap for ffmpeg (took me a while to create it on my own ;)) and now I’d like to connect to it from my application (running in a separate snap, python via subprocess).
I read through the snap interface pages but I had a hard time to find an example which would suit my needs. Could you help me here so that my ffmpeg snap provides a slot to be called by my application?
Thanks

that is because your approach of shipping ffmpeg in a separate snap makes it very complicated … the common way would be to use your ffmpeg build as another part of your application snap and in the end bundle it with the app … is there any particular reason why you try to keep it separated ? (you can surely use ffmpeg this way but would have to set up very complicated interface combinations using the content interface to achieve this, if you are the only user of ffmpeg for your specific snap, the bundling is the way to go, especially in the context of Ubuntu Core where you likely only run a singe purpose application)

Thanks for your help. Bundling the ffmpeg part and app with my application worked out perfectly :grin:

Hi;

I wanna build my snap package on Ubuntu Core. I have already done that successfully on Ubuntu using Snapcraft and I have snapcraft.yaml file. So I run these commands on Ubuntu Core:

$ sudo snap install classic --edge --devmode
$ sudo classic

Then I should be able to run classic ubuntu commands. I can install apt packages, but when I want to install Snapcraft, I got this error:

(classic)<my_user>@localhost:~$ snap install snapcraft
error: snap "snapcraft" requires classic confinement which is only available on classic systems

So how I can I install Snapcraft?

Thanks in advance.

Bests,
Vahid

You still won’t be able to install classic snaps inside the classic environment, you will need to use the apt package of snapcraft.
Also note that even if you did install a snap (strictly confined because you’re on Ubuntu Core) from inside the classic environment, it won’t be accessible from inside the classic environment as far as I can tell, because your classic rootfs won’t contain the /snap mount necessary:

(classic)$ snap install hello-world
hello-world 6.3 from 'canonical' installed
(classic)$ hello-world
hello-world: command not found
(classic)$ ls /snap
manifest.yaml  snapcraft.yaml
1 Like

Alternatively you could use lxd on core and build inside the lxd container. You can install the snap of snapcraft inside lxd and build there.

2 Likes