4

Can a snap be built in a way such as, when the user tries to install it, the snap also installs another package? For example, wget. Thanks.

2 Answers 2

4

The short answer to your question is: no, snaps cannot depend upon .debs in such as way that, when the snap is installed, the .deb is installed as well.

However, the longer answer is that, when building the snap, you can bundle whatever .debs you want within it. To use your example, here's the snapcraft.yaml for a snap that bundles wget within it:

name: my-snap-name # you probably want to 'snapcraft register <name>'
base: core18 # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: strict # 'strict' confinement means fully confined

parts: 
  my-part:
    plugin: nil
    # Include the wget .deb from the Ubuntu package archive
    stage-packages: [wget]

apps:
  # expose wget to end-users
  wget:
    command: usr/bin/wget
    plugs: [network, home, removable-media]

Run snapcraft on that and you end up with a snap that has a wget app. It doesn't pull wget in at install-time like you asked, but by pulling it in at build-time perhaps it accomplishes your end goal.

4
  • thanks! this is for a binary, but what if I also need libs from usr/lib?
    – knocte
    Jan 27, 2019 at 4:46
  • for example: gtk2 libs?
    – knocte
    Jan 27, 2019 at 4:46
  • Same thing, just add it to stage-packages and they'll end up in the snap.
    – kyrofa
    Jan 27, 2019 at 16:58
  • Note that as snap files are self-contained every dependency you use will increase the size of the snap and resources needed in the target system. If end user is running some other apps that would need the same libraries, the snap environment prevents sharing the libraries between different apps. Jan 11, 2021 at 12:56
0

Snap packages are self contained and need no outside dependencies to run. See here for more information Linux Commando: Snaps

5
  • that guide is only written from the user point of view, not from the developer that wants to create the snap; I mean, I know that a snap can be self contained and include all dependencies inside, but if a .deb package already provides a version that is compatible with the app contained in the snap, and the snap builder decides it's good enough, can the snap depend on the .deb?
    – knocte
    Jan 26, 2019 at 11:44
  • 2
    that may be true but the whole Idea of the snap is that it will work across many distros so if the developer require a dependency outside the snap that may not be the case because different distros may place files in different locations. JMHO.
    – kc1di
    Jan 26, 2019 at 13:14
  • 2
    A snap that depends upon a deb is non-portable, can be confusing to some users, and adds an unnecessary support burden to the developer. A more immediate problem is that snaps have no way to communicate a deb dependency to apt. This makes the install non-standard, and another pain point for support: We all know that humans sometimes aren't great at following simple directions.
    – user535733
    Jan 26, 2019 at 13:46
  • This conical guide should answer your question more throughly : docs.snapcraft.io/the-snap-format/698
    – kc1di
    Jan 26, 2019 at 13:54
  • @user535733: ok even if it's non-portable, I'm aware of the disadvantage of this, how can I do it?
    – knocte
    Jan 26, 2019 at 18:05

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.