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

From: Nicolas Schier

Date: Fri Nov 28 2025 - 14:20:27 EST


On Wed, Nov 19, 2025 at 11:39:36PM -0700, Nathan Chancellor wrote:
...
> > diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> > index 74bcb9e7f7a4516473481468a0fcf700c3bead33..20eec9e2dec4dda3fa0ef64a15b80dccdcb55f90 100644
> > --- a/scripts/Makefile.package
> > +++ b/scripts/Makefile.package
> > @@ -189,6 +189,22 @@ tar-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar
> > tar%-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar.% FORCE
> > @:
> >
> > +modules-install: FORCE
> > + $(Q)$(MAKE) -f $(srctree)/Makefile
> > + $(Q)rm -rf $@
> > + $(Q)$(MAKE) -f $(srctree)/Makefile INSTALL_MOD_PATH=$@ modules_install
> > +
> > +quiet_cmd_cpio = CPIO $@
> > + cmd_cpio = $(srctree)/usr/gen_initramfs.sh $< > $@
> > +
> > +modules-$(KERNELRELEASE)-$(ARCH).cpio: modules-install
> > + $(Q)$(MAKE) -f $(srctree)/Makefile $(build)=usr cpio-data= usr/gen_init_cpio
>
> This seems like a bit of a hack to generate gen_init_cpio this way but I
> am not sure it is worth moving usr/gen_init_cpio.c and
> usr/gen_initramfs.sh elsewhere (scripts?) to make it a most accessible
> hostprog right now... Nicolas, do you have any opinions on this?

Yes, it feels hacky to me, too. After digging into this a bit, I am in
favor of moving at least gen_init* and friends to scripts/. I can
prepare a patch in a few days.

Kind regards,
Nicolas