[11/17] meta-isar: deploy-image: Fix and enhance image selection dialog

Message ID 162026333e672018b2286d379fd9e88ea7792ce4.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>

The dialog was broken because an array of tag/value tuples had to be
provided, not just a list of files.

Use the chance an also fall back to the dialog if the search for
DISK_IMAGE does deliver a result but not a clear one. But only open the
dialog if there are entries.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../deploy-image/files/deploy-image-wic.sh     | 18 ++++++++++--------
 1 file changed, 10 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 81a006ce..35029728 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
@@ -7,16 +7,18 @@ 
 installdata=${INSTALL_DATA:-/install}
 
 DISK_IMAGE=$(find "$installdata" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;)
-if [ -z "$DISK_IMAGE" ]; then
+if [ -z "$DISK_IMAGE" ] || [ ! -f "$installdata/$DISK_IMAGE" ]; then
     pushd "$installdata"
-    shopt -s nullglob
-    array=(*)
-    shopt -u nullglob
+    for f in $(find . -type f); do
+        array+=("$f" "$f")
+    done
     popd
-    if ! DISK_IMAGE=$(dialog --no-tags \
-                      --menu "Select image to be installed" 10 60 3 \
-                      "${array[@]}" --output-fd 1)
-        exit 0
+    if [ ${#array[@]} -gt 0 ]; then
+        if ! DISK_IMAGE=$(dialog --no-tags \
+                          --menu "Select image to be installed" 10 60 3 \
+                          "${array[@]}" --output-fd 1); then
+            exit 0
+        fi
     fi
 fi
 if [ ! -f "$installdata/$DISK_IMAGE" ]; then