kernel: add Pre/Post hooks to Kernel/Configure/Initramfs - #25216
Open
alewi-westermo wants to merge 1 commit into
Open
alewi-westermo wants to merge 1 commit into
alewi-westermo wants to merge 1 commit into
Conversation
Kernel/Configure/Initramfs is a plain one-liner that calls
Kernel/SetInitramfs. A target that needs to run an extra step while
the initramfs staging tree is being assembled (e.g. dropping an
extra file into the future root filesystem) currently has to override
the whole define and duplicate the internal Kernel/SetInitramfs call,
coupling the target to build-system internals.
Frame the Kernel/SetInitramfs call with additive Pre/Post hook lists,
mirroring the Hooks/Configure/{Pre,Post} pattern already used for
package builds in include/package.mk. Targets can then append to
Hooks/InitramfsConfigure/{Pre,Post} without touching the shared
define. Default behaviour is unchanged: with no hooks registered both
loops expand to nothing and only Kernel/SetInitramfs runs.
Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Alexander Wilhelm <[email protected]>
openwrt-ai
reviewed
Sep 16, 2026
Comment on lines
+133
to
+135
| $(foreach hook,$(Hooks/InitramfsConfigure/Pre),$(call $(hook),$(1),$(2));) \ | ||
| $(call Kernel/SetInitramfs,$(1),$(2)) \ | ||
| $(foreach hook,$(Hooks/InitramfsConfigure/Post),;$(call $(hook),$(1),$(2))) |
Collaborator
There was a problem hiding this comment.
Unlike the include/package.mk hooks this mirrors, these do not expand into a recipe with $(sep) between them — they expand inside the single backslash-continued shell line built by $(call locked,{ ... }) at kernel-defaults.mk:188-190, so a hook whose define body spans several lines injects a bare newline and aborts the recipe with /bin/sh: Syntax error: end of file unexpected (expecting "}"). Worth stating that constraint in a comment above the define (multi-line hook bodies must be backslash-continued), since the commit message points readers at the package.mk hooks, where multi-line bodies are fine.
Generated by Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kernel/Configure/Initramfs is a plain one-liner that calls Kernel/SetInitramfs. A target that needs to run an extra step while the initramfs staging tree is being assembled (e.g. dropping an extra file into the future root filesystem) currently has to override the whole define and duplicate the internal Kernel/SetInitramfs call, coupling the target to build-system internals.
Frame the Kernel/SetInitramfs call with additive Pre/Post hook lists, mirroring the Hooks/Configure/{Pre,Post} pattern already used for package builds in include/package.mk. Targets can then append to Hooks/InitramfsConfigure/{Pre,Post} without touching the shared define. Default behaviour is unchanged: with no hooks registered both loops expand to nothing and only Kernel/SetInitramfs runs.
Assisted-by: Claude:claude-opus-4.8