[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251120080325-536d8deb-fdfe-4dc0-9687-d5d73006376c@linutronix.de>
Date: Thu, 20 Nov 2025 08:32:50 +0100
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: Ahmad Fatoum <a.fatoum@...gutronix.de>
Cc: Nathan Chancellor <nathan@...nel.org>,
Nicolas Schier <nicolas.schier@...ux.dev>, Simon Glass <sjg@...omium.org>, kernel@...gutronix.de,
linux-kernel@...r.kernel.org, linux-kbuild@...r.kernel.org,
Sascha Hauer <s.hauer@...gutronix.de>
Subject: Re: [PATCH] kbuild: add target to build a cpio containing modules
On Sat, Nov 15, 2025 at 03:21:51PM +0100, Ahmad Fatoum wrote:
> From: Sascha Hauer <s.hauer@...gutronix.de>
>
> Add a new package target to build a cpio archive containing the kernel
> modules. This is particularly useful to supplement an existing initramfs
> with the kernel modules so that the root filesystem can be started with
> all needed kernel modules without modifying it.
>
> Signed-off-by: Sascha Hauer <s.hauer@...gutronix.de>
> Co-developed-by: Ahmad Fatoum <a.fatoum@...gutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@...gutronix.de>
> ---
> .gitignore | 5 +++++
> Makefile | 2 +-
> scripts/Makefile.package | 17 +++++++++++++++++
> 3 files changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/.gitignore b/.gitignore
> index 86a1ba0d90353962183b47c0c657ec877e5b2f9f..764d115400d90f0904b8f60ea8851a7860c16411 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -96,6 +96,11 @@ modules.order
> #
> /tar-install/
>
> +#
> +# modules directory (make cpio-modules-pkg)
> +#
> +/modules-install/
> +
> #
> # pacman files (make pacman-pkg)
> #
> diff --git a/Makefile b/Makefile
> index fb4389aa5d5f1776f7bb5988102ed54f92491de7..19c7900d02ed5eee06f00820c138591b42e895e1 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1583,7 +1583,7 @@ CLEAN_FILES += vmlinux.symvers modules-only.symvers \
> # Directories & files removed with 'make mrproper'
> MRPROPER_FILES += include/config include/generated \
> arch/$(SRCARCH)/include/generated .objdiff \
> - debian snap tar-install PKGBUILD pacman \
> + debian snap tar-install modules-install PKGBUILD pacman \
> .config .config.old .version \
> Module.symvers \
> certs/signing_key.pem \
> 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
> @:
The other package targets have a separator and documentation comment.
>
> +modules-install: FORCE
> + $(Q)$(MAKE) -f $(srctree)/Makefile
> + $(Q)rm -rf $@
We have the filename prefix ".tmp_" for temporary files and directories.
These will be automatically ignored by git and cleaned up by "make clean".
> + $(Q)$(MAKE) -f $(srctree)/Makefile INSTALL_MOD_PATH=$@ modules_install
> +
> +quiet_cmd_cpio = CPIO $@
> + cmd_cpio = $(srctree)/usr/gen_initramfs.sh $< > $@
Use $(CONFIG_SHELL).
Using '-o' instead of redirecting stdout to the output file should enable the
usage of the recent copy_file_range() optimizations in gen_init_cpio.
> +
> +modules-$(KERNELRELEASE)-$(ARCH).cpio: modules-install
> + $(Q)$(MAKE) -f $(srctree)/Makefile $(build)=usr cpio-data= usr/gen_init_cpio
Drop the explicit '-f'; $(build) overwrites it.
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.
> + $(call cmd,cpio)
> +
> +PHONY += cpio-modules-pkg
> +cpio-modules-pkg: modules-$(KERNELRELEASE)-$(ARCH).cpio
> + @:
> +
> # 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@...gutronix.de>
>
Powered by blists - more mailing lists