[PATCH 06/10] base-files: upgrade: stage2: rework log lines

Yousong Zhou yszhou4tech at gmail.com
Tue Nov 3 07:21:03 EST 2020


 - Use common v function when possible
 - Write log lines to stderr when using echo

Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
---
 package/base-files/files/lib/upgrade/stage2 | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2
index a4fef42134..b452590eec 100755
--- a/package/base-files/files/lib/upgrade/stage2
+++ b/package/base-files/files/lib/upgrade/stage2
@@ -53,7 +53,7 @@ switch_to_ramfs() {
 	[ -L "/lib64" ] && ln -s /lib $RAM_ROOT/lib64
 
 	supivot $RAM_ROOT /mnt || {
-		echo "Failed to switch over to ramfs. Please reboot."
+		v "Failed to switch over to ramfs. Please reboot."
 		exit 1
 	}
 
@@ -75,7 +75,7 @@ kill_remaining() { # [ <signal> [ <loop> ] ]
 	local stat
 	local proc_ppid=$(cut -d' ' -f4  /proc/$$/stat)
 
-	echo -n "Sending $sig to remaining processes ... "
+	echo -n "Sending $sig to remaining processes ... " >&2
 
 	while $run; do
 		run=false
@@ -95,7 +95,7 @@ kill_remaining() { # [ <signal> [ <loop> ] ]
 			# Skip kernel threads
 			[ -n "$cmdline" ] || continue
 
-			echo -n "$name "
+			echo -n "$name " >&2
 			kill -$sig $pid 2>/dev/null
 
 			[ $loop -eq 1 ] && run=true
@@ -104,7 +104,7 @@ kill_remaining() { # [ <signal> [ <loop> ] ]
 		let loop_limit--
 		[ $loop_limit -eq 0 ] && {
 			echo
-			echo "Failed to kill all processes."
+			v "Failed to kill all processes."
 			exit 1
 		}
 	done
@@ -129,7 +129,7 @@ if [ -n "$IMAGE" ] && type 'platform_pre_upgrade' >/dev/null 2>/dev/null; then
 fi
 
 if [ -n "$(rootfs_type)" ]; then
-	echo "Switching to ramdisk..."
+	v "Switching to ramdisk..."
 	switch_to_ramfs
 fi
 



More information about the openwrt-devel mailing list