diff mbox series

[1/1] linux: Use the choosen rootfs compression type when rootfs is builtin

Message ID 20231106123705.311899-1-clabbe@baylibre.com
State New
Headers show
Series [1/1] linux: Use the choosen rootfs compression type when rootfs is builtin | expand

Commit Message

Corentin LABBE Nov. 6, 2023, 12:37 p.m. UTC
I have built a buildroot with:
BR2_TARGET_ROOTFS_CPIO_XZ=y
BR2_TARGET_ROOTFS_INITRAMFS=y
With this buildroot produces an images/rootfs.cpio.xz but the kernel still use gzip (CONFIG_INITRAMFS_COMPRESSION_GZIP)
as compression for a plain rootfs.cpio

Setting CONFIG_INITRAMFS_COMPRESSION_XZ in a linux.fragment does not
work as it seems the fragment is setup before buildroot set
CONFIG_INITRAMFS_SOURCE which reset the CONFIG_INITRAMFS_COMPRESSION
choice.

So buildroot have to change CONFIG_INITRAMFS_COMPRESSION after setup
CONFIG_INITRAMFS_SOURCE.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 linux/linux.mk | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Corentin LABBE Nov. 27, 2023, 11:42 a.m. UTC | #1
Le Mon, Nov 06, 2023 at 12:37:05PM +0000, Corentin Labbe a écrit :
> I have built a buildroot with:
> BR2_TARGET_ROOTFS_CPIO_XZ=y
> BR2_TARGET_ROOTFS_INITRAMFS=y
> With this buildroot produces an images/rootfs.cpio.xz but the kernel still use gzip (CONFIG_INITRAMFS_COMPRESSION_GZIP)
> as compression for a plain rootfs.cpio
> 
> Setting CONFIG_INITRAMFS_COMPRESSION_XZ in a linux.fragment does not
> work as it seems the fragment is setup before buildroot set
> CONFIG_INITRAMFS_SOURCE which reset the CONFIG_INITRAMFS_COMPRESSION
> choice.
> 
> So buildroot have to change CONFIG_INITRAMFS_COMPRESSION after setup
> CONFIG_INITRAMFS_SOURCE.
> 
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---

Hello

Ping

Regards
diff mbox series

Patch

diff --git a/linux/linux.mk b/linux/linux.mk
index 1db5c6046d..d64ebb5119 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -116,6 +116,14 @@  LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_XZ) += CONFIG_KERNEL_XZ
 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_ZSTD) += CONFIG_KERNEL_ZSTD
 LINUX_COMPRESSION_OPT_$(BR2_LINUX_KERNEL_UNCOMPRESSED) += CONFIG_KERNEL_UNCOMPRESSED
 
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_GZIP) += CONFIG_INITRAMFS_COMPRESSION_GZIP
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZ4) += CONFIG_INITRAMFS_COMPRESSION_LZ4
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZMA) += CONFIG_INITRAMFS_COMPRESSION_LZMA
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_LZO) += CONFIG_INITRAMFS_COMPRESSION_LZO
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_XZ) += CONFIG_INITRAMFS_COMPRESSION_XZ
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_ZSTD) += CONFIG_INITRAMFS_COMPRESSION_ZSTD
+LINUX_ROOTFS_COMPRESSION_OPT_$(BR2_TARGET_ROOTFS_CPIO_NONE) += CONFIG_INITRAMFS_COMPRESSION_NONE
+
 ifeq ($(BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL),y)
 LINUX_DEPENDENCIES += host-openssl
 endif
@@ -378,6 +386,10 @@  define LINUX_KCONFIG_FIXUP_CMDS_ROOTFS_CPIO
 	$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_SOURCE,"$${BR_BINARIES_DIR}/rootfs.cpio")
 	$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_UID,0)
 	$(call KCONFIG_SET_OPT,CONFIG_INITRAMFS_ROOT_GID,0)
+	$(call KCONFIG_ENABLE_OPT,$(strip $(LINUX_ROOTFS_COMPRESSION_OPT_y)))
+	$(foreach opt, $(LINUX_ROOTFS_COMPRESSION_OPT_),
+		$(call KCONFIG_DISABLE_OPT,$(opt))
+	)
 endef
 endif