I'm wondering if there's a way to include another .snap file when building with Snapcraft. This would be something like the equivalent of stage-packages or build-packages but for snaps instead of debs.

I've seen the after attribute, but my understanding is that just pulls down a shared part YAML and rebuilds locally.


No, you can not include a .snap inside another .snap. For sharing libraries/runtime binaries between snaps, consider using the content interface here. Additionally, you can create a shared part in snapcraft and make it available to the broader community. Please find a list of available parts for consumption here.

| improve this answer | |
  • I didn't use the content interface because I'm trying to avoid runtime dependencies. Shared parts are closer to what I'm looking for, but I'd like to avoid rebuilding for each snap. I'll probably just package the library into a .deb or tarball. – mrjogo Jan 30 '17 at 23:06
  • We discussed doing a snapcraft parts cache and webservice precisely for the reason you mentioned. Let me check on its status and I'll update the thread shortly. – Manik Taneja Jan 31 '17 at 4:36
  • Does the thing you want to include make sense to publish as it's own snap? If it's not something a user will directly interact with, it should be shared part rather than a full snap. – mhall119 Jan 31 '17 at 19:41

You can include any content inside your snap, including other snaps. In some cases snapcraft may not have the right helpers in place to do what you want with a couple of lines just yet, but you can always create a makefile that does exactly what you need to be done at build and install stages, for example. Use unsquashfs to extract the previous content from the other snap.

That said, consider if the first snap is supposed to be consumed on its own. If it's not, having that snap lingering in the store under your account won't be great when nobody can actually install it in a useful way. We need to improve snapcraft to handle reuse better in these cases, but meanwhile using a deb would be fine if you're already comfortable with that, or even simply pushing the built piece to a place you can share across consumers for the time being.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.