diff mbox series

initscripts: don't read /proc/cmdline in populate-volatile during build

Message ID 20251113163438.691353-1-ross.burton@arm.com
State Accepted, archived
Commit 52a6a9f23587cab65c76b6e9c9ec9721563854e0
Headers show
Series initscripts: don't read /proc/cmdline in populate-volatile during build | expand

Commit Message

Ross Burton Nov. 13, 2025, 4:34 p.m. UTC
The populate-volatile script will check for "clearcache" in the kernel
command line and wipe the caches if it has been set. This is useful at
boot, but we shouldn't be checking the kernel commandline when being
ran on the build machine at rootfs-time.

[ YOCTO #16056 ]

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../initscripts-1.0/populate-volatile.sh      | 24 ++++++++++---------
 1 file changed, 13 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
index bc630e871c1..8b0139c094f 100755
--- a/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
+++ b/meta/recipes-core/initscripts/initscripts-1.0/populate-volatile.sh
@@ -220,17 +220,19 @@  apply_cfgfile() {
 }
 
 clearcache=0
-exec 9</proc/cmdline
-while read -r line <&9
-do
-	case "$line" in
-		*clearcache*)  clearcache=1
-			       ;;
-		*)	       continue
-			       ;;
-	esac
-done
-exec 9>&-
+if test -z "$ROOT_DIR"; then
+	exec 9</proc/cmdline
+	while read -r line <&9
+	do
+		case "$line" in
+			*clearcache*)  clearcache=1
+					;;
+			*)	       continue
+					;;
+		esac
+	done
+	exec 9>&-
+fi
 
 if test -e "${ROOT_DIR}/etc/volatile.cache" -a "$VOLATILE_ENABLE_CACHE" = "yes" -a "x$1" != "xupdate" -a "x$clearcache" = "x0"
 then