Friday, June 2, 2017

Good snapcrafters use plugins; great snapcrafters steal

When I am snapping a new piece of software I usually find myself googling for similar snapcraft.yaml. This is somewhat embarrassing and looks like I don't know what I am doing.

Well, that's very often precisely the case. There are amazing applications out there, but they require some complex plumbing to work nicely, ask Debian maintainers ...

There is a vast and welcoming documentation for creating a snapcraft project from scratch, a large collection of plugins and a precise method for reaching strict confinement. It's much easier than it use to be.

However, sometimes it's difficult to figure out even basic command invocation bits ... Or perhaps it's just curiosity and willing to learn from someone else experience (wow! Plenty of euphemisms for laziness. Why bother after that post title ?)

One can always find, download, unpack and inspect snaps that you think have solved problems similar than yours:

$ snap find cassandra
Name       Version  Developer  Notes  Summary
cassandra  3.7      ev         -      Cassandra distributed database

$ snap download cassandra
Fetching snap "cassandra"
Fetching assertions for "cassandra"

$ ls -lh cassandra_66.*
-rw-rw-r-- 1 cprov cprov 5.5K Jun  2 10:05 cassandra_66.assert
-rw-r--r-- 1 cprov cprov  66M Jun  2 10:05 cassandra_66.snap

$ unsquashfs -n cassandra_66.snap meta/snap.yaml
...

$ cat squashfs-root/meta/snap.yaml
apps:
  cassandra:
    command: command-cassandra.wrapper
    daemon: forking
    plugs:
    - network
    - network-bind
    - mount-observe
...

But this it's not particularly efficient or pleasant to download 66+ MB just for checking a 1K YAML file.

It is lot easier to ask the Snap Store:

$ curl -s -H 'X-Ubuntu-Series: 16' 'https://search.apps.ubuntu.com/api/v1/snaps/details/cassandra?fields=snap_yaml_raw' | jq '.snap_yaml_raw' -r
apps:
  cassandra:
    command: command-cassandra.wrapper
    daemon: forking
    plugs:
    - network
    - network-bind
    - mount-observe
...

No comments: