[1/3] installer: add reusable progress gauge

Message ID 20261027110601.1197504-1-srinuvasan.a@siemens.com
State Under Review
Headers show
Series [1/3] installer: add reusable progress gauge | expand

Commit Message

srinuvasan.a Oct. 27, 2026, 11:05 a.m. UTC
From: Srinuvasan A <srinuvasan.a@siemens.com>

Add an independent percentage consumer for operations reporting progress.
Drain progress if dialog exits early, preserving producer execution.
Keep existing image-copy and RAID progress handling unchanged.

Signed-off-by: Shivaschandra K L <shivaschandra.k-l@siemens.com>
Signed-off-by: Srinuvasan A <srinuvasan.a@siemens.com>
Suggested-by: Cedric Hombourger <cedric.hombourger@siemens.com>
---
 .../files/usr/bin/installer_ui.sh             | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)

Patch

diff --git a/meta-isar/recipes-installer/deploy-image/files/usr/bin/installer_ui.sh b/meta-isar/recipes-installer/deploy-image/files/usr/bin/installer_ui.sh
index 133d7c70..aa906221 100644
--- a/meta-isar/recipes-installer/deploy-image/files/usr/bin/installer_ui.sh
+++ b/meta-isar/recipes-installer/deploy-image/files/usr/bin/installer_ui.sh
@@ -185,6 +185,30 @@  ui_start_progress_gauge() {
     UI_GAUGE_PID=$!
 }
 
+#--------------------------------------------------------------------------
+# ui_progress_gauge <message>
+#
+# Reads integer percentages (0-100), one per line, from stdin.
+# No dialog is opened until the first percentage arrives.
+# If dialog exits early, drain the remaining input so the operation is
+# not interrupted by SIGPIPE. Callers must check the producer's status
+# using PIPESTATUS[0]; a completed gauge does not imply operation success.
+# Returns dialog's status after all progress input has been consumed.
+#--------------------------------------------------------------------------
+ui_progress_gauge() {
+    local message="$1"
+    local status=0
+    local percent
+
+    IFS= read -r percent || return 0
+    dialog --gauge "$message" 10 70 "$percent" || status=$?
+    if [ "$status" -ne 0 ]; then
+        echo "Warning: progress dialog failed; waiting for the operation to finish." >&2
+    fi
+    cat >/dev/null
+    return "$status"
+}
+
 #--------------------------------------------------------------------------
 # ui_stop_progress_gauge
 #