Extensible Hooks

This library will allow you to use many scripts for each Snap Hook. When using this library, simply drop your hook script(s) into [snap_dir]/hooks.d/[hook_name]/*, where [snap_dir] is the top-level of your snap filesystem, and [hook_name] is the name of the hook from the following supported list:

  • install
  • configure
  • pre-refresh
  • post-refresh
  • remove

Usage with sc-jsonnet

Applying the utility with sc-jsonnet is the easiest method. To use, simply import the library and add extensible_hooks() to your snapcraft tag. The following code shows a trivial example of using it:

local snapcraft = import 'snapcraft.libsonnet';
local extensible_hooks = import 'https://raw.githubusercontent.com/diddlesnaps/snapcraft-utils-library/master/lib/extensible-hooks.libsonnet';

snapcraft {
    name: extensible-hooks-example,
    version: "0.1",
    summary: "Example of using the 'extensible-hooks' library",
    description: |||
        This is my-snap's description. You have a paragraph or two to tell the
        most important story about your snap. Keep it under 100 words though,
        we live in tweetspace and your description wants to look good in the snap

    base: core18,

    # Add the rest of your snapcraft build config here
+ extensible_hooks()

Manually adding to snapcraft.yaml

Simply add the following part into your snapcraft.yaml:

    plugin: dump
    source: https://github.com/diddlesnaps/snapcraft-utils-library.git
    source-subdir: snapcraft-assets/extensible-hooks