fix: hooks: process generated hooks
Metadata
Current evaluation
Merged as commit c77e3a07a (CRAFT-1159): core22 now includes lifecycle-generated hooks in the snap via meta/hooks wrappers, with snap/hooks taking priority; adds spread tests for core18/20/22.
Resolution: closed resolved
Reason: PR #3837 was approved and merged into main as commit c77e3a07a "hooks: process generated hooks (#3837)", porting the snapcraft_legacy behaviour so generated hooks are packaged for core22 alongside core18/core20, with new spread test coverage.
Evaluated by: mr-cal-bot
No scores available.
Issue body
- [X] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [X] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [X] Have you successfully run `make lint`?
- [X] Have you successfully run `pytest tests/unit`?
-----
#### Overview
Port support for generated hooks from `snapcraft_legacy` to `snapcraft`.
#### Issue
- Hooks generated during snapcraft's lifecycle were not being included in the snap.
- https://forum.snapcraft.io/t/call-for-testing-snapcraft-7/30201/43
#### Changes
- `core22` snaps now follow same behavior as `core18` and `core20`
- Hooks generated during the lifecycle are included in the final snap package
- A wrapper for each generated hook is written to `meta/hooks/`
- Pre-existing hooks in `snap/hooks/` take priority over generated hooks
- Spread test for generated and pre-existing hooks for `core18`, `core20`, and `core22`
(CRAFT-1159)
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged as commit c77e3a07a (CRAFT-1159): core22 now includes lifecycle-generated hooks in the snap via meta/hooks wrappers, with snap/hooks taking priority; adds spread tests for core18/20/22. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged in #3837 as c77e3a07a, including lifecycle-generated hooks in final snaps via meta/hooks wrappers while preserving existing snap/hooks, with spread coverage. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #3837 (c77e3a07a), including lifecycle-generated hooks in core18, core20, and core22 snaps via meta/hooks wrappers. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged fix to include generated hooks in snap packages. Ports legacy behavior to snapcraft, writing wrappers to meta/hooks/ while preserving pre-existing hooks. Added spread tests for core18, core20, and core22. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged a fix porting generated hook support to snapcraft. Core22 snaps now include lifecycle-generated hooks via meta/hooks/ wrappers, prioritizing pre-existing hooks. Spread tests verify behavior across core18, core20, and core22. |
Update history
No update history recorded yet.
Related work
-
Related To:
canonical/snapcraft#6433
(confidence 30%)
Later issue about generated hooks missing from the snap, fixed in 9.1.3 (commit 271462658) — a subsequent regression, not linked to this PR.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #6433 Generated hooks are not included in the Snap | snapcraft | closed | Generated part hooks now replace stubs correctly; commit 271462658 prevents premature stub creation and was targeted for Snapcraft 9.1.3. | |
| #3659 meta: add support for hooks | snapcraft | merged | Merged snapcraft#3659 via commit 00eed7dc9 (merge 795294fd5) into snapcraft/7.0, adding hooks support in snapcraft.yaml for CRAFT-808. | |
| #1026 Add support for hooks. | snapcraft | merged | PR #1026 merged as commit 01880ee8d ('core: add support for hooks'), adding hook support: executables in snap/hooks/ are copied into the snap, and parts can install hooks into snap/hooks/. Docs followed in #1042 (10c58b652). | |
| #1980089 Compiled snap hooks not executed when packaging with Snapcraft 7 | snapcraft (launchpad) | closed | Compiled snap hooks are supported again by merged PR snapcore/snapcraft#3837 (commit c77e3a07a), which processes generated hooks and restores the expected meta/hooks entries. | |
| #3386 meta: don't overwrite preconfigured hooks with stubs | snapcraft | merged | Hook stub generation now preserves existing primed meta/hooks scripts; merged in snapcraft#3386 via commit bb9525144, with added unit-test fixtures and coverage. | |
| #1812003 hooks should be made executable instead of erroring out | snapcraft (launchpad) | closed | Fixed by merged PR snapcore/snapcraft#2440 (commit c2f5a0dc0), which packages recognized hooks as executable instead of rejecting non-executable source files. | |
| #1586465 Add support for hooks | snapcraft (launchpad) | closed | Hook support was added in snapcore/snapcraft#1026 via commit 01880ee8d, packaging hook files and snapcraft.yaml hook definitions. | |
| #921 Add support for hooks. | snapcraft | closed | PR #921 (declarative `hooks:` with generated hook scripts) was closed unmerged after redesign discussion with snapd's niemeyer; hook support instead landed in #1026 (commit 01880ee8d) with docs in #1042. | |
| #4592 Support project hooks for core24 snaps | snapcraft | closed | Core24 project hook packaging was implemented in snapcraft#4717 and merged as commit aafbe672b, with hook-packaging tests. | |
| #4186 snap: migrate to core22 | snapcraft | merged | PR #4186 merged, moving the Snapcraft snap's own build environment to base core22 (8 files, +71/-70), landing as commit 60033305b and closing the core22 migration issue #4166. |