From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7387032429685374976 X-Received: by 2002:a05:600c:3542:b0:425:77ad:93cb with SMTP id 5b1f17b1804b1-4257a009c1cmr57436635e9.2.1719927516710; Tue, 02 Jul 2024 06:38:36 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:600c:1c96:b0:423:7d5:b53c with SMTP id 5b1f17b1804b1-4256bb0b1f6ls18818035e9.0.-pod-prod-06-eu; Tue, 02 Jul 2024 06:38:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFY4xg71PPUfu1B2gi8jEX7lD+owQN5zP+o6iMld3W65QrYI+30OLG1tTNvks/sFWbWkOL9 X-Received: by 2002:a05:600c:314b:b0:424:a5df:b998 with SMTP id 5b1f17b1804b1-4257a00cfd8mr56777405e9.9.1719927514457; Tue, 02 Jul 2024 06:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719927514; cv=none; d=google.com; s=arc-20160816; b=dTpzTpfFI9WC8naF62TArfHHT2MS4gh66JzV/k3A6vrw0hC/G+0YbpP6gHH9mxU/v+ i5Ff1IiT1NB+fRjuKCVjyS7Lck7W8wXzHQsgACxqkCQ0PIPhxmORFBPkx5hDqLSa3Cj1 eE9noACBBU9hbsnRJVLulfD/u1WuT0MEMBaaJ7wgaePEFhhZK0QzkJ37kqtF/TgGN9+S mulSDjIS0lkYQu0GP3vtzF9YvByDaQ5wO+G7Zm8Sp62ZcWVZVMyYmDH9BxucJo4aIoFH 38bHrsCO5LEcoquJuRjnlsnWbfSGHMHWdecQyuzJE043Bj1xyKRg7pbXw7WElGq/Cd/7 BCWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=TCuFpVh2p5rZ/gBB0e7WFXxi71qsiJbJmvANUt82SOg=; fh=TWGwN84gUgHIe5O4CbyH9KISyeWwGbvUX7cnJPxVD70=; b=sVOxYAwM+6VnhcXY6uRKamxfFBY9BcPpxMfJVhvfSyomE0hJ7a6X8mKiIAJ/jx0g6X q+uCV5ohCkHRQNTs4GscRSFbhBmI4jFllQjliAW0sTvKNtXyHZgOZIiQeJ+ROAW3whpm Tt06cMBONA8X5bwVIiwnw46wqMWt1z7qnhVsS5WHC7WR0RF8se1n8FsqeMxeBmNUCG8S gq0adZpC0PYFjdFaK9HPBaKFMFh0XFSJ1WC2Phzx/nH+Pl3ZcA3eBPDnQdRw50ioPlrk YMTS8rlMMwy3i7oST1aQKgTWs5YzKcCqOM9QyQlm7LRY8x5dd/Sk5Tx4gQdy9NWxttMc kdnQ==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=IS6pRBU0; spf=pass (google.com: domain of fm-294854-20240702133834f97ecd606dac0079ce-63e9a8@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-294854-20240702133834f97ecd606dac0079ce-63E9a8@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Return-Path: Received: from mta-65-226.siemens.flowmailer.net (mta-65-226.siemens.flowmailer.net. [185.136.65.226]) by gmr-mx.google.com with ESMTPS id 5b1f17b1804b1-42577a0deb0si4303495e9.0.2024.07.02.06.38.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jul 2024 06:38:34 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-294854-20240702133834f97ecd606dac0079ce-63e9a8@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) client-ip=185.136.65.226; Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=IS6pRBU0; spf=pass (google.com: domain of fm-294854-20240702133834f97ecd606dac0079ce-63e9a8@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-294854-20240702133834f97ecd606dac0079ce-63E9a8@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: by mta-65-226.siemens.flowmailer.net with ESMTPSA id 20240702133834f97ecd606dac0079ce for ; Tue, 02 Jul 2024 15:38:34 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm2; d=siemens.com; i=jan.kiszka@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=TCuFpVh2p5rZ/gBB0e7WFXxi71qsiJbJmvANUt82SOg=; b=IS6pRBU0QKn433L0qFz23Y/ky5TayIq5uGlWp8XkaPHUYJrZ9luAxssSpK9mourObg1Y7Y 6pUtwhDXW0lBSn6zn7PVPlpC7twnlOkva7z0Fk5ss34nKTvuThwbTOigr/L9i4eSKSntNaXj 8k9baPKkuKor1J19Ad2CcZo6VM7CU=; From: Jan Kiszka To: isar-users Cc: Quirin Gylstorff Subject: [PATCH 15/17] meta-isar: deploy-image: Prepare for auto-installation mode Date: Tue, 2 Jul 2024 15:38:29 +0200 Message-ID: <9545129ff28fb28b7142a31090f023c4420a5f4a.1719927511.git.jan.kiszka@siemens.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-294854:519-21489:flowmailer X-TUID: IM9TXYoCMp0/ From: Jan Kiszka Wrap the code blocks that will be skipped in auto-installation mode separately to ease review. As the controlling variable remains false for now, there are effectively no functional changes. Signed-off-by: Jan Kiszka --- .../deploy-image/files/deploy-image-wic.sh | 163 +++++++++--------- 1 file changed, 86 insertions(+), 77 deletions(-) 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 77eebe18..9df93fe7 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 @@ -6,21 +6,26 @@ installdata=${INSTALL_DATA:-/install} -DISK_IMAGE=$(find "$installdata" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;) -if [ -z "$DISK_IMAGE" ] || [ ! -f "$installdata/$DISK_IMAGE" ]; 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 \ - --menu "Select image to be installed" 10 60 3 \ - "${array[@]}" --output-fd 1); then - exit 0 +AUTO_INSTALL=false + +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 + 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 \ + --menu "Select image to be installed" 10 60 3 \ + "${array[@]}" --output-fd 1); then + exit 0 + fi fi fi fi + if [ ! -f "$installdata/$DISK_IMAGE" ]; then dialog --msgbox "Could not find an image to install. Installation aborted." 6 60 exit 1 @@ -28,79 +33,81 @@ fi DISK_BMAP=$(find "$installdata" -type f -iname "${DISK_IMAGE%.wic*}.wic.bmap") # inspired by poky/meta/recipes-core/initrdscripts/files/install-efi.sh -target_device_list="" -current_root_dev=$(readlink -f "$(findmnt / -o source -n)") -current_root_dev=${current_root_dev#\/dev/} -case $current_root_dev in - mmcblk*) - ;; - nvme*) - ;; - *) - current_root_dev=${current_root_dev%%[0-9]*} - ;; -esac - -echo "Searching for target device..." - -devices=$(find /sys/block/ -type b,c,f,l -not -iname "mmcblk*" -printf "%f\n") || true -mmc_devices=$(find /sys/block/ -type b,c,f,l -iname "mmcblk[0-9]" -printf "%f\n") || true -devices="$devices $mmc_devices" - -for device in $devices; do - case $device in - loop*) - # skip loop device - ;; - mtd*) +if ! $AUTO_INSTALL; then + target_device_list="" + current_root_dev=$(readlink -f "$(findmnt / -o source -n)") + current_root_dev=${current_root_dev#\/dev/} + case $current_root_dev in + mmcblk*) ;; - sr*) - # skip CDROM device - ;; - ram*) - # skip ram device + nvme*) ;; *) - case $device in - $current_root_dev*) - # skip the device we are running from - ;; - *) - target_device_list="$target_device_list $device" - ;; - esac + current_root_dev=${current_root_dev%%[0-9]*} ;; esac -done -if [ -z "${target_device_list}" ]; then - dialog --msgbox "You need another device (besides the live device /dev/${current_root_dev}) to install the image. Installation aborted." 7 60 - exit 1 -fi + echo "Searching for target device..." -if [ "$(echo "$target_device_list" | wc -w)" -gt 1 ]; then - array=() - for target in $(echo "$target_device_list" | xargs -n1 | sort); do - target_size=$(lsblk --nodeps --noheadings -o SIZE /dev/"$target" | tr -d " ") - if cmp /dev/zero /dev/"$target" -n 1M; then - state="empty" - else - state="contains data" - fi - array+=("/dev/$target" "/dev/$target ($target_size, $state)") + devices=$(find /sys/block/ -type b,c,f,l -not -iname "mmcblk*" -printf "%f\n") || true + mmc_devices=$(find /sys/block/ -type b,c,f,l -iname "mmcblk[0-9]" -printf "%f\n") || true + devices="$devices $mmc_devices" + + for device in $devices; do + case $device in + loop*) + # skip loop device + ;; + mtd*) + ;; + sr*) + # skip CDROM device + ;; + ram*) + # skip ram device + ;; + *) + case $device in + $current_root_dev*) + # skip the device we are running from + ;; + *) + target_device_list="$target_device_list $device" + ;; + esac + ;; + esac done - if ! TARGET_DEVICE=$(dialog --no-tags \ - --menu "Select device to install image to" 10 60 3 \ - "${array[@]}" --output-fd 1); then + + if [ -z "${target_device_list}" ]; then + dialog --msgbox "You need another device (besides the live device /dev/${current_root_dev}) to install the image. Installation aborted." 7 60 + exit 1 + fi + + if [ "$(echo "$target_device_list" | wc -w)" -gt 1 ]; then + array=() + for target in $(echo "$target_device_list" | xargs -n1 | sort); do + target_size=$(lsblk --nodeps --noheadings -o SIZE /dev/"$target" | tr -d " ") + if cmp /dev/zero /dev/"$target" -n 1M; then + state="empty" + else + state="contains data" + fi + array+=("/dev/$target" "/dev/$target ($target_size, $state)") + done + 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" | 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 exit 0 fi -else - TARGET_DEVICE=/dev/$(echo "$target_device_list" | tr -d " ") -fi -TARGET_DEVICE_SIZE=$(lsblk --nodeps --noheadings -o SIZE "$TARGET_DEVICE" | 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 - exit 0 fi if ! cmp /dev/zero "$TARGET_DEVICE" -n 1M && \ @@ -118,6 +125,8 @@ if ! bmaptool copy ${bmap_options} "$installdata/$DISK_IMAGE" "${TARGET_DEVICE}" exit 1 fi -dialog --title "Reboot" \ - --msgbox "Installation is successful. System will be rebooted. Please remove the USB stick." 6 60 +if ! $AUTO_INSTALL; then + dialog --title "Reboot" \ + --msgbox "Installation is successful. System will be rebooted. Please remove the USB stick." 6 60 +fi exit 0 -- 2.43.0