Providing hints about snaps from apt

We want to help people who use the traditional APT system when they don’t get a deb but there is a snap available.

The idea is that APT would provide a hook like AptUi::{Search,Install}::NotFound - this hook will get called when apt cannot find a package (either in apt install foo or in apt search foo). Snapd would hook into this via a helper and display something like:

$ sudo apt install spotify
The package 'spotiy' is not available from apt, however you can install it using:
  sudo snap install spotify
Check `snap info spotify` for more versions.
E: Unable to locate package spotify.

This is currently implemented in https://salsa.debian.org/apt-team/apt/merge_requests/5

There is an alternative proposal from David (from the apt team) to have a more structured approach. Instead of allowing the hook to write to stdout (and with many hooks providing a messy experience) the hook would communicate with apt via a very simple deb822 based protocol. The hook would send:

name: Install::NotFound
package: spotify

and hook would reply:

type: INSTALL-VIA
source: snapd apstore
version: 1.0
message: snap install spotify

The idea is that this is flexible, i.e. it could be used for:

type: INSTALL-VIA
source: snapd appstore
version: many
message: Multiple versions available, check `snap info spotify`

as well.

With that apt would be able to display a more context aware message like (after executing the hook and parsing the returned data from the hook):

# apt install spotify
Sorry, cannot find package "spotify", but there are other ways to install it:
    Snapd Appstore     1.0              snap install spotify

For search it would be a similar mechanism.

Feedback welcome!

1 Like