How to get dependencies and reserve dependencies for a sanp package?

Hello,
I would like to know what packages a specific snap package depends on, and also to know what cased a snap package to be installed as a dependency.

In apt we can use:
apt-cache depends packagename
and for reverse dependencies:
apt-cache rdepends packagename

I would like to know what are the alternatives for snap.

many snaps ship

/snap/<snap name>/current/snap/snapcraft.yaml

that lists all build and stage packages under the parts used by the snap … (note that snap developers can opt out of shipping snapcraft.yaml though, so not all snaps ship this)

There’s also the manifest.yaml from the same directory.

Thank you, But I was thinking to find those information in the command line and before even installing like apt-cache does.

There aren’t large dependency graphs for snap packages the same as you’d see for .deb or .rpm packages. At present, there are two cases where installing a snap package will trigger the installation of another snap:

  1. If the snap’s base snap is not present on the system. A base snap provides the root file system image used to run the application in. At present, there are three commonly used base snaps (core, core18, and core20), so it is rare for these to be missing.
  2. If the snap has a content interface plug and the snap with the matching plug is not installed. The main places you’ll see the content interface used today is to share groups of libraries (such as gnome-3-34-1804), or common data files (e.g. gtk-common-themes).

There isn’t currently an obvious way to determine what snaps might be referenced here without first downloading the snap. However, this blog post describes a way to request the snap.yaml metadata for an arbitrary snap via the store API:

After issuing that curl command, you want to look for the following:

  1. The value of the base: property at the top level gives the name of the base snap.
  2. In the plugs: section, look for subsections that set interface: content. The default-provider: property lists the name of the default snap providing that data.

It probably wouldn’t be too difficult to put together a script that pulled this information together for a given snap, and filtered out the deps that are already installed.

3 Likes