Hooks stanza doesn't match parts and apps
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Snapcraft |
New
|
Undecided
|
Unassigned |
Bug Description
Working on adding some font hooks for the Inkscape package it was my first time using hooks, and I found it kinda confusing. I think this largely stemmed from the fact that the hooks section works differently than the parts and apps sections.
The hooks section is abstractly like this: hooks.$
Where apps and parts are mostly like this: apps.$name.
I think that the $name attribute is useful for organization and allows for more flexible hooks. For instance I'd suggest what is now:
hooks:
configure:
plugs: [ desktop ]
Would look more like this:
hooks:
update-
trigger: [ configure ]
command: update-
plugs: [ desktop ]
This would allow for better organization and documentation of hooks.
Of course this would require some translation as snapd expects the original format. But that could be achieved with Snapcraft building a shell script for each trigger calling the appropriate hooks.
I very much support hooks mirroring apps. In fact, that's what the original proposal was[1]. The "trigger" idea is new though. Two questions come to mind:
1) Can you give me a use-case for where you'd want the exact same thing triggered upon multiple events?
2) If you define multiple hooks that are triggered by the same thing, how should snapcraft determine the order in which to execute them? Does it matter?
[1]: https:/ /github. com/snapcore/ snapcraft/ pull/921