From: Nathan Chancellor <nathan@kernel.org>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: "Nicolas Schier" <nicolas.schier@linux.dev>,
"Simon Glass" <sjg@chromium.org>,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
kernel@pengutronix.de, linux-kernel@vger.kernel.org,
linux-kbuild@vger.kernel.org,
"Sascha Hauer" <s.hauer@pengutronix.de>
Subject: Re: [PATCH] kbuild: add target to build a cpio containing modules
Date: Wed, 19 Nov 2025 23:39:36 -0700 [thread overview]
Message-ID: <20251120063936.GA3321365@ax162> (raw)
In-Reply-To: <20251115-cpio-modules-pkg-v1-1-01d5a0748442@pengutronix.de>
Hi Ahmad,
On Sat, Nov 15, 2025 at 03:21:51PM +0100, Ahmad Fatoum wrote:
> From: Sascha Hauer <s.hauer@pengutronix.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.
Yeah, I would say this is pretty useful, I have already used it while
triaging another issue.
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Co-developed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.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
> @:
>
> +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?
> + $(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.
> + @:
> +
> # 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@pengutronix.de>
>
next prev parent reply other threads:[~2025-11-20 6:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-15 14:21 [PATCH] kbuild: add target to build a cpio containing modules Ahmad Fatoum
2025-11-19 18:25 ` Simon Glass
2025-11-20 6:39 ` Nathan Chancellor [this message]
2025-11-25 12:21 ` Ahmad Fatoum
2025-11-26 21:03 ` Nicolas Schier
2025-11-20 7:32 ` Thomas Weißschuh
2025-11-25 12:07 ` Ahmad Fatoum
2025-11-25 12:52 ` Thomas Weißschuh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251120063936.GA3321365@ax162 \
--to=nathan@kernel.org \
--cc=a.fatoum@pengutronix.de \
--cc=kernel@pengutronix.de \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.schier@linux.dev \
--cc=s.hauer@pengutronix.de \
--cc=sjg@chromium.org \
--cc=thomas.weissschuh@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox