Re: [PATCH] kbuild: add target to build a cpio containing modules

From: Thomas Weißschuh
Date: Tue Nov 25 2025 - 07:53:13 EST


On Tue, Nov 25, 2025 at 01:07:20PM +0100, Ahmad Fatoum wrote:
> On 11/20/25 8:32 AM, Thomas Weißschuh wrote:
> >> diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> >> index 74bcb9e7f7a4516473481468a0fcf700c3bead33..20eec9e2dec4dda3fa0ef64a15b80dccdcb55f90 100644
> >> --- a/scripts/Makefile.package
> >> +++ b/scripts/Makefile.package

(...)

> >> +quiet_cmd_cpio = CPIO $@
> >> + cmd_cpio = $(srctree)/usr/gen_initramfs.sh $< > $@
> >
> > Use $(CONFIG_SHELL).
>
> Can do. Is this to allow users to override CONFIG_SHELL from outside?

I think so. Some distributions do weird things.

> If so, why not go one step further and remove shebangs from scripts
> altogether to enforce that they are called with a $(VARIABLE) that can
> be overridden?

The shebang is also useful to enable syntax highlighting in editors, tell
linters which shell dialect (POSIX/bash) is expected and to run the script
without kbuild. I would just leave it as is.

(...)

> > Is the cpio-data= intended to make sure the line 'hostprogs := gen_init_cpio'
> > is executed? I don't think this works as usr/Makefile will overwrite 'cpio-data'
> > in any case. But it should be fine to make hostprogs definition unconditional.
>
> Will add a commit making hostprogs := gen_init_cpio unconditional.
> The current approach worked though, because specifying the variable on
> the command line overrides cpio-data := assignments even if there are
> multiple.

Indeed. Good to know, thanks!


Thomas