2

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.

2 Answers 2

1

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.

3
  • 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, 2017 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. Jan 31, 2017 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, 2017 at 19:41
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .