[09/17] meta-isar: deploy-image: Allow to cancel installation

Message ID baf4b2a434e0452d88798c84c66353d527e47925.1719927511.git.jan.kiszka@siemens.com
State Accepted, archived
Headers show
Series Reworks, fixes and unattended mode for image installer | expand

Commit Message

Jan Kiszka July 2, 2024, 1:38 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

Terminate if the users chooses to cancel. Offer this option also on the
final message box before the start.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../deploy-image/files/deploy-image-wic.sh    | 22 ++++++++++++-------
 1 file changed, 14 insertions(+), 8 deletions(-)

Patch

diff --git a/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh
index 284252fb..09d6cc11 100644
--- a/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh
+++ b/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh
@@ -12,10 +12,12 @@  if [ -z "$DISK_IMAGE" ]; then
     shopt -s nullglob
     array=(*)
     shopt -u nullglob
-    DISK_IMAGE=$(dialog --no-tags \
-                 --menu "Select image to be installed" 10 60 3 \
-                 "${array[@]}" --output-fd 1)
     popd
+    if ! DISK_IMAGE=$(dialog --no-tags \
+                      --menu "Select image to be installed" 10 60 3 \
+                      "${array[@]}" --output-fd 1)
+        exit 0
+    fi
 fi
 if [ ! -f "$installdata/$DISK_IMAGE" ]; then
     dialog --msgbox "Could not find an image to install. Installation aborted." 7 60
@@ -80,15 +82,19 @@  if [ "$(echo "$target_device_list" | wc -w)" -gt 1 ]; then
         target_size=$(lsblk --nodeps --noheadings -o SIZE /dev/"$target")
         array+=("/dev/$target" "/dev/$target $target_size")
     done
-    TARGET_DEVICE=$(dialog --no-tags \
-                    --menu "Select device to install $DISK_IMAGE" 10 60 3 \
-                    "${array[@]}" --output-fd 1)
-
+    if ! TARGET_DEVICE=$(dialog --no-tags \
+                         --menu "Select device to install image to" 10 60 3 \
+                         "${array[@]}" --output-fd 1); then
+        exit 0
+    fi
 else
     TARGET_DEVICE=/dev/$(echo "$target_device_list" | tr -d " ")
 fi
 TARGET_DEVICE_SIZE=$(lsblk --nodeps --noheadings -o SIZE "$TARGET_DEVICE")
-dialog --msgbox "Start installing '$DISK_IMAGE' to '$TARGET_DEVICE'(Size: '$TARGET_DEVICE_SIZE' )." 7 60
+if ! dialog --yes-label Ok --no-label Cancel \
+            --yesno "Start installing '$DISK_IMAGE' to '$TARGET_DEVICE'(Size: '$TARGET_DEVICE_SIZE' )." 7 60; then
+    exit 0
+fi
 
 bmap_options=""
 if [ -z "$DISK_BMAP" ]; then