Re: [PATCH] kbuild: add target to build a cpio containing modules
From: Ahmad Fatoum
Date: Tue Nov 25 2025 - 07:21:44 EST
Hi Nathan,
On 11/20/25 7:39 AM, Nathan Chancellor wrote:
> On Sat, Nov 15, 2025 at 03:21:51PM +0100, Ahmad Fatoum wrote:
>> From: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
>> +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?
After incorporating Thomas' feedback, this is simplified to:
$(Q)$(MAKE) $(build)=usr usr/gen_init_cpio
which looks much better.
>> + $(call cmd,cpio)
>> +
>> +PHONY += cpio-modules-pkg
>> +cpio-modules-pkg: modules-$(KERNELRELEASE)-$(ARCH).cpio
>
> I think it would make a little more sense (and match the style of the
> perf package targets as well) to name this target modules-cpio-pkg.
It currently matches the style of the tar packages, which start with
tar-, but I can follow the perf- order. Makes more sense if it's
extended to support compressed cpios in future too.
Cheers,
Ahmad
>
>> + @:
>> +
>> # perf-tar*-src-pkg - generate a source tarball with perf source
>> # ---------------------------------------------------------------------------
>>
>> @@ -245,6 +261,7 @@ help:
>> @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
>> @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
>> @echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball'
>> + @echo ' cpio-modules-pkg - Build the kernel modules as cpio archive'
>> @echo ' perf-tar-src-pkg - Build the perf source tarball with no compression'
>> @echo ' perf-targz-src-pkg - Build the perf source tarball with gzip compression'
>> @echo ' perf-tarbz2-src-pkg - Build the perf source tarball with bz2 compression'
>>
>> ---
>> base-commit: e9a6fb0bcdd7609be6969112f3fbfcce3b1d4a7c
>> change-id: 20251115-cpio-modules-pkg-70d85a69892b
>>
>> Best regards,
>> --
>> Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
>>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |