Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Refresh the whole page, add install and remove hooks #98
Conversation
|
@stolowski can you review please? If you have relevant examples to add, please do! |
| +# This could be downloading a list of dynamic configuration options or creating a database. | ||
| +``` | ||
| + | ||
| +<br> |
caldav
Sep 8, 2017
Collaborator
This is expected, it prettifies a CSS issue with titles following a code block.
stolowski
suggested changes
Sep 8, 2017
Looks good overall, a few comments to consider. Thanks!
| + | ||
| +There are three hooks types: | ||
| + | ||
| +* [`configure`](#configure): on demand hook to `snap get` or `snap set` a configuration value inside a snap. |
| +There are three hooks types: | ||
| + | ||
| +* [`configure`](#configure): on demand hook to `snap get` or `snap set` a configuration value inside a snap. | ||
| +* [`install`](#install): run after a snap is installed on a system. |
| +[...] | ||
| +``` | ||
| + | ||
| +In this example, we have an application requesting hardware information during install or subsequent configuration. We are therefore granting access to the `hardware-observe` interface to the install and configure hooks, but denying them access to the `x11` one since they don't need to display anything on screen. |
stolowski
Sep 8, 2017
This is tricky... Interfaces that are not-autoconnected will not be available at the time the hook is executed.
| + | ||
| +### “install” | ||
| + | ||
| +The install hook is called upon initial install. If the hook exits non-zero, the installation of the snap will fail. |
stolowski
Sep 8, 2017
Also worth mentioning is the fact, that 'install' hook is exectued before services of the snap are started (contrary to configure hook, which runs afterwards).
| + | ||
| +### “remove” | ||
| + | ||
| +The remove hook is called upon snap removal. |
|
@stolowski updated |
stolowski
suggested changes
Sep 14, 2017
Looks goods, just two minor issues to fix and should be good to go. Thanks!
| +``` | ||
| + | ||
| +In this example, we have an application requesting hardware information during install or subsequent configuration. We are therefore granting access to the `hardware-observe` interface to the install and configure hooks, but denying them access to the `x11` one since they don't need to display anything on screen. Note that interfaces that are not auto-connected will not be available through hooks until they are connected. | ||
| + |
| + | ||
| +Before running the `snapcraft` command to build your snap, this `install` file should be placed at this location: | ||
| + | ||
| +`<snap project>/snap/hooks/configure`. |
| +There are three hooks types: | ||
| + | ||
| +* [`configure`](#configure): run after snap installation, refresh and on demand to `snap get` or `snap set` a configuration value inside a snap. | ||
| +* [`install`](#install): run when a snap is installed on the system, before any services contained by the snap have been started. |
evilnick
Sep 14, 2017
Does this only run on initial install, and not for example, when the snap is refreshed? I think we should explicitly clarify that here
caldav
added some commits
Sep 14, 2017
stolowski
approved these changes
Sep 14, 2017
Thanks David, looks good to me!
Nb, there is some more fancy stuff one can do with snap configuration as get/set supports JSON values, e.g. you can have a map and then access a value inside it with dotted path such as snap abc get foo.bar.baz. But I think this is a meterial for next update.
caldav commentedSep 8, 2017