# snap

### Installation:

##### Installer snap sur Solus:

installé par défaut depuis Solus 3
sinon

```bash
$ sudo eopkg up
$ sudo eopkg install snapd
$ sudo reboot
```

##### Installer snap sur ubuntu:

installé par défaut depuis Mint 16.04

```bash
$ sudo apt update
$ sudo apt install snapd
# logout / restart
```

##### Installer snap sur Mint:

disponible depuis Mint 18.2

```bash
$ sudo apt update
$ sudo apt install snapd
# logout / restart
```

##### Installer snap sur Debian:

disponible depuis Debian 9

```bash
$ sudo apt update
$ sudo apt install snapd
# logout / restart
```

##### Tester l'installation:

```bash
$ sudo snap install hello-world
hello-world 6.3 from Canonical✓ installed
$ hello-world
Hello World!
```

##### Installer le Snap Store:

```bash
$ sudo snap install snap-store
```



### Utilisation:

##### Version courante de snap:

```bash
$ snap version
snap    2.39.3
snapd   2.39.3
series  16
solus   4.1
kernel  5.5.6-149.current
```


Rechercher une appli:

```bash
$ snap find "media player"
Name                    Version                 Publisher      Notes    Summary
vlc                     3.0.8                   videolan✓      -        The ultimate media player
foobar2000              1.5.2                   mmtrt          -        foobar2000 is an advanced freeware audio player.
tizonia                 0.18.0                  tizonia        -        Cloud music from the Linux terminal
minidlna-escoand        1.2.1snap1              escoand        -        server software with the aim of being fully compliant with DLNA/UPnP clients.
audio-recorder          3.0.5+rev1432+pkg-7b07  brlin          -        A free audio-recorder for Linux (EXTREMELY BUGGY)
mpv                     0.26.0                  casept         -        a free, open source, and cross-platform media player.
```

##### Info sur un snap:

```bash
$ snap info chromium
name:      chromium
summary:   Chromium web browser, open-source version of Chrome
publisher: Canonical✓
contact:   https://bugs.launchpad.net/ubuntu/+source/chromium-browser/+bugs?field.tag=snap
license:   unset
description: |
  An open-source browser project that aims to build a safer, faster, and more stable way for all
  Internet users to experience the web.
commands:
  - chromium.chromedriver
  - chromium
snap-id:      XKEcBqPM06H1Z7zGOdG5fbICuf8NWK5R
tracking:     stable
refresh-date: today at 10:16 CET
channels:
  stable:    80.0.3987.132 2020-03-05 (1043) 160MB -
  candidate: 80.0.3987.132 2020-03-04 (1043) 160MB -
  beta:      81.0.4044.43  2020-03-05 (1045) 161MB -
  edge:      81.0.4044.17  2020-02-14 (1028) 161MB -
installed:   80.0.3987.132            (1043) 160MB -

```

```bash
# plus d'info sur le snap
$ snap info chromium --color=always --verbose
```

Installer un snap:

```bash
$ snap install chromium
chromium 80.0.3987.132 from Canonical✓ installed
```

```bash
$ sudo snap install --channel=edge chromium
$ sudo snap switch --channel=stable chromium
```

##### Lancer un snap:

Les snap sont installés dans `/snap/bin`. Ajouter `/snap/bin` au $PATH si nécessaire.
Certaines distributions utilisent `/var/lib/snapd/snap/bin`

```bash
$ which chromium
/snap/bin/chromium
```

##### Liste des snaps installés:

```bash
$ snap list
Name               Version                     Rev   Tracking  Publisher   Notes
chromium           80.0.3987.132               1043  stable    canonical✓  -
core               16-2.43.3                   8689  stable    canonical✓  core
core18             20200124                    1668  stable    canonical✓  base
gnome-3-28-1804    3.28.0-16-g27c9498.27c9498  116   stable    canonical✓  -
gtk-common-themes  0.1-28-g1503258             1440  stable    canonical✓  -
odio               1.4.0                       5     stable    meniedri1   -
snap-store         20191114.a9948d5            209   stable    canonical✓  -
snapd              2.43.3                      6434  stable    canonical✓  snapd
```

```bash
$ snap list --all
Name               Version                     Rev   Tracking  Publisher   Notes
chromium           80.0.3987.132               1043  stable    canonical✓  -
core               16-2.43.3                   8689  stable    canonical✓  core
core18             20200124                    1668  stable    canonical✓  base
core18             20190709                    1066  stable    canonical✓  base,disabled
gnome-3-28-1804    3.28.0-16-g27c9498.27c9498  116   stable    canonical✓  -
gnome-3-28-1804    3.28.0-10-gaa70833.aa70833  67    stable    canonical✓  disabled
gtk-common-themes  0.1-28-g1503258             1440  stable    canonical✓  -
gtk-common-themes  0.1-22-gab0a26b             1313  stable    canonical✓  disabled
odio               1.4.0                       5     stable    meniedri1   -
snap-store         20190723.daf5512            180   stable    canonical✓  disabled
snap-store         20191114.a9948d5            209   stable    canonical✓  -
snapd              2.39.2                      3646  stable    canonical✓  snapd,disabled
snapd              2.43.3                      6434  stable    canonical✓  snapd
```

##### Mises-à-jour:

Les snaps sont mis-à-jour automatiquement (dans les 6h après une révision). 
On peut aussi chercher les m-à-j manuellement:

```bash
$ sudo snap refresh chromium
Mot de passe : 
snap "chromium" has no updates available
$ sudo snap refresh --channel=beta vlc
```

Liste des snaps en attente de mise-à-jour:

```bash
$ snap refresh --list
All snaps up to date.
```

##### Date de la dernière et de la prochaine m-à-j:

```bash
$ snap refresh --time
timer: 00:00~24:00/4
last: today at 08:55 CET
next: today at 14:11 CET
```

##### Voir les dernières modifications:

```bash
$ snap changes
error: no changes found
$ snap changes ID
```

Réinstaller la version  précédente:

```bash
$ snap list --all chromium
Name      Version        Rev   Tracking  Publisher   Notes
chromium  80.0.3987.122  1040  stable    canonical✓  disabled
chromium  80.0.3987.132  1043  stable    canonical✓  -
```

```bash
$ snap revert chromium
chromium reverted to 80.0.3987.122

# --revision=	réinstaller une révision précise
```

```bash
$ snap list --all chromium
Name      Version        Rev   Tracking  Publisher   Notes
chromium  80.0.3987.122  1040  stable    canonical✓  -
chromium  80.0.3987.132  1043  stable    canonical✓  disabled
```

```bash
$ snap refresh chromium
chromium 80.0.3987.132 from Canonical✓ refreshed
```

##### Liste de toutes les révisions disponibles:

```bash
$ snap list --all chromium
Name      Version        Rev   Tracking  Publisher   Notes
chromium  80.0.3987.122  1040  stable    canonical✓  disabled
chromium  80.0.3987.132  1043  stable    canonical✓  -
```

##### Activer / désactiver des snaps:

```bash
$ snap disable chromium
chromium disabled

# Le snap reste disponible pour une réactivation.
```

```bash
$ snap list --all chromium
Name      Version        Rev   Tracking  Publisher   Notes
chromium  80.0.3987.122  1040  stable    canonical✓  disabled
chromium  80.0.3987.132  1043  stable    canonical✓  disabled
```

```bash
$ snap enable chromium
chromium enabled
```

##### Supprimer un snap:

```bash
$ snap remove chromium
chromium removed
```

Supprimer uniquement 1 révision:

```bash
$ snap remove chromium --revision=1040
```

##### Voir les logs:

```bash
$ snap logs <service>

# -n=	affiche un nombre de lignes(defaut:10)
# -f	affichage au fil de l'eau
```

```bash
$ snap logs chromium
error: snap "chromium" has no services
```

##### Permissions:

```bash
$ snap connections chromium
Interface                 Plug                               Slot                            Notes
browser-support           chromium:browser-sandbox           :browser-support                -
camera                    chromium:camera                    :camera                         -
content[gtk-3-themes]     chromium:gtk-3-themes              gtk-common-themes:gtk-3-themes  -
content[icon-themes]      chromium:icon-themes               gtk-common-themes:icon-themes   -
content[sound-themes]     chromium:sound-themes              gtk-common-themes:sound-themes  -
cups-control              chromium:cups-control              :cups-control                   -
desktop                   chromium:desktop                   :desktop                        -
gsettings                 chromium:gsettings                 :gsettings                      -
home                      chromium:home                      :home                           -
joystick                  chromium:joystick                  :joystick                       -
mount-observe             chromium:mount-observe             -                               -
mpris                     -                                  chromium:mpris                  -
network                   chromium:network                   :network                        -
network-bind              chromium:network-bind              :network-bind                   -
network-manager           chromium:network-manager           -                               -
opengl                    chromium:opengl                    :opengl                         -
password-manager-service  chromium:password-manager-service  -                               -
personal-files            chromium:chromium-config           :personal-files                 -
pulseaudio                chromium:pulseaudio                :pulseaudio                     -
raw-usb                   chromium:raw-usb                   -                               -
removable-media           chromium:removable-media           -                               -
screen-inhibit-control    chromium:screen-inhibit-control    :screen-inhibit-control         -
u2f-devices               chromium:u2f-devices               :u2f-devices                    -
unity7                    chromium:unity7                    :unity7                         -
upower-observe            chromium:upower-observe            :upower-observe                 -
x11                       chromium:x11                       :x11                            -

```

Liste des interfaces:

```bash
$ snap interface
Name                      Summary
browser-support           allows access to various APIs needed by modern web browsers
camera                    allows access to all cameras
content                   allows sharing code and data with other snaps
cups-control              allows access to the CUPS control socket
desktop                   allows access to basic graphical desktop resources
desktop-legacy            allows privileged access to desktop legacy methods
gsettings                 allows access to any gsettings item of current user
home                      allows access to non-hidden files in the home directory
joystick                  allows access to joystick devices
network                   allows access to the network
network-bind              allows operating as a network service
opengl                    allows access to OpenGL stack
password-manager-service  allows access to common password manager services
personal-files            allows access to personal files or directories
pulseaudio                allows operating as or interacting with the pulseaudio service
screen-inhibit-control    allows inhibiting the screen saver
snapd-control             allows communicating with snapd
system-observe            allows observing all processes and drivers
u2f-devices               allows access to u2f devices
unity7                    allows interacting with Unity 7 services
upower-observe            allows operating as or reading from the UPower service
wayland                   allows access to compositors supporting wayland protocol
x11                       allows interacting with or running as an X11 server
```

##### Lire les options de configuration pour le snap:

```bash
$ snap get chromium
error: snap "chromium" has no configuration
```

##### Se connecter:

Ce n'est pas nécessaire sauf pour les achats et pour les développeurs.

```bash
$ snap login bruno@xxx.info
Personal information is handled as per our privacy notice at
https://www.ubuntu.com/legal/dataprivacy/snap-store

Password of "bruno@xxx.info": 
Login successful
```

Afficher qui est connecté:

```bash
$ snap whoami
email: bruno@xxx.info
```

Snapshot:

```bash
$ snap saved
Set  Snap      Age    Version        Rev   Size    Notes
3    chromium  57.7m  80.0.3987.132  1043  34.4MB  auto
```



### Aide:

```bash
$ snap --help

$ snap help --all
The snap command lets you install, configure, refresh and remove snaps.
Snaps are packages that work across many different Linux distributions,
enabling secure delivery and operation of the latest apps and utilities.

Usage: snap <command> [<options>...]

Commands can be classified as follows:


  Basics (basic snap management):
    find            Find packages to install
    info            Show detailed information about snaps
    install         Install snaps on the system
    list            List installed snaps
    remove          Remove snaps from the system

  ...more (slightly more advanced snap management):
    refresh         Refresh snaps in the system
    revert          Reverts the given snap to the previous state
    switch          Switches snap to a different channel
    disable         Disable a snap in the system
    enable          Enable a snap in the system

  History (manage system change transactions):
    changes         List system changes
    tasks           List a change's tasks
    abort           Abort a pending change
    watch           Watch a change in progress

  Daemons (manage services):
    services        Query the status of services
    start           Start services
    stop            Stop services
    restart         Restart services
    logs            Retrieve logs for services

  Commands (manage aliases):
    alias           Set up a manual alias
    aliases         List aliases in the system
    unalias         Remove a manual alias, or the aliases for an entire snap
    prefer          Enable aliases from a snap, disabling any conflicting aliases

  Configuration (system administration and configuration):
    get             Print configuration options
    set             Change configuration options
    wait            Wait for configuration

  Account (authentication to snapd and the snap store):
    login           Authenticate to snapd and the store
    logout          Log out of snapd and the store
    whoami          Show the email the user is logged in with

  Permissions (manage permissions):
    connections     List interface connections
    interface       Show details of snap interfaces
    connect         Connect a plug to a slot
    disconnect      Disconnect a plug from a slot

  Snapshots (archives of snap data):
    saved           List currently stored snapshots
    save            Save a snapshot of the current data
    check-snapshot  Check a snapshot
    restore         Restore a snapshot
    forget          Delete a snapshot

  Other (miscellanea):
    version         Show version details
    warnings        List warnings
    okay            Acknowledge warnings
    ack             Add an assertion to the system
    known           Show known assertions of the provided type

  Development (developer-oriented features):
    run             Run the given snap command
    pack            Pack the given directory as a snap
    try             Test an unpacked snap in the system
    download        Download the given snap
    prepare-image   Prepare a device image

For more information about a command, run 'snap help <command>'.

```



https://snapcraft.io/docs