kbuild: add target to build a cpio containing modules
v2 cover kbuild: add target to build a cpio containing modules
---
Changes in v2:
- Add Simon's Tested-by and Reviewed-by
- rename to modules-cpio-pkg (Nathan)
- add separator/doc comment heading (Thomas)
- Make temp directory ignoring and cleanup automatic (Thomas)
- Use CONFIG_SHELL instead of shebang (Thomas)
- Use -o instead of redirecting stdout when creating cpio (Thomas)
- Drop superfluous -f as $(build)= overrides it (Thomas)
- Add extra preparatory patch that makes hostprogs := gen_init_cpio
unconditional
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Ahmad Fatoum (1):
initramfs: add gen_init_cpio to hostprogs unconditionally
Sascha Hauer (1):
kbuild: add target to build a cpio containing modules
scripts/Makefile.package | 20 ++++++++++++++++++++ usr/Makefile | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-)
---
base-commit: e9a6fb0bcdd7609be6969112f3fbfcce3b1d4a7c
change-id: 20251115-cpio-modules-pkg-70d85a69892b
Best regards,
Signature · 1 line
Ahmad Fatoum <[email protected]>
PATCH v2 1/2 initramfs: add gen_init_cpio to hostprogs unconditionally
gen_init_cpio is currently only needed when an initramfs cpio archive is to be created out of CONFIG_INITRAMFS_SOURCE's contents. In other cases, it's not added to hostprogs and no make target is available.
In preparation to use the host program from Makefile.package, define it unconditionally. The program will still only be built as needed.
--- usr/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
usr/Makefile +2 -2
@@ -16,6 +16,8 @@ obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o $(obj)/initramfs_data.o: $(obj)/initramfs_inc_data +hostprogs := gen_init_cpio + ramfs-input := $(CONFIG_INITRAMFS_SOURCE) cpio-data :=
@@ -48,8 +50,6 @@ ifeq ($(cpio-data),) cpio-data := $(obj)/initramfs_data.cpio -hostprogs := gen_init_cpio - # .initramfs_data.cpio.d is used to identify all files included # in initramfs and to detect if any files are added/removed. # Removed files are identified by directory timestamp being updated
Signature · 1 line
2.47.3
Re: [PATCH v2 1/2] initramfs: add gen_init_cpio to hostprogs unconditionally
Quoted 5 lines · Ahmad Fatoum
gen_init_cpiois currently only needed when an initramfs cpio archive is to be created out of CONFIG_INITRAMFS_SOURCE's contents. In other cases, it's not added to hostprogs and no make target is available.
Quoted 7 lines
In preparation to use the host program from Makefile.package, define it unconditionally. The program will still only be built as needed.
Signed-off-by Ahmad Fatoum <[email protected]>--- usr/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH v2 2/2 kbuild: add target to build a cpio containing modules
In reply to Ahmad FatoumFrom: Sascha Hauer <[email protected]>
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.
--- scripts/Makefile.package | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
scripts/Makefile.package +20 -0
@@ -189,6 +189,25 @@ tar-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar tar%-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar.% FORCE @: +# modules-cpio-pkg - generate an initramfs with the modules +# --------------------------------------------------------------------------- + +.tmp_modules_cpio: 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 = $(CONFIG_SHELL) $(srctree)/usr/gen_initramfs.sh -o $@ $< + +modules-$(KERNELRELEASE)-$(ARCH).cpio: .tmp_modules_cpio + $(Q)$(MAKE) $(build)=usr usr/gen_init_cpio + $(call cmd,cpio) + +PHONY += modules-cpio-pkg +modules-cpio-pkg: modules-$(KERNELRELEASE)-$(ARCH).cpio + @: + # perf-tar*-src-pkg - generate a source tarball with perf source # ---------------------------------------------------------------------------
@@ -245,6 +264,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 ' modules-cpio-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'
Signature · 1 line
2.47.3
Quoted 21 lines · Ahmad Fatoum
From: Sascha Hauer <[email protected]>
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 <[email protected]>Reviewed-by Simon Glass <[email protected]>Tested-by Simon Glass <[email protected]>Co-developed-by Ahmad Fatoum <[email protected]>Signed-off-by Ahmad Fatoum <[email protected]>--- scripts/Makefile.package | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)scripts/Makefile.package +0
-0
scripts/Makefile.package tar-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar · line 198
Quoted 10 lines
scripts/Makefile.package +7
-0@@ -189,6 +189,25 @@ tar-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar tar%-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar.% FORCE @: +# modules-cpio-pkg - generate an initramfs with the modules +# --------------------------------------------------------------------------- + +.tmp_modules_cpio: FORCE + $(Q)$(MAKE) -f $(srctree)/Makefile + $(Q)rm -rf $@ + $(Q)$(MAKE) -f $(srctree)/Makefile INSTALL_MOD_PATH=$@ modules_install
Do you know why '-f $(srctree)/Makefile' is necessary here? As this and the make call two lines above call common top-level targets, I do not see the reason for explicitly adding the Makefile path. Am I missing something; or have you observed problems without '-f'?
scripts/Makefile.package tar-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar · line 205
Quoted 7 lines
scripts/Makefile.package +7
-0+ +quiet_cmd_cpio = CPIO $@ + cmd_cpio = $(CONFIG_SHELL) $(srctree)/usr/gen_initramfs.sh -o $@ $< + +modules-$(KERNELRELEASE)-$(ARCH).cpio: .tmp_modules_cpio + $(Q)$(MAKE) $(build)=usr usr/gen_init_cpio + $(call cmd,cpio)
Removing the '$(MAKE) $(build)=usr usr/gen_init_cpio' line and adding
PHONY += usr_gen_init_cpiousr_gen_init_cpio: scripts_basic
$(Q)$(MAKE) $(build)=usr usr/gen_init_cpio
modules-cpio-pkg: usr_gen_init_cpio
to top-level Makefile could be used to allow make to compile gen_init_cpio in parallel instead of sequential. And it simplifies a possible move of gen_init_cpio from usr/ to scripts/, as Nathan suggested.
What do you think? (Top-level Makefile addition should probably better be integrated into patch 1.) I can also send this as a follow-up patch after merging your patches.
Nevertheless,
If there are no further remarks, I am going to merge the patch set before the weekend.
Thanks and kind regards,
Nicolas
Quoted 21 lines · Ahmad Fatoum
---
Changes in v2:
- Add Simon's Tested-by and Reviewed-by
- rename to modules-cpio-pkg (Nathan)
- add separator/doc comment heading (Thomas)
- Make temp directory ignoring and cleanup automatic (Thomas)
- UseCONFIG_SHELLinstead of shebang (Thomas)
- Use -o instead of redirecting stdout when creating cpio (Thomas)
- Drop superfluous -f as $(build)= overrides it (Thomas)
- Add extra preparatory patch that makes hostprogs :=gen_init_cpio
unconditional
- Link to v1: https://lore.kernel.org/r/[email protected]---
Ahmad Fatoum (1):
initramfs: addgen_init_cpioto hostprogs unconditionallySascha Hauer (1):
kbuild: add target to build a cpio containing modules
Quoted 11 lines
scripts/Makefile.package | 20 ++++++++++++++++++++ usr/Makefile | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-)---
base-commit:e9a6fb0bcdd7609be6969112f3fbfcce3b1d4a7c
change-id: 20251115-cpio-modules-pkg-70d85a69892bBest regards,
Signature · 1 line
Ahmad Fatoum <[email protected]>
Thanks a lot for implementing all of Thomas's suggestions (and thanks to him for providing them). This series looks good to me and I can imagine this being quite useful for testing.
Cheers,
Nathan
Quoted 14 lines · Ahmad Fatoum
---
Changes in v2:
- Add Simon's Tested-by and Reviewed-by
- rename to modules-cpio-pkg (Nathan)
- add separator/doc comment heading (Thomas)
- Make temp directory ignoring and cleanup automatic (Thomas)
- UseCONFIG_SHELLinstead of shebang (Thomas)
- Use -o instead of redirecting stdout when creating cpio (Thomas)
- Drop superfluous -f as $(build)= overrides it (Thomas)
- Add extra preparatory patch that makes hostprogs :=gen_init_cpio
unconditional
- Link to v1: https://lore.kernel.org/r/[email protected]
Quoted 6 lines
---
Ahmad Fatoum (1):
initramfs: addgen_init_cpioto hostprogs unconditionallySascha Hauer (1):
kbuild: add target to build a cpio containing modules
For the series:
Quoted 12 lines
scripts/Makefile.package | 20 ++++++++++++++++++++ usr/Makefile | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-)---
base-commit:e9a6fb0bcdd7609be6969112f3fbfcce3b1d4a7c
change-id: 20251115-cpio-modules-pkg-70d85a69892bBest regards,
Signature · 1 line
Ahmad Fatoum <[email protected]>
Quoted 2 lines · Ahmad Fatoum
Applied, thanks!
[1/2] initramfs: add gen_init_cpio to hostprogs unconditionally
https://git.kernel.org/kbuild/c/c83c9564 [2/2] kbuild: add target to build a cpio containing modules https://git.kernel.org/kbuild/c/2a9c8c0b
Best regards,
Signature · 1 line
Nicolas