[PATCH v2] base-files: remove break from initramfs test

Florian Eckert fe at dev.tdt.de
Tue Sep 10 07:18:39 PDT 2024


The 'preinit' script '/lib/preinit/70_initramfs_test' [1] checks whether
the system is running in an 'initramfs'. If this is the case, the loop [2]
in which the function is called is exited via a 'break' call. Further
'preinit_main' hooks are ignored.

This behavior is very unfortunate and would not be expected. The 'break' is
therefore removed. This means that all further 'preinit_main' hooks
continued to be processed.

To ensure that the system continues to behave as before, all scripts that
are executed after the 'break' must be checked to see whether they are
running in an initramfs so that they are not executed.

[1] https://github.com/openwrt/openwrt/blob/master/package/base-files/files/lib/preinit/70_initramfs_test
[2] https://github.com/openwrt/openwrt/blob/master/package/base-files/files/lib/functions/preinit.sh#L57

Signed-off-by: Florian Eckert <fe at dev.tdt.de>
---
 package/base-files/files/lib/preinit/70_initramfs_test          | 1 -
 package/base-files/files/lib/preinit/99_10_run_init             | 2 +-
 target/linux/mvebu/cortexa53/base-files/lib/preinit/82_uDPU     | 2 +-
 .../mvebu/cortexa9/base-files/lib/preinit/81_linksys_syscfg     | 2 +-
 4 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/package/base-files/files/lib/preinit/70_initramfs_test b/package/base-files/files/lib/preinit/70_initramfs_test
index c5aae983c7..940a2756ba 100644
--- a/package/base-files/files/lib/preinit/70_initramfs_test
+++ b/package/base-files/files/lib/preinit/70_initramfs_test
@@ -5,7 +5,6 @@ initramfs_test() {
 	if [ -n "$INITRAMFS" ]; then
 		boot_run_hook initramfs
 		preinit_ip_deconfig
-		break
 	fi
 }
 
diff --git a/package/base-files/files/lib/preinit/99_10_run_init b/package/base-files/files/lib/preinit/99_10_run_init
index ebf77b0896..a4232bc332 100644
--- a/package/base-files/files/lib/preinit/99_10_run_init
+++ b/package/base-files/files/lib/preinit/99_10_run_init
@@ -5,4 +5,4 @@ run_init() {
 	preinit_ip_deconfig
 }
 
-boot_hook_add preinit_main run_init
+[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main run_init
diff --git a/target/linux/mvebu/cortexa53/base-files/lib/preinit/82_uDPU b/target/linux/mvebu/cortexa53/base-files/lib/preinit/82_uDPU
index 1c72d0fe66..3efc6ccb30 100644
--- a/target/linux/mvebu/cortexa53/base-files/lib/preinit/82_uDPU
+++ b/target/linux/mvebu/cortexa53/base-files/lib/preinit/82_uDPU
@@ -46,4 +46,4 @@ preinit_mount_udpu() {
 	esac
 }
 
-boot_hook_add preinit_main preinit_mount_udpu
+[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main preinit_mount_udpu
diff --git a/target/linux/mvebu/cortexa9/base-files/lib/preinit/81_linksys_syscfg b/target/linux/mvebu/cortexa9/base-files/lib/preinit/81_linksys_syscfg
index 6ebd727556..26cbcbbbf2 100644
--- a/target/linux/mvebu/cortexa9/base-files/lib/preinit/81_linksys_syscfg
+++ b/target/linux/mvebu/cortexa9/base-files/lib/preinit/81_linksys_syscfg
@@ -39,4 +39,4 @@ preinit_mount_syscfg() {
 	esac
 }
 
-boot_hook_add preinit_main preinit_mount_syscfg
+[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main preinit_mount_syscfg
-- 
2.39.2




More information about the openwrt-devel mailing list