From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Thu, 04 Jun 2026 14:57:02 +0200 X-Sieve: CMU Sieve 2.4 Received: from mail-wr1-f60.google.com (mail-wr1-f60.google.com [209.85.221.60]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 654Cv1eF010064 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 4 Jun 2026 14:57:01 +0200 Received: by mail-wr1-f60.google.com with SMTP id ffacd0b85a97d-460153ce644sf471406f8f.0 for ; Thu, 04 Jun 2026 05:57:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1780577816; cv=pass; d=google.com; s=arc-20240605; b=b0qVrCyBR7jDMIkZRqxCOGZz1cIhkppzl6ar6+CxjtOCDcaxUMjL2bt0CudWMsUN08 Ugtm3Rr3jV/N3QIu/T0R2VeSwG2v7b/mVepRRCZC4zSrLr568/WjZ9BdpSRxX/hshUCq rVSjaUY5Z7VKaT7qumRX8Y9OJgWbedxQEyj40gDekWvxXzIxGIybmScnutpNau5SKteF OTpUletDeIuE2m0AxMzHZe1UNqqDWUzNnRU8T7wQOv0lAqZZhe149iVnwyUKe01Y4n6b txA9m0bvVjn2ZVcFh1J9tYVEer/LawhmThwLkmkR5bEBCnggtb1vHYkPcfiby4YFuUV1 ZUew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :sender:dkim-signature; bh=bk+djqi5XCJelkck3vLYB/Qlr1wUeIJ7cE5LxrqMsxY=; fh=P6Lo0YotKB3pCxDRTOvUoFrcB9m31j9K0OyTKIobI3c=; b=lDAmv05KAxE9jx4Aw/UD6LcII5MTaZS/L5oQ6I8FW5u1buSMDwIYrxw7plDeI94h7k 4YQhoAODCYvcwIN4BwW5EhBNV9KA5Qd69KkWwnD4nB7Czoo/sU0izQaZRblBCRoeYyBj /FGvLrD47YCTsJl+HV1lvplJoKCKXwTkVwrprE/9djWoPIcL32LiAPgCEcyc1EERgno3 +39WcqR8uVYB8ba6hEGY4VLXD6K1zdvodJjOi7RUUwx3rlrBnw5czVte/6zpkPJcKUCw 95xzGueUfmLYYdLSrRQMi/gKJYNN8M+IrWbHmUTJ7KupYw7fpUl8OBtj/8eXN58CnIDd GvpA==; darn=ilbers.de ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=amikan@ilbers.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20251104; t=1780577816; x=1781182616; darn=ilbers.de; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:in-reply-to:from:content-language:references:to :subject:user-agent:mime-version:date:message-id:sender:from:to:cc :subject:date:message-id:reply-to; bh=bk+djqi5XCJelkck3vLYB/Qlr1wUeIJ7cE5LxrqMsxY=; b=Gcif94LY/js9gmifdrjo6bRaigPU58HZar/UuXCtTPSCjGAjJCbYKB5Y/IQbL5xCZ9 K1ca8nAfKrKheoMD71DcVgfugyiu3apuEO+qEKNCUQvLrP03aYzKuW5ZL7LZa3uSrIb3 0jGc1F730ulOSIH8jtmy3j/ax0n8BTfKeipIvPcbJhoeC6IfNpZQX4ZuTU0w8+iJTFQP dlXz7cDcH0W03EshcIRKYbGi5UAOaB4pezXruEuNklQzuoMvQLclHqqC0mzuPpPOtF4H PvHFP8za9BkdceRp5EkaRqCdI2dZQXziwk8XBff7tC+MmpdtkgRetvuk/C29eFQLhkS0 +4LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780577816; x=1781182616; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:in-reply-to :from:content-language:references:to:subject:user-agent:mime-version :date:message-id:x-beenthere:x-gm-message-state:sender:from:to:cc :subject:date:message-id:reply-to; bh=bk+djqi5XCJelkck3vLYB/Qlr1wUeIJ7cE5LxrqMsxY=; b=rCiyPLUCXTFs635ZcABy87NBRRSaiqdb5Vf4RnsTHoefkMk0GHxCQ2abuO2hPP8dB7 T1CicZeKANIatamYLQBIqwQGxPsPxWtz/m1Ns2Lxac8Sagl6tm3D8A0eGozTHNN38iXT bdbHp3fhwGsF8vdB6h5JeO/o9cZU/SRsA36A4/zMrHh4U9mc2dSbemBArNogMiHFnFiN 9szIP0c0wh56xylqYYg9d36Tx6cyYwUgZHkUtuqLrlwuBaNhvqQzw8YPUPUuFTJXysDR Wcv0T0en9yMJPAboCT1BwwRJoOOrE/4Bsa14XBBqRb6D10qDrZexMfjVBs2aScbguA2K XggQ== Sender: isar-users@googlegroups.com X-Forwarded-Encrypted: i=2; AFNElJ9IQZ1+y4KTWSZvujfbyMnpQZqs/1uGIujeJDNHlVYOCQIXZf8lfIDIakTtmZ01xqv66BJX@ilbers.de X-Gm-Message-State: AOJu0YygfyIG2QIFf/QyWbsY+7Zuuvd1I8bwue8Ra5OzXHa7MiKyWSYu DYmmxV9eGGEyP/T3VMsyJWUaq4cfvqjfei6QDO8gjs3gv1bVfsAihkSB X-Received: by 2002:adf:f8c4:0:b0:460:18e9:c0da with SMTP id ffacd0b85a97d-4602179133emr8957927f8f.10.1780577816303; Thu, 04 Jun 2026 05:56:56 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com; h="AUV6zMPavEszY9s2BlnYOlwSDUreiz+0GuBWQkCqy7gsVjvVyA==" Received: by 2002:a05:6000:2403:b0:45e:f6e8:d866 with SMTP id ffacd0b85a97d-46026de7922ls764836f8f.0.-pod-prod-03-eu; Thu, 04 Jun 2026 05:56:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AFNElJ/IMvu9tZN5xlCOsmNzIzEieszLME4+kIqyYE5Tog34P1qUev6fbbTe+/TXU5fWyooCM+LsUgqK21HD@googlegroups.com X-Received: by 2002:a05:600c:1993:b0:490:bb19:b110 with SMTP id 5b1f17b1804b1-490bb19b19amr79318645e9.27.1780577814044; Thu, 04 Jun 2026 05:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780577814; cv=none; d=google.com; s=arc-20240605; b=jqX98N18GqaLah9Ae94aHi2U179ngaDR/xApyUfPJbl01sg6NfJds8AeGXpTWg8hZt QC73w6smWBWd8MmqaFBtjM/muoOWtU1BZm/HiBHOB7ZbtUVyOijPyb3DoDOqi78eNfdf Xub812m9lYmSl5zPBn9cT2AXRFz8s3+NHRX4r94JqkAsrGcaK+kT/hW9Vkr+/l01b8c0 /8wg+sp3taScO/L5fiZ6OnBvwmvbb3PdtNLAZjvEMG5jxgWnyZzFVtoAyLWg/Oci3vcJ kSeBqNA0uO8Gg1s+0CM6cLhWZ9Khg84ZNZk+ffPXDcUu+3CrNu/ZjBqVgxe8sSqknBrN zYhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id; bh=bav3ZYtrkRh5VRyyEqNny97dK/HGa4g0kY5DB8UOZ38=; fh=9mcVTMEQBDtzoms+Xy2T7KzxKBDm07At1XVf7j8G8z8=; b=fFzI5fIeNpEIuzQm8xrmBIqdsR8ZIlVDAqRYOOXQGEKirBdMmqxDfbReZvq2S3NAsi d8yiKByPnJ/wPjY6O/Zsdy6SYBu/pqOf5+r6O4+HDjHaRzQpJzSkjfh++hM+iKby3vmv RT49wlP26mKK0gfPWCtJxB4AsefBLNn68U1H795C1qLo/WHej86x/WeuNYp1lf7kmXCo hxJxv1DB9UB08aDZoLjnOcAwJeGOl/IuW8Z4Tm6WQ9W+dQDUPqdV9c0W1Ap1iwXCPqoJ SLEhFlGTwCTk6fG2iL5qoUpjV3TT+DenaOpksDl7btTuru3UVUMw/m1Nj/xO9JSvEJA3 Lanw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=amikan@ilbers.de Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id ffacd0b85a97d-4601f0a00b4si123968f8f.0.2026.06.04.05.56.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jun 2026 05:56:53 -0700 (PDT) Received-SPF: pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Received: from [127.0.0.1] (host-80-81-17-52.static.customer.m-online.net [80.81.17.52]) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPSA id 654CupU6010057 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 4 Jun 2026 14:56:52 +0200 Message-ID: <8b658081-ce7b-4ffc-b108-1691f5a8ceaf@ilbers.de> Date: Thu, 4 Jun 2026 15:56:51 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/4] installer: add installer flow module and entrypoint To: Kasturi shekar , isar-users@googlegroups.com References: <20260427063957.603123-4-kasturi.shekar@siemens.com> <20260514091951.1572682-1-kasturi.shekar@siemens.com> <20260514091951.1572682-4-kasturi.shekar@siemens.com> Content-Language: en-US, ru-RU From: Anton Mikanovich In-Reply-To: <20260514091951.1572682-4-kasturi.shekar@siemens.com> Content-Type: text/plain; charset="UTF-8"; format=flowed X-Spam-Status: No, score=-4.6 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, RCVD_IN_RP_CERTIFIED,RCVD_IN_RP_RNBL,RCVD_IN_RP_SAFE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-Original-Sender: amikan@ilbers.de X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=amikan@ilbers.de Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-TUID: gtw1477WaL8V Hello Kasturi, 14.05.2026 12:19, 'Kasturi shekar' via isar-users wrote: > From: Kasturi Shekar > > high-level orchestration and keep deploy-image-wic.sh as a thin launcher. > > This keeps the externally used script name stable while making the flow easier > to review and maintain by separating: > - backend APIs > - UI frontend > - mode/orchestration flow > > Signed-off-by: Kasturi Shekar > --- > .../files/usr/bin/deploy-image-wic.sh | 475 +++++++----------- > 1 file changed, 192 insertions(+), 283 deletions(-) > mode change 100755 => 100644 meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh > > 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 > old mode 100755 > new mode 100644 > index 9a4102b2..a692b679 > --- 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 > @@ -1,6 +1,6 @@ > #!/usr/bin/env bash > # This software is a part of Isar. > -# Copyright (C) Siemens AG, 2024 > +# Copyright (C) Siemens AG, 2026 > # > # SPDX-License-Identifier: MIT > > @@ -9,293 +9,202 @@ installdata=${INSTALL_DATA:-/install} > SCRIPT_DIR=$( dirname -- "$( readlink -f -- "$0"; )"; ) > > . "${SCRIPT_DIR}/../lib/deploy-image-wic/handle-config.sh" > +. "${SCRIPT_DIR}/sys_api.sh" > +. "${SCRIPT_DIR}/installer_ui.sh" > > -if [ "$installer_unattended" = true ] && [ "$installer_unattended_abort_enable" = true ]; then > - abort_file=/run/attended_mode_trigger > - for ((i=$installer_unattended_abort_timeout; i>0; i--)); do > - echo -ne "\rUnattended installation will start in $i seconds. Press any key to switch to attended mode..." > +#-------------------------------------------------------------------------- > +# This module contains high-level installer flow logic > +# while keeping low-level backend APIs in sys_api.sh > +# and user-facing dialogs in installer_ui.sh. > +#-------------------------------------------------------------------------- > > - # Switch to attended mode if the abort file exists or any key pressed during countdown > - # Create abort file to notify all other console instances to abort > - if [ -f "$abort_file" ] || read -n 1 -t 1; then > - installer_unattended=false > - touch "$abort_file" > - break > - fi > - done > -fi > - > -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 ! -iname "*.wic.bmap"); do > - array+=("$f" "$f") > - done > - popd > - if [ ${#array[@]} -gt 0 ]; then > - if ! installer_image_uri=$(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/$installer_image_uri" ]; then > - dialog --msgbox "Could not find an image to install. Installation aborted." 6 60 > - exit 1 > - fi > - > - # inspired by poky/meta/recipes-core/initrdscripts/files/install-efi.sh > - target_device_list="" > - current_root_dev_type=$(findmnt / -o fstype -n) > - exclude_list=() > - > - if [ "$current_root_dev_type" = "nfs" ]; then > - current_root_dev="nfs" > - exclude_list+=("nfs") > - else > - # For normal or immutable systems, get the backing device of '/' > - root_source=$(findmnt / -o source -n) > - root_source_resolved=$(readlink -f "$root_source" 2>/dev/null || echo "$root_source") > - current_root_dev=${root_source_resolved#/dev/} > - > - # Always exclude the exact device mounted as / > - exclude_list+=("$current_root_dev") > - > - if [[ "$current_root_dev" =~ ^(mmcblk|nvme) ]]; then > - base_no_part="${current_root_dev%p[0-9]*}" > - else > - base_no_part="${current_root_dev%%[0-9]*}" > - fi > - if [ -n "$base_no_part" ]; then > - exclude_list+=("$base_no_part") > - fi > - > - # If root is coming through a dm-* device (e.g., dm-verity), > - # the actual physical devices appear under /sys/block//slaves/. > - # We must exclude those slaves as well, otherwise the installer > - # might show the live USB stick as a valid target. > - if [ -d "/sys/block/$current_root_dev/slaves" ]; then > - for slave in /sys/block/"$current_root_dev"/slaves/*; do > - [ -e "$slave" ] || continue > - slave_dev=$(basename "$slave") > - exclude_list+=("$slave_dev") > - slave_base=${slave_dev%%[0-9]*} > - [ -n "$slave_base" ] && exclude_list+=("$slave_base") > - done > - fi > - fi > - > - 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 > - is_raid_member=0 > - > - if [ -d "/sys/block/$device/holders" ] && [ ! -d "/sys/block/$device/md" ]; then > - for holder_path in /sys/block/$device/holders/*; do > - holder_name=$(basename "$holder_path") > - case "$holder_name" in > - md[0-9]*) > - is_raid_member=1 > - break > - ;; > - esac > - done > - fi > - > - if [ "$is_raid_member" -eq 1 ]; then > - continue # Skip RAID member disks > - fi > - > - if [[ "$device" == md* ]]; then > - if [ -f "/sys/block/$device/md/array_state" ]; then > - state=$(cat /sys/block/$device/md/array_state) > - if [ "$state" != "active" ] && [ "$state" != "clean" ]; then > - continue > - fi > - else > - continue > - fi > - fi > - > - case $device in > - dm-*) > - # skip device-mapper device > - ;; > - loop*) > - # skip loop device > - ;; > - mtd*) > - ;; > - sr*) > - # skip CDROM device > - ;; > - ram*) > - # skip ram device > - ;; > - zram*) > - # skip zram device > - ;; > - *) > - #skip any excluded devices (root and its slaves) > - skip_device=0 > - for ex in "${exclude_list[@]}"; do > - if [[ "$device" == "$ex"* ]]; then > - skip_device=1 > - break > - fi > - done > - > - if [ "$skip_device" -eq 0 ]; then > - target_device_list="$target_device_list $device" > - fi > - ;; > - 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 > - > - 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 ! 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 > - installer_target_dev="/dev/$(echo "$target_device_list" | tr -d " ")" > - fi > - 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'$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 > - installer_image_uri="$installdata/$installer_image_uri" > -fi > - > -if ! cmp /dev/zero "$installer_target_dev" -n 1M; then > - if ! $installer_unattended; then > - if ! dialog --defaultno \ > - --yesno "WARNING: Target device is not empty! Continue anyway?" 5 60; then > - exit 0 > - fi > - else > - if [ "$installer_target_overwrite" != "OVERWRITE" ]; then > - echo "Target device is not empty! -> Abort" > - echo "If you want to override existing data set \"installer.target.overwrite=OVERWRITE\" on your kernel cmdline or edit your \"auto.install\" file accordingly." > - > - exit 1 > - fi > - fi > -fi > - > -bmap_options="" > - > -# bmap file is expected to be next to the installer image > -DISK_BMAP="${installer_image_uri%.wic*}.wic.bmap" > - > -if [ ! -f "$DISK_BMAP" ]; then > - bmap_options="--nobmap" > -fi > - > -if ! $installer_unattended; then > - clear > -fi > - > -# Function to compare version numbers > -version_ge() { > - if [ "$(printf '%s\n' "$1"X "$2" | sort -V | head -n 1)" != "$1"X ]; then > - return 0 > - else > - return 1 > - fi > +#-------------------------------------------------------------------------- > +# flow_run_attended > +# > +# Handles all attended-mode interactions and assigns: > +# installer_image_uri > +# installer_target_dev > +# > +# Returns: > +# 0 on success > +# 1 on hard error > +# 2 on user cancel > +#-------------------------------------------------------------------------- > +flow_run_attended() { > + local default_image > + local selected_image > + local selected_target > + local target_device_size > + > + default_image=$(sys_first_default_image_name "$installdata") > + if [ -n "$default_image" ] && [ -f "$installdata/$default_image" ]; then > + installer_image_uri="$default_image" > + fi > + > + if [ -z "$installer_image_uri" ] || [ ! -f "$installdata/$installer_image_uri" ]; then This check is never hit because installer_image_uri is always set after calling sys_first_default_image_name. It results in skipping image selection dialog and always installing the first one. > + selected_image=$(ui_select_image_menu "$installdata") > + case $? in > + 0) > + installer_image_uri="$selected_image" > + ;; > + 1) > + ui_show_error "Could not find an image to install. Installation aborted." > + return 1 > + ;; > + 2) > + return 2 > + ;; > + *) > + return 1 > + ;; > + esac > + fi > + > + if [ ! -f "$installdata/$installer_image_uri" ]; then > + ui_show_error "Could not find an image to install. Installation aborted." > + return 1 > + fi > + > + echo "Searching for target device..." > + sys_discover_target_devices > + if [ "${#SYS_TARGET_DEVICES[@]}" -eq 0 ]; then > + ui_show_error "You need another device (besides the live device /dev/${SYS_CURRENT_ROOT_DEV}) to install the image. Installation aborted." > + return 1 > + fi > + > + if [ "${#SYS_TARGET_DEVICES[@]}" -gt 1 ]; then > + selected_target=$(ui_select_target_device_menu "${SYS_TARGET_DEVICES[@]}") > + case $? in > + 0) > + installer_target_dev="$selected_target" > + ;; > + 1) > + ui_show_error "No installable target devices available. Installation aborted." > + return 1 > + ;; > + 2) > + return 2 > + ;; > + *) > + return 1 > + ;; > + esac > + else > + installer_target_dev="${SYS_TARGET_DEVICES[0]}" > + fi > + > + target_device_size=$(sys_device_size "$installer_target_dev") > + if ! ui_confirm_install "$installer_image_uri" "$installer_target_dev" "$target_device_size"; then > + return 2 > + fi > + > + installer_image_uri="$installdata/$installer_image_uri" > + return 0 > } > > -lockfile="/run/installer.lock" > -progress_pipe="/run/installer.fifo" > - > -exec 9>"$lockfile" > -if flock -n 9; then > - # Get bmap-tools version > - bmap_version=$(bmaptool --version | awk '{ print $NF }') > - > - if version_ge "$bmap_version" "3.6"; then > - if ! mkfifo "$progress_pipe"; then > - echo "Error: Failed to create named pipe $progress_pipe" > - exit 1 > - fi > - > - # Add psplash pipe to bmap_options > - bmap_options="$bmap_options --psplash-pipe=$progress_pipe" > - quiet_flag="-q" > - > - # Initialize the dialog gauge and update it dynamically > - ( > - while true; do > - if read -r line < "$progress_pipe"; then > - percentage=$(echo "$line" | awk '{ print $2 }') > - echo "$percentage" > - fi > - done > - ) | dialog --gauge "Flashing image, please wait..." 10 70 0 & > - > - gauge_pid=$! > - fi > - > - if ! bmaptool $quiet_flag copy $bmap_options "$installer_image_uri" "$installer_target_dev"; then > - kill "$gauge_pid" > - exit 1 > - fi > - > - # Attempt to terminate the gauge process if still running. > - # Errors are ignored since the process may already have exited. > - kill "$gauge_pid" 2>/dev/null > -else > - echo "Installation already running in another console." > +#-------------------------------------------------------------------------- > +# flow_validate_target_overwrite_policy > +# > +# Enforces overwrite policy for non-empty targets in both attended and > +# unattended modes. > +# > +# Returns: > +# 0 when policy permits installation > +# 1 when policy rejects installation > +# 2 when user cancels in attended mode > +#-------------------------------------------------------------------------- > +flow_validate_target_overwrite_policy() { > + if sys_device_is_empty "$installer_target_dev"; then > + return 0 > + fi > + > + if ! $installer_unattended; then > + if ! ui_confirm_overwrite; then > + return 2 > + fi > + else > + if [ "$installer_target_overwrite" != "OVERWRITE" ]; then > + echo "Target device is not empty! -> Abort" > + echo "If you want to override existing data set \"installer.target.overwrite=OVERWRITE\" on your kernel cmdline or edit your \"auto.install\" file accordingly." > + return 1 > + fi > + fi > + > + return 0 > +} > > - # Wait for running console to create the progress pipe > - sleep 5 > +#-------------------------------------------------------------------------- > +# flow_maybe_switch_to_attended > +# > +# If unattended abort-by-key is enabled, this function offers a timeout > +# window to switch to attended mode. > +#-------------------------------------------------------------------------- > +flow_maybe_switch_to_attended() { > + local abort_file > + > + if [ "$installer_unattended" = true ] && [ "$installer_unattended_abort_enable" = true ]; then > + abort_file=/run/attended_mode_trigger > + if ui_countdown_allow_attended_switch "$installer_unattended_abort_timeout" "$abort_file"; then > + installer_unattended=false > + fi > + fi > +} > > - # Check if progress pipe exists and has content > - if [ -e "$progress_pipe" ]; then > - echo "Installation progress..." > - tail -f "$progress_pipe" | while read line; do > - printf "\r%s%%" "$line" > - done > - else > - # Periodically check if bmaptool is still running every 5 seconds > - echo "Waiting for installation to finish..." > - while pgrep -x "bmaptool" > /dev/null; do > - sleep 5 > - done > - fi > -fi > +#-------------------------------------------------------------------------- > +# flow_run > +# > +# Main installer flow combining attended/unattended execution paths. > +#-------------------------------------------------------------------------- > +flow_run() { > + flow_maybe_switch_to_attended > + > + if ! $installer_unattended; then > + flow_run_attended > + case $? in > + 0) > + ;; > + 2) > + return 0 > + ;; > + *) > + return 1 > + ;; > + esac > + fi > + > + flow_validate_target_overwrite_policy > + case $? in > + 0) > + ;; > + 2) > + return 0 > + ;; > + *) > + return 1 > + ;; > + esac > + > + if ! $installer_unattended; then > + clear > + fi > + > + if ! sys_install_image_with_lock "$installer_image_uri" "$installer_target_dev"; then > + if ! $installer_unattended; then > + ui_show_error "Installation failed." > + fi > + return 1 > + fi > + > + if ! $installer_unattended; then > + ui_show_info "Installation was successful. System will be rebooted. Please remove the USB stick." > + else > + echo "Installation was successful." > + fi > + > + return 0 > +} > > -if ! $installer_unattended; then > - dialog --title "Reboot" \ > - --msgbox "Installation was successful. System will be rebooted. Please remove the USB stick." 6 60 > -else > - echo "Installation was successful." > -fi > +# Entrypoint: run the installer flow and propagate status. > +flow_run > +exit $? > > -exit 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 visit https://groups.google.com/d/msgid/isar-users/8b658081-ce7b-4ffc-b108-1691f5a8ceaf%40ilbers.de.