configure hook

Didier Roche didrocks at ubuntu.com
Wed Nov 9 07:38:02 UTC 2016


Le 09/11/2016 à 07:44, Enwei Zhang a écrit :
> Hi Didier,
> Sorry to cut in.
> Is "hooks" working now in snapcraft?
> I encountered error:
> I used below in snapcraft.yaml:
>
> hooks: # Top-level YAML attribute, parallel to `apps`
>     upgrade: # Hook name, corresponds to executable name
>         plugs: [network] # Or any other plugs required by this hook
>
> enwei at XPS-13-9350:~/work/snap/simple-daemon$ snapcraft
> Issues while validating snapcraft.yaml: Additional properties are not
> allowed ('hooks' was unexpected)
> enwei at XPS-13-9350:~/work/snap/simple-daemon$ snapcraft --version
> 2.20

No, right now, they are only implemented in snapd.
You need to place the correct file in the meta/hooks/ folder (if you are
using snapcraft, do this in the prime/ directory, before "snapcraft snap
prime/").

There is an example available at
https://github.com/snapcore/snapd/tree/master/tests/lib/snaps/basic-hooks/meta/hooks.

Hope that helps!
Didier
>
> Thanks.
>
> Br
> Enwei
>
>
>
> On Tue, Nov 8, 2016 at 6:28 PM, Didier Roche <didrocks at ubuntu.com
> <mailto:didrocks at ubuntu.com>> wrote:
>
>     Le 08/11/2016 à 04:52, Kyle Fazzari a écrit :
>     >
>     > On Nov 6, 2016 21:51, "Didier Roche" <didrocks at ubuntu.com
>     <mailto:didrocks at ubuntu.com>
>     > <mailto:didrocks at ubuntu.com <mailto:didrocks at ubuntu.com>>> wrote:
>     >>
>     >> Le 06/11/2016 à 00:22, Boris Rybalkin a écrit :
>     >> >
>     >> > Hello,
>     >> >
>     >>
>     >> Hey Boris,
>     >> >
>     >> > I want to generate my config on snap install using snap location
>     >> > variables.
>     >> >
>     >> > From the docs configure hook is only triggered when 'snap set' is
>     >> > called. Will configure also be called on install and upgrade?
>     >> >
>     >> I didn't try it myself yet, but from what I heard yeah, they
>     will be run
>     >> at that time. Kyle can confirm (and if so, we'll update to the
>     >> documentation to reflect that).
>     >
>     > When I wrote it (and the docs) it was only run with `snap set`. I
>     > believe it's been modified since then to run upon initial install as
>     > well as upgrade; indeed Gustavo mentioned that it should serve as an
>     > install and an upgrade hook. The docs weren't updated with this
>     change,
>     > it seems. That recommendation should also be documented.
>     >
>     > Kyle
>     >
>
>     FYI, opened
>     https://github.com/ubuntudesign/snapcraft.io/issues/216
>     <https://github.com/ubuntudesign/snapcraft.io/issues/216>
>     about it (after confirming manually this new behavior).
>
>     So, to answer on the initial reply: yes, the hooks are ran on install
>     and upgrade.
>
>     Cheers,
>     Didier
>
>     --
>     Snapcraft mailing list
>     Snapcraft at lists.snapcraft.io <mailto:Snapcraft at lists.snapcraft.io>
>     Modify settings or unsubscribe at:
>     https://lists.ubuntu.com/mailman/listinfo/snapcraft
>     <https://lists.ubuntu.com/mailman/listinfo/snapcraft>
>
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/snapcraft/attachments/20161109/7852c6ad/attachment.html>


More information about the Snapcraft mailing list