Reading tracking information of host installed snaps from another snap

Hi all. I am working on a new ubuntu-package-manifest strict snap to list installed packages and snaps on the host system. Following advice in the forum I am using the system-backup interface and /var/lib/snapd/hostfs/ to access dpkg data on the host but I was unable to find a way to do something similar for listing installed snaps on the host system.

Instead I was wrote a simple python script which parses /var/lib/snapd/hostfs/var/lib/snapd/ and each snap’s snap.yaml to produce a list of snaps (example: But in doing it this way I lose the tracking information

tracking:     latest/stable

I searched the snapd code. My golang foo is lacking but what I now assume is that the tracking information is from the snap store and not from anything written on disk. Is this true?

And if not, where is this information?

I used strace on snap info aws-cli but I couldn’t see it accessing any related local files other than /snap/aws-cli/current/meta/snap.yaml and this does not contain the tracking information.

ogra pointed me to /var/lib/snapd/state.json @ Classic confinement for ubuntu-package-manifest snap which works perfectly and is exactly what I need.

The format/content of state.json is not a public interface of snapd. It could potentially change at any time.

well, i only pointed out that the local package info you asked about is stored in that file … the proper solution is in the next paragraph in my post …

use the snapd API (which will prevent you from uploading to the global store with a few exceptions though):

1 Like