Skip to content

kernel: add Pre/Post hooks to Kernel/Configure/Initramfs - #25216

Open
alewi-westermo wants to merge 1 commit into
openwrt:mainfrom
alewi-westermo:kernel-configure-initramfs-hooks
Open

alewi-westermo wants to merge 1 commit into
openwrt:mainfrom
alewi-westermo:kernel-configure-initramfs-hooks

Conversation

@alewi-westermo

Copy link
Copy Markdown

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

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 openwrt Bot added the build/scripts/tools pull request/issues for build, scripts and tools related changes label Sep 16, 2026

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 new commit.


Generated by Claude Code

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)))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build/scripts/tools pull request/issues for build, scripts and tools related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants