Base Snaps - Doubts

Hello There,

I have been trying to understand the base snap concepts and see if that is something we could use in one of our projects. As usual, the documentations are hard to find . All I could find are this forum topic and these demos (base-snap and base-snap-consumer).

My requirements or problem statement is as below.

  1. The project is a python package turned in to snap , though the actual python package is very small, the dependencies are huge and it would take a lot of time to build and resulting snap size is also huge (around 80+ MB).
  2. The Idea would be (if feasible) to divide the entire packages in to base snap (which installs python + other system and third party packages along with all the install dependencies of our python package) and the actual snap for our python package (There by reducing the time to build and size of the resulting snap (hopefully ??)).

So to begin with, I cloned the repo in to a new directory my-snap-base, modified the snapcraft.yaml and removed apps section, addedd type: base, renamed it to my-snap-base and built the snap. I then, went ahead to the original snap directory my-snap ,edited the snapcraft.yaml this time to exclude all the parts which are now part of my-base-snap and tried building the snap. The snap failed to build at the prime stage while trying to create command wrappers for the third party packages such as sqlite3 which are now part of base-snap. To overcome this error I though to moving the required app section to base-snap itself but on going through the forum topic Base snaps with defined applications I am again confused .

What would be the best way to handle this situation ?Is there a way I can tell snapcraft to just create the command wrappers and look for the required binaries in the base-snap upon installation/ at run time ? Or Should I just skip creating the base snap and stick to what we are having at present (one snap with everything packaged) ?

You almost certainly don’t want a base snap for this. In addition to the Python code you propose putting in your base snap, you’d also be responsible for libc and all the other base libraries used by Python. By not relying on one of the existing bases, you’d be on the hook for tracking security vulnerabilities in all this code.

What might be more useful is the content interface. This allows you to have files from one snap bind mounted into a second snap. You can set a default provider for a content interface plug, which can trigger the installation of your second snap.


Thanks @jamesh for the hints. I tried using content-interface a long while ago but could not get the gist of it , so if I create a snap with all my third party libraries and executable, Can I access them from my apps in the second snap ?

Say snap1 has bin1 located in its $SNAP/usr/bin folder, If I mount $SNAP of first snap in second snap, Can I access it ?

I’d suggest reading the documentation about the interface here:

In short, it provides a way for a directory from one snap to be bind mounted into another. So you want the content you wish to export to be under a single directory tree.