[openwrt/openwrt] kernel: fix rootfs initramfs not updating on subsequent single build

LEDE Commits lede-commits at lists.infradead.org
Mon Jan 20 08:22:27 PST 2025


ansuel pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/334c649a8d9b191c0282f9104b3997b090628f56

commit 334c649a8d9b191c0282f9104b3997b090628f56
Author: Christian Marangi <ansuelsmth at gmail.com>
AuthorDate: Mon Jan 20 17:14:47 2025 +0100

    kernel: fix rootfs initramfs not updating on subsequent single build
    
    There is currently a problem where the rootfs in an initramfs image for
    single target build is not updated on subsequent run. This is caused by
    a bug introduced in d78dec3e19e3 ("kernel: copy kernel build dir on
    Per-Device Initramfs compilation") where the initramfs_data.cpio rm was
    moved to PrepareConfigPerRootfs. This caused the side effect of dropping
    the rm call for single target build making the kernel reusing the
    previous generated initramfs_data.cpio.
    
    To correctly handle this, restore the original location of this call
    right after the touch /init call. This way the kernel will always
    regenerate the initramfs embedded rootfs ALSO for single target build.
    
    Fixes: d78dec3e19e3 ("kernel: copy kernel build dir on Per-Device Initramfs compilation")
    Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
---
 include/kernel-defaults.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk
index f94ed33230..cbe415abe6 100644
--- a/include/kernel-defaults.mk
+++ b/include/kernel-defaults.mk
@@ -175,7 +175,6 @@ define Kernel/PrepareConfigPerRootfs
 		[ ! -d "$(1)" ] || rm -rf $(1); \
 		mkdir $(1) && $(CP) -T $(LINUX_DIR) $(1); \
 		touch $(1)/.config; \
-		rm -rf $(1)/usr/initramfs_data.cpio*; \
 	}
 endef
 
@@ -190,6 +189,7 @@ define Kernel/CompileImage/Initramfs
 		$(call Kernel/Configure/Initramfs,$(if $(1),$(1),$(TARGET_DIR)),$(LINUX_DIR)$(2)); \
 		$(CP) $(GENERIC_PLATFORM_DIR)/other-files/init $(if $(1),$(1),$(TARGET_DIR))/init; \
 		$(if $(SOURCE_DATE_EPOCH),touch -hcd "@$(SOURCE_DATE_EPOCH)" $(if $(1),$(1),$(TARGET_DIR)) $(if $(1),$(1),$(TARGET_DIR))/init;) \
+		rm -rf $(LINUX_DIR)$(2)/usr/initramfs_data.cpio*; \
 		$(if $(CONFIG_TARGET_ROOTFS_INITRAMFS_SEPARATE), \
 			$(call locked,{ \
 				$(if $(call qstrip,$(CONFIG_EXTERNAL_CPIO)), \




More information about the lede-commits mailing list