I’m a little confused by mixing service-startup hook concept with install/remove hooks. It’s seems we’re interested in install/remove hooks after all, as described in the bug 1661126 linked by @kyrofa.
If this is correct and we’re looking for install/remove hooks, then these hooks would be similiar to configure hook, with exceptions of course. My proposal:
install hook gets executed when snap is installed, refreshed or reverted. It’s run before
- If it’s desirable to distinguish between install and revert/refresh (upgrade), then refresh and revert may have separate hooks (or we may pass extra environment variables to indicate this fact to install).
uninstall hook is only executed when last revision of snap is removed from the system.
uninstall would be run in transactions when it comes to configuration changes made via snapctl (similiar to
- Failure in
install hook would abort the install, undo the tasks internally etc. However, I’m not sure if we should have an
undo-install hook for failure on install during refresh. Perhaps if this was a refresh/revert, we should just run
install hook of the previous revision?
- Failure in
uninstall hook would log a warning, but would not abort snap removal.
I think that implementation of the suggestion regarding running install/uninstall hooks per-user (suggested in the comments of aforementioned bug report) is out of scope for now as this is a bigger shift in snapd.