public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "alexander.heinisch via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com
Cc: jan.kiszka@siemens.com, quirin.gylstorff@siemens.com,
	Alexander Heinisch <alexander.heinisch@siemens.com>
Subject: [PATCH 2/2] meta-isar: Unified variable names in deploy-image script.
Date: Tue,  8 Oct 2024 12:22:35 +0200	[thread overview]
Message-ID: <20241008102235.34078-3-alexander.heinisch@siemens.com> (raw)
In-Reply-To: <20241008102235.34078-1-alexander.heinisch@siemens.com>

From: Alexander Heinisch <alexander.heinisch@siemens.com>

Unified shell variable names between deploy image config handling
and actual deploy script.

renamed AUTO_INSTALL to installer_unattended
renamed DISK_IMAGE to installer_image_uri
renamed TARGET_DEVICE to installer_target_dev
renamed OVERWRITE to installer_target_overwrite

Signed-off-by: Alexander Heinisch <alexander.heinisch@siemens.com>
---
 .../files/usr/bin/deploy-image-wic.sh         | 42 ++++++++-----------
 1 file changed, 18 insertions(+), 24 deletions(-)

diff --git a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
index 108a5975..e6ee426d 100755
--- a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
+++ b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
@@ -11,22 +11,16 @@ SCRIPT_DIR=$( dirname -- "$( readlink -f -- "$0"; )"; )
 . ${SCRIPT_DIR}/../lib/deploy-image-wic/handle-config.sh
 
 
-# Map config params
-AUTO_INSTALL=${installer_unattended}
-DISK_IMAGE=${installer_image_uri}
-TARGET_DEVICE=${installer_target_dev}
-OVERWRITE=${installer_target_overwrite}
-
-if ! $AUTO_INSTALL; then
-    DISK_IMAGE=$(find "$installdata" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;)
-    if [ -z "$DISK_IMAGE" ] || [ ! -f "$installdata/$DISK_IMAGE" ]; then
+if ! $installer_unattended; then
+    installer_image_uri=$(find "$installdata" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;)
+    if [ -z "$installer_image_uri" ] || [ ! -f "$installdata/$installer_image_uri" ]; then
         pushd "$installdata"
         for f in $(find . -type f); do
             array+=("$f" "$f")
         done
         popd
         if [ ${#array[@]} -gt 0 ]; then
-            if ! DISK_IMAGE=$(dialog --no-tags \
+            if ! installer_image_uri=$(dialog --no-tags \
                               --menu "Select image to be installed" 10 60 3 \
                               "${array[@]}" --output-fd 1); then
                 exit 0
@@ -34,11 +28,11 @@ if ! $AUTO_INSTALL; then
         fi
     fi
 
-    if [ ! -f "$installdata/$DISK_IMAGE" ]; then
+    if [ ! -f "$installdata/$installer_image_uri" ]; then
         dialog --msgbox "Could not find an image to install. Installation aborted." 6 60
         exit 1
     fi
-    DISK_BMAP=$(find "$installdata" -type f -iname "${DISK_IMAGE%.wic*}.wic.bmap")
+    DISK_BMAP=$(find "$installdata" -type f -iname "${installer_image_uri%.wic*}.wic.bmap")
 
     # inspired by poky/meta/recipes-core/initrdscripts/files/install-efi.sh
     target_device_list=""
@@ -108,37 +102,37 @@ if ! $AUTO_INSTALL; then
             fi
             array+=("/dev/$target" "/dev/$target ($target_size, $state)")
         done
-        if ! TARGET_DEVICE=$(dialog --no-tags \
+        if ! installer_target_dev=$(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 " ")
+        installer_target_dev=/dev/$(echo "$target_device_list" | tr -d " ")
     fi
-    TARGET_DEVICE_SIZE=$(lsblk --nodeps --noheadings -o SIZE "$TARGET_DEVICE" | tr -d " ")
+    TARGET_DEVICE_SIZE=$(lsblk --nodeps --noheadings -o SIZE "$installer_target_dev" | tr -d " ")
     if ! dialog --yes-label Ok --no-label Cancel \
-                --yesno "Start installing\n'$DISK_IMAGE'\nto $TARGET_DEVICE (capacity: $TARGET_DEVICE_SIZE)" 7 60; then
+                --yesno "Start installing\n'$installer_image_uri'\nto $installer_target_dev (capacity: $TARGET_DEVICE_SIZE)" 7 60; then
         exit 0
     fi
 
     # set absolute paths to be compatible with unattended mode
-    DISK_IMAGE="$installdata/$DISK_IMAGE"
+    installer_image_uri="$installdata/$installer_image_uri"
 
     if [ -z "$DISK_BMAP" ]; then
         DISK_BMAP="$installdata/$DISK_BMAP"
     fi
 fi
 
-if ! cmp /dev/zero "$TARGET_DEVICE" -n 1M; then
-    if ! $AUTO_INSTALL && \
+if ! cmp /dev/zero "$installer_target_dev" -n 1M; then
+    if ! $installer_unattended && \
        ! dialog --defaultno \
                 --yesno "WARNING: Target device is not empty! Continue anyway?" 5 60; then
         exit 0
     else
-        if [ "$OVERWRITE" != "OVERWRITE" ]; then
+        if [ "$installer_target_overwrite" != "installer_target_overwrite" ]; then
             echo "Target device is not empty! -> Abort"
-            echo "If you want to override existing data set \"installer_target_overwrite=OVERWRITE\""
+            echo "If you want to override existing data set \"installer_target_overwrite=installer_target_overwrite\""
         fi
     fi
 fi
@@ -148,15 +142,15 @@ if [ -z "$DISK_BMAP" ]; then
     bmap_options="--nobmap"
 fi
 
-if ! $AUTO_INSTALL; then
+if ! $installer_unattended; then
     clear
 fi
 
-if ! bmaptool copy ${bmap_options} "$DISK_IMAGE" "${TARGET_DEVICE}"; then
+if ! bmaptool copy ${bmap_options} "$installer_image_uri" "${installer_target_dev}"; then
     exit 1
 fi
 
-if ! $AUTO_INSTALL; then
+if ! $installer_unattended; then
     dialog --title "Reboot" \
            --msgbox "Installation was successful. System will be rebooted. Please remove the USB stick." 6 60
 else
-- 
2.43.0

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/isar-users/20241008102235.34078-3-alexander.heinisch%40siemens.com.

  parent reply	other threads:[~2024-10-08 10:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08 10:22 [PATCH 0/2] Added unattended mode for deploy-image-wic installer script alexander.heinisch via isar-users
2024-10-08 10:22 ` [PATCH 1/2] meta-isar: " alexander.heinisch via isar-users
2024-10-08 10:22 ` alexander.heinisch via isar-users [this message]
2024-10-14 17:28 ` [PATCH 0/2] " Uladzimir Bely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241008102235.34078-3-alexander.heinisch@siemens.com \
    --to=isar-users@googlegroups.com \
    --cc=alexander.heinisch@siemens.com \
    --cc=jan.kiszka@siemens.com \
    --cc=quirin.gylstorff@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox