From patchwork Mon Apr 27 06:39:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kasturi shekar X-Patchwork-Id: 5049 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Mon, 27 Apr 2026 08:40:13 +0200 X-Sieve: CMU Sieve 2.4 Received: from mail-pj1-f61.google.com (mail-pj1-f61.google.com [209.85.216.61]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 63R6e49w000432 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 Apr 2026 08:40:05 +0200 Received: by mail-pj1-f61.google.com with SMTP id 98e67ed59e1d1-35da4795b3csf19469051a91.2 for ; Sun, 26 Apr 2026 23:40:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1777271999; cv=pass; d=google.com; s=arc-20240605; b=b4c055/SIDNi9psilbvKBjPqNhzZEeB/5M6+CJENOv86dtmwEzhfB+1NxrOl3RuN/w NUGkWlijS5rPWftapSZI+KrJXtflbReERkEktvQKeMJK4ZXtXHdKjRyGqDbolMEJTOjx 70JUI+fjYB4nzdAmnNZhWnc5X2Nr0UZHNQmbbp6ykCHiFRyuK0NiIPPlai6yVf2wr5tJ Zk/zJ9mq3aV7A4lmzCPGY/7Q43z9G41AY7SCjxU8H0BdN7NPA3MGFnHYEXXRGIRQIedK zX3QmLoBtEQFteGfz10Bs6QyCH0ukwr/eq1CsWW86a90TRdwjOKr74ILVe7KzbUWXV+h 0JoQ== 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:reply-to:feedback-id :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=+pWAEweT2nMw4WAGuckTbp8IQ4MGsAGNiLvZyLmSEE0=; fh=ND0/tKG9zw+2gB0/tEVHMycqI4NazJKP4OYWr2VWQoo=; b=TvQJG1EcXO5vYPrmPBUN29KQeGsRCv0FFaXgoS/KVVsMbAVJ3NP7y8p8IXBzHU6D8o AFelE09D/kiKg/5R9WF9Ao2YAzQ/E4hAZrT7VkGrCjGkybmRcaU6/R/L+1WI5vWTWHGO iRZwT/zesOPLM04ELzhZ/ilHw3IrfzPQtcgTZvfHY9/ziNRMZzs7EnXnzlYidl5+bwah DxU8OuqB+Agi9fIw0cc5QoKa1sKxYTJ3/b9CVAos3cL6L01waJwAB4Dbx45QkogWc7u+ FhWv3Q1ne+flnt+9FknELprcWG3pMUKOCTBveEZfAPypoPR7AbNX5jbsWIMva4l/BT+B c9Yg==; darn=isar-build.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=cv4WCk5C; spf=pass (google.com: domain of fm-1328757-20260427063956c78e33cfec000207a5-obe5_1@rts-flowmailer.siemens.com designates 185.136.64.228 as permitted sender) smtp.mailfrom=fm-1328757-20260427063956c78e33cfec000207a5-ObE5_1@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20251104; t=1777271999; x=1777876799; darn=isar-build.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+pWAEweT2nMw4WAGuckTbp8IQ4MGsAGNiLvZyLmSEE0=; b=ucDoz+Y27cOrGAz61C5tR55oY4/5sj6BIOUAXhw7rMy/qup7KwGCYwrnCL45WIoy4n LGjRFbaCBoMfcxMhkw7dzKyesWmnLJxHYByEsiToI+NynnVk6nunVz3Rkr4TKHgRDi4n 8Ct8RRn9ebqe0gKnJBJ/S1eVyHJ6o9P59HBiLr5mIl5QeVuQHtmpD4ued+yMd8IhuJE7 nJCoxFvT0YtuBYn01KnsIIXjfNc6WLaE0Z39dhqElK1nlVave1XR2mmc2azoa11HHRGX lpmpsH4aL02GM8HzMLlPKaJrr6njJy6Icg1WP0mcdBagelr9RpzhW7/7udGHPRkgXSL7 Eujg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777271999; x=1777876799; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+pWAEweT2nMw4WAGuckTbp8IQ4MGsAGNiLvZyLmSEE0=; b=YaVRoqTC0luLJP/PCKnVOvHN72X+IH/XVmfMvFk8GYcCzSak+SyAISny8ASrHvtu/X eTKCLABoQfowDsZzsLKTgUNAJc8nh3Z3NWyAelPwjFidJbKTbHiGMgASRfBi9vb0+TKd mpOvupsnHzIku8vBlgy8jgDCDJcdQlkdf25+sy3+9n5sOPDV4+zBNFsx/uir2pxeX/D2 eeggUIEDfleJ169CGLV5dXn6LlWGjl5cUpX/EAt7Dtn2yubJGyC+huzP4MramtthDQN8 VVcxdINXq1fW0jqTNo8OmPIfzK+MFSTloOsAsLFGkhlyzl68OFVCfde8raw/dPzZSkWs kqZw== X-Forwarded-Encrypted: i=2; AFNElJ96F0cLeW64yjLKHQ0TGSrPQZB7ayE32v3lzW+Lp/zbua4TE2m1xoIF9yZ+lvYMWSr42wZx9WI=@isar-build.org X-Gm-Message-State: AOJu0Yw9nhaspznLE5H6lrx3Vfq16t9PHew9V38YhOCQaTV/M6mG6MNF J3Pvw7+kz9zEOoulqCq92FUh9Rj6MgZeBvO+aaSZPq1BrY8lkPi3V83s X-Received: by 2002:a17:90b:2686:b0:356:2c7b:c026 with SMTP id 98e67ed59e1d1-36140499690mr42166402a91.23.1777271998930; Sun, 26 Apr 2026 23:39:58 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com; h="AUV6zMMV5DK+Ih5jC99jjDR/iAol8xyEEAiDwQsTcVKyGVenbQ==" Received: by 2002:a17:90b:808:b0:35f:b556:578a with SMTP id 98e67ed59e1d1-3612fe99103ls9636873a91.2.-pod-prod-03-us; Sun, 26 Apr 2026 23:39:57 -0700 (PDT) X-Received: by 2002:a17:90b:5185:b0:35f:b7f5:9b3 with SMTP id 98e67ed59e1d1-361403b18c9mr44568572a91.3.1777271997478; Sun, 26 Apr 2026 23:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777271997; cv=none; d=google.com; s=arc-20240605; b=Xk7u/JRHxfn7TyOLNPcflS25K8VZ9SvS+s4ql0/rSh+O7w4WGpKYqz1xFOYOgVWjO8 8P8wqvf6y7xVygv+uOQOrWjUthsHagESQwcQOIo4OXIpmkYX0XiH1ixB4iNk1+pgX1VY N7Nkv+afS84BeOY1EmBvBXiZAVRfW/6ZVNAlpZUZ6Vzhj6BPb9J8J40/O37Ugdy8qtGA KsFV6rsGleUePkv5VvQ+VbJjzkI9z9IjKdBNvi57WdIdC+nHDRdwccYASGxhzwn1Dz34 oiIZvrQroW5F0IgKHWWSOmF95fg+BGt+VE82Aq6EpAfuHpdYn20fyTTI+MxuF1lsrLay t6LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=feedback-id:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=yVTshxRX4pn1ALbNKO5dfGlTxrgYLO6qs1Kg+k4dJdw=; fh=kh6mBxUBxYhzFhhtG3ckYICU9JWCX223LZXZsw4oG5w=; b=ZJUOTWuLtlx8Hij8TBQXKKQvIX2GlYpQavw+IVvOsa1JaaWYhfMVa30yUOsdY+wHB8 dOV0tNKXmWSsQ7qhm+krC8bVk6WopSDnp8CPH3iD5Kfd6ybyGLH1kpMUNk4C48B/FuCg YBXrNgmCi6WbVpAPaLLztMayfPOh5qCgiyWZlM3O2VIASniUVq0gcPvdnA+JYQgjYef9 HbzY4ttCL3U7+RRDNBZXgM8cLy/oA9SSZZrBz8FDctylUs8i49fAQJy5Nfi5Uvlght+x XEGfkIkxXqptT+946xMKJwiyhVLfoLBkopnYuA05ZYc+0c0i5Dljv4svvbv/QhRF/Qkk e6jg==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=cv4WCk5C; spf=pass (google.com: domain of fm-1328757-20260427063956c78e33cfec000207a5-obe5_1@rts-flowmailer.siemens.com designates 185.136.64.228 as permitted sender) smtp.mailfrom=fm-1328757-20260427063956c78e33cfec000207a5-ObE5_1@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from mta-64-228.siemens.flowmailer.net (mta-64-228.siemens.flowmailer.net. [185.136.64.228]) by gmr-mx.google.com with ESMTPS id 98e67ed59e1d1-36141787cefsi1027153a91.0.2026.04.26.23.39.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Apr 2026 23:39:57 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-1328757-20260427063956c78e33cfec000207a5-obe5_1@rts-flowmailer.siemens.com designates 185.136.64.228 as permitted sender) client-ip=185.136.64.228; Received: by mta-64-228.siemens.flowmailer.net with ESMTPSA id 20260427063956c78e33cfec000207a5 for ; Mon, 27 Apr 2026 08:39:56 +0200 X-Patchwork-Original-From: "'Kasturi shekar' via isar-users" From: Kasturi shekar To: isar-users@googlegroups.com Cc: "kasturi.shekar" Subject: [PATCH 1/4] installer: extract backend helpers to sys_api.sh Date: Mon, 27 Apr 2026 12:09:53 +0530 Message-ID: <20260427063957.603123-2-kasturi.shekar@siemens.com> In-Reply-To: <20260427063957.603123-1-kasturi.shekar@siemens.com> References: <20260427063957.603123-1-kasturi.shekar@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1328757:519-21489:flowmailer X-Original-Sender: kasturi.shekar@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=cv4WCk5C; spf=pass (google.com: domain of fm-1328757-20260427063956c78e33cfec000207a5-obe5_1@rts-flowmailer.siemens.com designates 185.136.64.228 as permitted sender) smtp.mailfrom=fm-1328757-20260427063956c78e33cfec000207a5-ObE5_1@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: Kasturi shekar Reply-To: Kasturi shekar 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-Spam-Status: No, score=-4.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: "kasturi.shekar" Move backend and system-facing installer logic into sys_api.sh This patch introduces backend helper APIs for: - install image discovery - target device discovery and filtering - root/live-device exclusion - RAID member and inactive md filtering - block device state and size helpers - bmap copy execution with locking and progress pipe support Signed-off-by: kasturi.shekar --- .../deploy-image/files/usr/bin/sys_api.sh | 400 +++++++++++++++--- 1 file changed, 333 insertions(+), 67 deletions(-) diff --git a/meta-isar/recipes-installer/deploy-image/files/usr/bin/sys_api.sh b/meta-isar/recipes-installer/deploy-image/files/usr/bin/sys_api.sh index b144419e..9c9c5840 100644 --- a/meta-isar/recipes-installer/deploy-image/files/usr/bin/sys_api.sh +++ b/meta-isar/recipes-installer/deploy-image/files/usr/bin/sys_api.sh @@ -1,84 +1,350 @@ #!/usr/bin/env bash +# This software is a part of ISAR. +# Copyright (C) Siemens AG, 2026 # -# sys_api.sh — Ported installer system APIs -# ------------------------------------------------------------------- +# SPDX-License-Identifier: MIT -# Load shared framework utilities -source ./func.sh || { - echo "Error: func.sh not found or not readable." >&2 - exit 1 +#-------------------------------------------------------------------------- +# sys_api.sh - Backend APIs for deploy-image-wic installer. +# +# This file intentionally contains only system/backend logic: +# - image discovery +# - target device discovery and filtering +# - low-level install/copy flow +# +# UI concerns (dialog boxes, menus, confirmations) are implemented in +# installer_ui.sh and called by the main orchestrator script. +#-------------------------------------------------------------------------- + +# Globals populated by sys_discover_target_devices(). +SYS_CURRENT_ROOT_DEV="" +SYS_TARGET_DEVICES=() + +#-------------------------------------------------------------------------- +# sys_first_default_image_name +# +# Returns: +# basename of matching *.wic* image (excluding *.wic.bmap), or empty. +#-------------------------------------------------------------------------- +sys_first_default_image_name() { + local install_data_dir="$1" + + find "$install_data_dir" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" \ + -exec basename {} \; | head -n 1 +} + +#-------------------------------------------------------------------------- +# sys_list_installable_entries +# +# Returns: +# relative file paths under install_data_dir, one per line. +# Files ending in *.wic.bmap are excluded. +#-------------------------------------------------------------------------- +sys_list_installable_entries() { + local install_data_dir="$1" + + ( + cd "$install_data_dir" || return 1 + find . -type f ! -iname "*.wic.bmap" -print | sed 's#^./##' + ) } -# ------------------------------------------------------------------- -# API: locate_disk_images -# Description: -# Find disk image files (.wic, .wic.bz2) under given path. -# Usage: -# sys_locate_disk_images search_path=/install -# Returns JSON: -# {"error":"", "retval":"0", "images":["/install/image.wic", ...]} -# ------------------------------------------------------------------- -sys_locate_disk_images() { - local -A ARGS - local required=(search_path) - api_args ARGS required[@] "$@" || { - pack_return_data error "$_args_error" retval "1" - return 1 - } - - local fn="${FUNCNAME[0]}" - local path="${ARGS[search_path]}" - - log_info "$fn" "Searching for disk images in '$path'" - - local images - images=$(find "$path" -type f -iname "*.wic*" ! -iname "*.wic.bmap" 2>/dev/null) - - # when no images found in /install - if [[ -z "$images" ]]; then - log_warn "$fn" "No images found." - pack_return_data error "No images found" retval "1" - return 1 +#-------------------------------------------------------------------------- +# sys_resolve_image_path +# +# Arguments: +# install_data_dir - base directory where installable images are stored +# image_or_path - either a relative image filename under install_data_dir +# or an explicit absolute/relative filesystem path +# +# Returns: +# absolute image path if resolvable, else non-zero return code. +#-------------------------------------------------------------------------- +sys_resolve_image_path() { + local install_data_dir="$1" + local image_or_path="$2" + + if [ -f "$image_or_path" ]; then + echo "$image_or_path" + return 0 + fi + + if [ -f "$install_data_dir/$image_or_path" ]; then + echo "$install_data_dir/$image_or_path" + return 0 fi - # Convert newline-separated paths into JSON array elements - local json_images - json_images=$(printf '"%s",' $images | sed 's/,$//') - # final JSON response on stdout - echo "{ \"error\":\"\", \"retval\":\"0\", \"images\":[${json_images}] }" + return 1 } +#-------------------------------------------------------------------------- +# sys_discover_target_devices +# +# Populates globals: +# SYS_CURRENT_ROOT_DEV - current live root device identifier +# SYS_TARGET_DEVICES - array with valid target block devices (/dev/*) +# +# Filtering rules match legacy deploy-image-wic behavior, including: +# - skip installer/live root device and backing devices +# - skip loop/dm/ram/sr/mtd/zram +# - skip inactive md arrays and md members +#-------------------------------------------------------------------------- +sys_discover_target_devices() { + local current_root_dev_type + local current_root_dev + local root_source + local root_source_resolved + local base_no_part + local slave + local slave_dev + local slave_base + local devices + local mmc_devices + local device + local is_raid_member + local holder_path + local holder_name + local state + local skip_device + local ex + + local exclude_list=() + + SYS_TARGET_DEVICES=() + + # Determine the live root device so we do not offer the current system disk + # as an install target. For NFS roots use a special sentinel value. + + current_root_dev_type=$(findmnt / -o fstype -n) + if [ "$current_root_dev_type" = "nfs" ]; then + current_root_dev="nfs" + exclude_list+=("nfs") + else + 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/} + + exclude_list+=("$current_root_dev") + + # Strip partition suffix for common disk names so the base device + # (e.g. /dev/sda or /dev/mmcblk0) also does not become selectable. + 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 + + # Exclude backing devices for the live root, such as multipath or RAID + # underlying devices exposed via /sys/block//slaves. + 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 + + SYS_CURRENT_ROOT_DEV="$current_root_dev" + + # Gather block devices from /sys/block while preserving mmcblk devices that + # would otherwise be filtered by the main find expression. + 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 + # Skip RAID member devices, because we only want whole block devices + # available for standalone image installation. + continue + fi + + if [[ "$device" == md* ]]; then + # Accept only active or clean md arrays, reject degraded/inactive RAID sets. + if [ -f "/sys/block/$device/md/array_state" ]; then + state=$(cat /sys/block/$device/md/array_state | tr -d '\n' | tr -d ' ') + if [ "$state" != "active" ] && [ "$state" != "clean" ]; then + echo "Skipping RAID device $device: state='$state'" >&2 + continue + fi + echo "Found RAID device $device: state='$state'" >&2 + else + echo "Skipping RAID device $device: no array_state file" >&2 + continue + fi + fi -# ------------------------------------------------------------------- -# API: sys_list_valid_target_devices -# Description: -# Shell-friendly variant of sys_get_valid_target_devices. -# Prints one valid device per line (absolute path). -# Usage: -# sys_list_valid_target_devices -# Output: -# /dev/sdb -# /dev/sdc -# ------------------------------------------------------------------- -sys_list_valid_target_devices() { - local dev - - for dev in /sys/block/*; do - dev=$(basename "$dev") - - case "$dev" in - loop*|ram*|sr*|mtd*) + case "$device" in + dm-*|loop*|mtd*|sr*|ram*|zram*) continue ;; esac - # skip inactive md devices - if [[ "$dev" == md* ]]; then - [ -f "/sys/block/$dev/md/array_state" ] || continue - state=$(cat /sys/block/$dev/md/array_state) - [ "$state" = "active" ] || [ "$state" = "clean" ] || continue - fi + skip_device=0 + for ex in "${exclude_list[@]}"; do + if [[ "$device" == "$ex"* ]]; then + skip_device=1 + break + fi + done - echo "/dev/$dev" + if [ "$skip_device" -eq 0 ]; then + SYS_TARGET_DEVICES+=("/dev/$device") + fi done } + +#-------------------------------------------------------------------------- +# sys_device_size +# +# Returns: +# human-readable size string from lsblk, or empty if unavailable. +#-------------------------------------------------------------------------- +sys_device_size() { + local device="$1" + lsblk --nodeps --noheadings -o SIZE "$device" 2>/dev/null | tr -d " " +} + +#-------------------------------------------------------------------------- +# sys_device_is_empty +# +# Returns: +# 0 when first 1 MiB is zero-filled, 1 otherwise. +#-------------------------------------------------------------------------- +sys_device_is_empty() { + local device="$1" + cmp /dev/zero "$device" -n 1M >/dev/null 2>&1 +} + +#-------------------------------------------------------------------------- +# sys_version_ge +# +# Returns: +# 0 if current >= required, else 1. +#-------------------------------------------------------------------------- +sys_version_ge() { + local current="$1" + local required="$2" + + if [ "$(printf '%s\n' "$current"X "$required" | sort -V | head -n 1)" != "$current"X ]; then + return 0 + fi + return 1 +} + +#-------------------------------------------------------------------------- +# sys_bmap_options_for_image +# +# Returns: +# bmaptool options string ("--nobmap" when no sidecar bmap is present). +#-------------------------------------------------------------------------- +sys_bmap_options_for_image() { + local image_path="$1" + local disk_bmap + + disk_bmap="${image_path%.wic*}.wic.bmap" + if [ -f "$disk_bmap" ]; then + # If a .wic.bmap sidecar exists, return an empty option string so + # bmaptool uses the bundled map automatically. + echo "" + else + echo "--nobmap" + fi +} + +#-------------------------------------------------------------------------- +# sys_install_image_with_lock +# +# Performs the actual bmaptool copy, serializing concurrent installer +# consoles via flock. When UI hook functions are available, this API +# uses them to present a progress gauge in attended mode. +# +# Optional UI hooks (if defined): +# ui_start_progress_gauge +# ui_stop_progress_gauge +#-------------------------------------------------------------------------- +sys_install_image_with_lock() { + local image_path="$1" + local target_device="$2" + local lockfile="/run/installer.lock" + local progress_pipe="/run/installer.fifo" + local bmap_options + local bmap_version + local quiet_flag="" + + bmap_options=$(sys_bmap_options_for_image "$image_path") + + exec 9>"$lockfile" + if flock -n 9; then + bmap_version=$(bmaptool --version | awk '{ print $NF }') + + if sys_version_ge "$bmap_version" "3.6"; then + if [ -p "$progress_pipe" ]; then + rm -f "$progress_pipe" + fi + + if ! mkfifo "$progress_pipe"; then + echo "Error: Failed to create named pipe $progress_pipe" + return 1 + fi + + bmap_options="$bmap_options --psplash-pipe=$progress_pipe" + quiet_flag="-q" + + if declare -F ui_start_progress_gauge >/dev/null; then + ui_start_progress_gauge "$progress_pipe" + fi + fi + + # Run the actual copying step under the lock to avoid concurrent writes + # from multiple installer consoles or sessions. + if ! bmaptool $quiet_flag copy $bmap_options "$image_path" "$target_device"; then + if declare -F ui_stop_progress_gauge >/dev/null; then + ui_stop_progress_gauge + fi + return 1 + fi + + if declare -F ui_stop_progress_gauge >/dev/null; then + ui_stop_progress_gauge + fi + else + echo "Installation already running in another console." + sleep 5 + + if [ -e "$progress_pipe" ]; then + echo "Installation progress..." + tail -f "$progress_pipe" | while read -r line; do + printf "\r%s%%" "$line" + done + else + echo "Waiting for installation to finish..." + while pgrep -x "bmaptool" >/dev/null; do + sleep 5 + done + fi + fi + + return 0 +} From patchwork Mon Apr 27 06:39:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kasturi shekar X-Patchwork-Id: 5050 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Mon, 27 Apr 2026 08:40:15 +0200 X-Sieve: CMU Sieve 2.4 Received: from mail-qv1-f64.google.com (mail-qv1-f64.google.com [209.85.219.64]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 63R6e6SK000469 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 Apr 2026 08:40:07 +0200 Received: by mail-qv1-f64.google.com with SMTP id 6a1803df08f44-8ae6aa148a7sf189109796d6.0 for ; Sun, 26 Apr 2026 23:40:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1777272001; cv=pass; d=google.com; s=arc-20240605; b=JS/wmeCXa68xyonL2qsrUs9uTm/cMoHpI5xf5MZF/QI9uOyBPHQSGGrEmirCQtA2o9 z13xG70OBBcLJV40C9/hChgz55fzTlO4+8ZVHsGk3Sw2l/8NqTCj9WIitjGM0TaAXk43 1FzRSyiViWyEJjbfhEmU9eqinenvt4uvVgKQqVSmRXgl9BepVea4Uw/rqVK/MRC75qMJ C33PR7BFY3ZXMI0f/K7tiP5xVcljyZFXdyc165CTuZ4/Pr/cnxQT5GleG/UV+JCVLdok pTkiN99aKsDHpua89EuUywJxP/qVnFX6157GE6KKYON86l6GwsFCFFMRx3jHSUWYr0QU fc6g== 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:reply-to:feedback-id :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ZncHi4nBRsL1VqRmAq6UsTvNVqkiA+A6Oq/N+qTFRRw=; fh=Oc8uYKG1IM9Ou4GrtQJDdFx71c7Hs+Nt1AnEdH6ixJw=; b=T9aBzg/VkdToKWaHfLqe7bNunS+X/NU2bS3JtazkZpCHsIDILnqTnbrZww0fV4FKTX h0aTzal53z3jGDvirYaX7IxydINlAahHylIDHiQndtwzAYDTkB6aZbWXKkGfvNqq1aJY QlWg5Tw8+yOFQQZNX33Rh8AXAKJFlMl7twwIOZlrVgJYGBNovOrqF0vb/WKLJl8teuL6 OkoQ+nMAs1Vvx9b2v1gQleHol3HdxgoCtDJdHcamXaghKzFLeLUD6OQWphPAnb/lHZ4K kZZkd624nxPTnOWRDmpRblcmhGjIoPkTNX7yfF6THH+Hox9OEnVqeAu1ZBzlJDJXKlxr dUuw==; darn=isar-build.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=Oou6e1m4; spf=pass (google.com: domain of fm-1328757-202604270639584cea3f4a0b00020755-xtyvbq@rts-flowmailer.siemens.com designates 185.136.64.228 as permitted sender) smtp.mailfrom=fm-1328757-202604270639584cea3f4a0b00020755-XTYvBq@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20251104; t=1777272001; x=1777876801; darn=isar-build.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZncHi4nBRsL1VqRmAq6UsTvNVqkiA+A6Oq/N+qTFRRw=; b=izgvo83vW9tTV4G2/rMI6lTSGwPcwMJX06QotnE02mZWEeTUlm3Ja7jPjPnkyOs2ta S0nPMv+6me/PDDgFQSxwUd2DtlSNn3AvVLuZiXerLVwB68dcPT2CdJfITT1uEdOWa8LK mTfKTFeikxYHieFvB+4yLyErfuO1lkOgz+KD1sQvGBGIXPPph2nJVNM82Pjv8UQu5T/G PWaYz0wPM6cJ/v40cEblc9ZNPL8KDTbcpGNpMUhKeaEf6XotQmqoWDJ3y4kJOoLE+VpR fn1mUrkiZNwxdMXPLgWpu2bJ/G8aP/+joME8HHlHA9djofzThuFOMHhadYLaqrXj0ppB XvDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777272001; x=1777876801; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ZncHi4nBRsL1VqRmAq6UsTvNVqkiA+A6Oq/N+qTFRRw=; b=SPi+ZDuLL3eb0LYOm05DMdFjwgkbtc24n2O5kYtY3S004XPWWd4gRCIJHRelwRzPqx DXvULFlUdsw9XH4R2DEubla/nymly88GxCpWubLaIIp+l0YPsM1yBp2Hrebh2NVRmjoE 7LJf/Wr2hqpOUPon9+tfZXvQeyBU7uJarArCWjIy4iv0RN95KtuRawWTOYnbsEdE2Xmg kd3FoNM0HAYDhPaD8IjzwShfvGspWULnpM/aiuJPEvdcqQ15xp19xfmkesspfeKKDHGl hWzIkxFZiUpVELasO6ttSvFGePPXyEc0Rh/XJqUUz4CRYxFnZE34DHR7vAUKQxuo42Aa 4ulQ== X-Forwarded-Encrypted: i=2; AFNElJ/lDKtd1/zzonuYB0Ng8LWhaoe4oMULB65RFl/T4jfCcUq8EyeHYsyf28xLc5JWnCooXg7yWLk=@isar-build.org X-Gm-Message-State: AOJu0YxZDsGvhighulr6BLA6Nxr5n4AMoELPwryQUA6EZjAE1aHca88G vh+XKsyE8tmi+TSQm08OTQnvxbbJOy0tWDN6SiVq+wnCOj7/mYcE2Cty X-Received: by 2002:a05:6214:500f:b0:89c:da2b:d137 with SMTP id 6a1803df08f44-8b0287e49e3mr527403726d6.33.1777272001052; Sun, 26 Apr 2026 23:40:01 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com; h="AYAyTiLr0XP4xmYAmr7S/4taG9jw/aC9FUZK17CQ779wqsGx7g==" Received: by 2002:a05:622a:4656:b0:50f:b181:6ae0 with SMTP id d75a77b69052e-50fb1816d70ls47318281cf.0.-pod-prod-00-us; Sun, 26 Apr 2026 23:40:00 -0700 (PDT) X-Received: by 2002:a05:622a:1902:b0:50b:8b8c:f68b with SMTP id d75a77b69052e-50e367b90a2mr541560811cf.39.1777272000211; Sun, 26 Apr 2026 23:40:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777272000; cv=none; d=google.com; s=arc-20240605; b=Pg+I2ZcIv8yRYXvpJvGe1TzIRyAi20t8nvCt/nzyqZhkQYLnvf2CKjp2hZ98NuI2nk NuG5S0Ws39HPFy2gh5Y2p5hMr/rKrLEY5KUdJp8eWYny8gOKjvKoCvzJfKRFDm4tx9GX gRK+jXGdLArQuDHzTZeG73LyVmZ0zsWiz2l7fh1TzbdOIx2O8gkJF9+R4Cs2FmD4WnV0 N1B/571K2n17ArpBHJX30lsbh6sZ3TKLjClXzlZ0Ykb8PiwATWNhobbbButmWNtny2uV WDhnQhYPvaeGLEFw1gNI0C+su5ucUDCd7t4c8iXp13r4m6jIaqniKR+zxy1pBP2/ynRU qfKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=feedback-id:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=ytomooH9Ej5VaG//kMNK2ngS+woy9XntQRff8LUEiDY=; fh=kh6mBxUBxYhzFhhtG3ckYICU9JWCX223LZXZsw4oG5w=; b=eezjHhrnqTqXfqm1aWo0XIOS4NGWCCC6WSgIcfYwaqDqODY5QaipQSf6kyEG8WhZkw pTJ3iMl8eS5Ht9Kgt/RT3kqaAL7D8FFbbKgO4smBbVmfLO5dr4OsqafwNWX2iZ0KUBRw WVTajUFlypT/vQUZno4y3jPVIyOJbdD+6VRpyIiJo/TsFIs6EMkZAYIApBGqhlvvW1AQ Uzar7mbRWWUqI7I/kqEIdjr7rRaGtOcMxe3c3PYwxMkSGpAgFs9/QkSYeTgnLdgDunUg oT5izUgUBA5y6UPHKIahP+6gC4kbM576O2VdI6kaLm5KVlsNSdxpLffOUoBtvB+eA775 f85Q==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=Oou6e1m4; spf=pass (google.com: domain of fm-1328757-202604270639584cea3f4a0b00020755-xtyvbq@rts-flowmailer.siemens.com designates 185.136.64.228 as permitted sender) smtp.mailfrom=fm-1328757-202604270639584cea3f4a0b00020755-XTYvBq@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from mta-64-228.siemens.flowmailer.net (mta-64-228.siemens.flowmailer.net. [185.136.64.228]) by gmr-mx.google.com with ESMTPS id d75a77b69052e-50fbe8b5d39si6680961cf.4.2026.04.26.23.40.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Apr 2026 23:40:00 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-1328757-202604270639584cea3f4a0b00020755-xtyvbq@rts-flowmailer.siemens.com designates 185.136.64.228 as permitted sender) client-ip=185.136.64.228; Received: by mta-64-228.siemens.flowmailer.net with ESMTPSA id 202604270639584cea3f4a0b00020755 for ; Mon, 27 Apr 2026 08:39:59 +0200 X-Patchwork-Original-From: "'Kasturi shekar' via isar-users" From: Kasturi shekar To: isar-users@googlegroups.com Cc: "kasturi.shekar" Subject: [PATCH 2/4] installer: extract attended UI to installer_ui.sh Date: Mon, 27 Apr 2026 12:09:54 +0530 Message-ID: <20260427063957.603123-3-kasturi.shekar@siemens.com> In-Reply-To: <20260427063957.603123-1-kasturi.shekar@siemens.com> References: <20260427063957.603123-1-kasturi.shekar@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1328757:519-21489:flowmailer X-Original-Sender: kasturi.shekar@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=Oou6e1m4; spf=pass (google.com: domain of fm-1328757-202604270639584cea3f4a0b00020755-xtyvbq@rts-flowmailer.siemens.com designates 185.136.64.228 as permitted sender) smtp.mailfrom=fm-1328757-202604270639584cea3f4a0b00020755-XTYvBq@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: Kasturi shekar Reply-To: Kasturi shekar 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-Spam-Status: No, score=-4.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: "kasturi.shekar" Move attended dialog interactions into installer_ui.sh The new UI module provides: - image selection menu - target device selection menu - install and overwrite confirmation dialogs - error and info dialogs - attended progress gauge hooks Signed-off-by: kasturi.shekar --- .../files/usr/bin/installer_ui.sh | 217 +++++++++++++----- 1 file changed, 161 insertions(+), 56 deletions(-) mode change 100755 => 100644 meta-isar/recipes-installer/deploy-image/files/usr/bin/installer_ui.sh diff --git a/meta-isar/recipes-installer/deploy-image/files/usr/bin/installer_ui.sh b/meta-isar/recipes-installer/deploy-image/files/usr/bin/installer_ui.sh old mode 100755 new mode 100644 index 33685c6f..9d3ba5de --- a/meta-isar/recipes-installer/deploy-image/files/usr/bin/installer_ui.sh +++ b/meta-isar/recipes-installer/deploy-image/files/usr/bin/installer_ui.sh @@ -1,86 +1,191 @@ #!/usr/bin/env bash +# This software is a part of ISAR. +# Copyright (C) Siemens AG, 2026 # -# installer_ui.sh — Attended installer frontend -# ------------------------------------------------ +# SPDX-License-Identifier: MIT -SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" -INSTALL_DATA=${INSTALL_DATA:-./install} +#-------------------------------------------------------------------------- +# installer_ui.sh - Frontend/UI helpers for isar installer. +# +# This file is intentionally UI-only: +# - dialog menus and message boxes +# - attended confirmations +# - user abort countdown handling +#-------------------------------------------------------------------------- +UI_GAUGE_PID="" + +#-------------------------------------------------------------------------- +# ui_show_error +# +# Displays an error dialog in attended mode. +#-------------------------------------------------------------------------- +ui_show_error() { + local message="$1" + dialog --msgbox "$message" 6 60 +} -# Backend APIs -. "$SCRIPT_DIR/sys_api.sh" +#-------------------------------------------------------------------------- +# ui_show_info +# +# Displays an informational dialog in attended mode. +#-------------------------------------------------------------------------- +ui_show_info() { + local message="$1" + dialog --msgbox "$message" 6 60 +} + +#-------------------------------------------------------------------------- +# ui_countdown_allow_attended_switch +# +# In unattended mode, this gives users a chance to switch to attended +# mode by pressing any key. Returns 0 when attended mode should be +# used, and 1 otherwise. +#-------------------------------------------------------------------------- +ui_countdown_allow_attended_switch() { + local timeout="$1" + local abort_file="$2" + local i + + # Countdown loop prints a message once per second and accepts a key press. + # If any key is pressed, create the abort trigger file for the caller. + for ((i=timeout; i>0; i--)); do + echo -ne "\rUnattended installation will start in $i seconds. Press any key to switch to attended mode..." + + if [ -f "$abort_file" ] || read -n 1 -t 1; then + touch "$abort_file" + echo + return 0 + fi + done -# ------------------------------------------------ -# Helpers -# ------------------------------------------------ -die() { - dialog --msgbox "$1" 6 60 - exit 1 + echo + return 1 } -# ------------------------------------------------ -# UI: Select image -# ------------------------------------------------ -ui_select_image() { - local images json list=() +#-------------------------------------------------------------------------- +# ui_select_image_menu +# +# Uses sys_list_installable_entries backend API and returns selected +# relative image path on stdout. +#-------------------------------------------------------------------------- +ui_select_image_menu() { + local install_data_dir="$1" + local list=() + local entry + local selected - # On failure, show error dialog and exit - json=$(sys_locate_disk_images search_path="$INSTALL_DATA") || \ - die "No installable images found in $INSTALL_DATA" + while IFS= read -r entry; do + [ -n "$entry" ] || continue + list+=("$entry" "$entry") + done < <(sys_list_installable_entries "$install_data_dir") - # Extract image paths from JSON - images=$(echo "$json" | sed -n 's/.*"images":\[\(.*\)\].*/\1/p' | tr -d '"' | tr ',' '\n') + if [ "${#list[@]}" -eq 0 ]; then + return 1 + fi - # Building dialog menu entries - for img in $images; do - base=$(basename "$img") - list+=("$img" "$base") - done + selected=$(dialog --no-tags \ + --menu "Select image to be installed" 12 70 6 \ + "${list[@]}" --output-fd 1) || return 2 - # Display menu and capture selection - INSTALL_IMAGE=$(dialog --no-tags \ - --menu "Select image to install" 10 70 5 \ - "${list[@]}" \ - --output-fd 1) || exit 0 + echo "$selected" + return 0 } -# ------------------------------------------------ -# UI: Select target device -# ------------------------------------------------ -ui_select_target_device() { +#-------------------------------------------------------------------------- +# ui_select_target_device_menu +# +# Displays candidate target devices and returns selected /dev path. +#-------------------------------------------------------------------------- +ui_select_target_device_menu() { local list=() + local target + local target_size + local state + local selected - devices=$(sys_list_valid_target_devices) || \ - die "No valid target devices found" + for target in "$@"; do + [ -b "$target" ] || continue - for dev in $devices; do - [ -b "$dev" ] || continue + target_size=$(sys_device_size "$target") + [ -n "$target_size" ] || target_size="unknown" - size=$(lsblk --nodeps --noheadings -o SIZE "$dev" 2>/dev/null | tr -d " ") - [ -z "$size" ] && size="unknown" - - if cmp /dev/zero "$dev" -n 1M >/dev/null 2>&1; then + # Indicate whether the selected device is already empty, to help users + # avoid accidental overwrite of data. + if sys_device_is_empty "$target"; then state="empty" else state="contains data" fi - list+=("$dev" "$dev ($size, $state)") + list+=("$target" "$target ($target_size, $state)") done - if [ "${#list[@]}" -lt 2 ]; then - die "no installable target devices available" + if [ "${#list[@]}" -eq 0 ]; then + return 1 fi - TARGET_DEVICE=$(dialog --no-tags \ - --menu "Select target device" 10 70 6 \ - "${list[@]}" \ - --output-fd 1) || exit 0 + selected=$(dialog --no-tags \ + --menu "Select device to install image to" 12 70 6 \ + "${list[@]}" --output-fd 1) || return 2 + + echo "$selected" + return 0 } -run_interactive_installer() { - clear - ui_select_image - ui_select_target_device +#-------------------------------------------------------------------------- +# ui_confirm_install +# +# Returns: +# 0 when user confirms, 1 when canceled. +#-------------------------------------------------------------------------- +ui_confirm_install() { + local image_path="$1" + local target_device="$2" + local target_size="$3" + + dialog --yes-label Ok --no-label Cancel \ + --yesno "Start installing\n'$image_path'\nto $target_device (capacity: $target_size)" 8 70 +} + +#-------------------------------------------------------------------------- +# ui_confirm_overwrite +# +# Returns: +# 0 when user accepts overwrite, 1 when canceled. +#-------------------------------------------------------------------------- +ui_confirm_overwrite() { + dialog --defaultno --yesno "WARNING: Target device is not empty! Continue anyway?" 8 70 +} + +#-------------------------------------------------------------------------- +# ui_start_progress_gauge +# +# Opens a dialog gauge and updates it from bmaptool psplash pipe. +#-------------------------------------------------------------------------- +ui_start_progress_gauge() { + local pipe_path="$1" + + ( + while true; do + if read -r line < "$pipe_path"; then + percentage=$(echo "$line" | awk '{ print $2 }') + echo "$percentage" + fi + done + ) | dialog --gauge "Flashing image, please wait..." 10 70 0 & + + UI_GAUGE_PID=$! +} + +#-------------------------------------------------------------------------- +# ui_stop_progress_gauge +# +# Best-effort termination of the active progress gauge process. +#-------------------------------------------------------------------------- +ui_stop_progress_gauge() { + if [ -n "$UI_GAUGE_PID" ]; then + kill "$UI_GAUGE_PID" 2>/dev/null || true + UI_GAUGE_PID="" + fi } -run_interactive_installer From patchwork Mon Apr 27 06:39:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kasturi shekar X-Patchwork-Id: 5051 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Mon, 27 Apr 2026 08:40:16 +0200 X-Sieve: CMU Sieve 2.4 Received: from mail-qt1-f185.google.com (mail-qt1-f185.google.com [209.85.160.185]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 63R6e8Sd000479 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 Apr 2026 08:40:08 +0200 Received: by mail-qt1-f185.google.com with SMTP id d75a77b69052e-50fb3c7b989sf109490711cf.0 for ; Sun, 26 Apr 2026 23:40:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1777272002; cv=pass; d=google.com; s=arc-20240605; b=K/yghsedggJTTDzIID4QGQYUibGS3+dfq+z16cP997DP7iWeNXsnbDbf5KmOjsd7k/ S2zJbggvPkHmbFokxC82Rspdp8EtrAY7ofP52hxz4VpKx8QFkS+66T+Ot2aqxyefBNMs MiwuQAmTF6NNDPZFtS0RwxJ/sh3dYsMXKbZOeGdeFzXyBLT1M5cH69XRvs/teW+ODlca 98yLY4pxP2gMqjiUT2UGmmB5600D4qf/Lu6DXnE9UUqO0H1FiIFSbo0TpEvF+LMOftAE nuzuy6IHje+M8rq/cjcrVQ9WRxYehpq0ekflNtckKo50RzqXuI9ke+HGoaY7vP7MJn0G 8Ssg== 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:reply-to:feedback-id:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VTmvnn9fk1Dwikgezeh1dpRzaynQwmGZt2UmqtKKsAg=; fh=l4IMEeLuV5xWGoG4sdw6xQKfmhA3Urt4UULBBYMXYz4=; b=T32ihCdLn9cOO3JZB0JTCw24Vkx7avQzZqS9lViWWHYct/dcCtxNB/PLPlIZLBTbqM m8dMsWCzVyyrJBqZJLHKipU5b2qZW8h8MdK+FbKN0xdOPoEKrp6o/H2NPuqZPKV9jJ6h UfQCo6sYdR3qI+BwR2Ya9ZZqqJ5/Zx9fmTTkTnldfVkGu7bmfkpXMPiaEvaHBfxzmjuK CT04XH0ptIhvOQQeQTFNiiogizAG8Dw1hO9kyjEam677j1kjAz1WYMg64QvvSNlOQNzM f6pnzkEb7RHMke+1r5CNWuK98H4bynxIktFkj9h7FzOjtM5Nl5ha9hOu25IWlS31Q00I Zhbw==; darn=isar-build.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=O1QuGWLa; spf=pass (google.com: domain of fm-1328757-20260427064000a9a8877af0000207a7-4x_blb@rts-flowmailer.siemens.com designates 185.136.64.228 as permitted sender) smtp.mailfrom=fm-1328757-20260427064000a9a8877af0000207a7-4X_BlB@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20251104; t=1777272002; x=1777876802; darn=isar-build.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=VTmvnn9fk1Dwikgezeh1dpRzaynQwmGZt2UmqtKKsAg=; b=GBESgh6ifJl/oBxQIaPz9oZnr2CXeipY4Xhx72Rjp+K9nIZDC27tqylRaSfeALokvQ 7hPaqK20gMUSyvTdM+mM3Xo/6AUUVVpgX7PzjN8/4pPgamwmh5v+T5VgRX4vkrG6/+QV qtBgQ1so6ExRj/DY9fG0IKRhOdO+Gol2TCgDN1HNzlSgfpSsokUxyVsvxnD/rO0QoA0Q IeQOBl5h2ceVrioeszQY404JlNzCt03qHvxBaIe1pXw7Q44kURGMPVND+y6abdrOBYnK H0QsM+ICr8LVKJPQqL2rmcLaUmgi/5HYxASNAsA4wqKjprTHlMqFAS7D6wtWGd7e/HdI BNiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777272002; x=1777876802; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-beenthere:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=VTmvnn9fk1Dwikgezeh1dpRzaynQwmGZt2UmqtKKsAg=; b=ZI0qEdEGyKMcP8p7cSMAT8Z3/0U4jlBmowhmTP1qESoTTgpenLYvOKoqtAbB2mgtBC ho1xqV4tRn/iNXEwa1fyFZ8H7ZHMz7Io+5kKaHhFVDzepHqcAtZVKupX2IDoVM5U1i+e qiVt/LthvwzQsnJQePRGZbBMnwWLgIa7EJXPGXPaJJdAg1bB+XcORxQJKqVGLT2lY5eJ Z6NeNPMIjEhtkbLtCj/qYsF/esdSIO3jmpTFt293T8jT/CqQ3MyMR6y+OqYUimXN+/DW 3DZBMQiRoR6AOnam7w+cXFshJlTWvmofTB54JIF8Tnc9nPdTwM2xBTma4H3eEaRdcbJR gepA== X-Forwarded-Encrypted: i=2; AFNElJ8AoFDblpQ8a1ScgyHUdcKquf/rgNFOuNCgjqt5eITXmt/AUXhHnsrFOAeE1WVLdGn516XpYQI=@isar-build.org X-Gm-Message-State: AOJu0YzsDQmsBPVHOK64Ln598+GGNvjuhDrOu1gwb7MALkMBzxiMHa/s eguNrgSWPeJPacbbulQzHWFh47IVSCxs4T5Y04zPZsaEkwkubk10blGe X-Received: by 2002:ac8:5856:0:b0:50f:ca25:fb48 with SMTP id d75a77b69052e-50fca26036fmr264083651cf.55.1777272002342; Sun, 26 Apr 2026 23:40:02 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com; h="AYAyTiKkUQdWhe2zEXsmQg3JvxpmEs0d8Mn0S7TcWA0DGxS/xA==" Received: by 2002:ac8:628a:0:b0:50e:5a4b:401c with SMTP id d75a77b69052e-50e5a4b5477ls79181981cf.0.-pod-prod-01-us; Sun, 26 Apr 2026 23:40:01 -0700 (PDT) X-Received: by 2002:a05:622a:287:b0:50f:b4c0:62ff with SMTP id d75a77b69052e-50fb4c068famr393703881cf.54.1777272001398; Sun, 26 Apr 2026 23:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777272001; cv=none; d=google.com; s=arc-20240605; b=Uao0nJGKGRNGIPiGZc2i+g5u8EsSz5Nfqaz+ClHo8gclLPfVY9cjyEUgq7QpPj7CPe Y5wfXUSmvsKT8EBrkFnalvj2oaCsMRHXweClW4ZfXrzKq/nDTIbbKPKFemoLwqxx9lUr eioXW3D51LG/4NAnS7VAGIrLVwT8HUXk97mHIy203ufCz+U0UdVl+PqdD/jgSmsaLK2W P+OuYnRLk4ON2lxy3hB7iuUmhHOFhU3ArueH71g+SL2Zx603LVEZ3VEc5fEWhHyKWytn Xk0Zk7vwYlsWgXckrgZcL5rXy7r5mzR3yK2tB/eUoiHjfXZT+lzBveVXzruRsI+tLD5y dm7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=feedback-id:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=0mWN3zvhbc/yCMVJqXHPqNT0BJg7H4y5py8KuQ+bIP0=; fh=kh6mBxUBxYhzFhhtG3ckYICU9JWCX223LZXZsw4oG5w=; b=icxTaKNyqFA1XTF8MiGFgSyzk/79hpqsH2wFDSOF/BPW4Q+xDhRPSIO2XclQBGb6g/ MRVTrGVZD4JwCQfJsmcDYoH/nQGcImo237CKiYXB6nvUF5LESpHTm3YeO6cVke9n3J23 11xOXKOgDy6uvlV3u7QlWN5kBIwe8yBGg/YW/OBfzHas3gPjZLPqYJQgE/7PKKgqP8m/ 3mmikcb6yVUkgoaxeIhSpZxICP4yrnTI9a4bamHKxDDhHC0TRH7joMw1QCbvVi4evVkl CkR0dscJQNjJvtap7KR1mLwxDeDnpAfaHF+cd8xsW0ogtr67eP3gknlrfTfJWJuCSbnE Dz+A==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=O1QuGWLa; spf=pass (google.com: domain of fm-1328757-20260427064000a9a8877af0000207a7-4x_blb@rts-flowmailer.siemens.com designates 185.136.64.228 as permitted sender) smtp.mailfrom=fm-1328757-20260427064000a9a8877af0000207a7-4X_BlB@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from mta-64-228.siemens.flowmailer.net (mta-64-228.siemens.flowmailer.net. [185.136.64.228]) by gmr-mx.google.com with ESMTPS id d75a77b69052e-50fbe8b5d39si6680961cf.4.2026.04.26.23.40.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Apr 2026 23:40:01 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-1328757-20260427064000a9a8877af0000207a7-4x_blb@rts-flowmailer.siemens.com designates 185.136.64.228 as permitted sender) client-ip=185.136.64.228; Received: by mta-64-228.siemens.flowmailer.net with ESMTPSA id 20260427064000a9a8877af0000207a7 for ; Mon, 27 Apr 2026 08:40:01 +0200 X-Patchwork-Original-From: "'Kasturi shekar' via isar-users" From: Kasturi shekar To: isar-users@googlegroups.com Cc: "kasturi.shekar" Subject: [PATCH 3/4] installer: add installer flow module and entrypoint Date: Mon, 27 Apr 2026 12:09:55 +0530 Message-ID: <20260427063957.603123-4-kasturi.shekar@siemens.com> In-Reply-To: <20260427063957.603123-1-kasturi.shekar@siemens.com> References: <20260427063957.603123-1-kasturi.shekar@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1328757:519-21489:flowmailer X-Original-Sender: kasturi.shekar@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=O1QuGWLa; spf=pass (google.com: domain of fm-1328757-20260427064000a9a8877af0000207a7-4x_blb@rts-flowmailer.siemens.com designates 185.136.64.228 as permitted sender) smtp.mailfrom=fm-1328757-20260427064000a9a8877af0000207a7-4X_BlB@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: Kasturi shekar Reply-To: Kasturi shekar 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-Spam-Status: No, score=-4.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= 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 60944e58..d128a9b8 --- 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=/tmp/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 + 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=/tmp/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 From patchwork Mon Apr 27 06:39:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kasturi shekar X-Patchwork-Id: 5052 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Mon, 27 Apr 2026 08:40:17 +0200 X-Sieve: CMU Sieve 2.4 Received: from mail-yx1-f56.google.com (mail-yx1-f56.google.com [74.125.224.56]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 63R6eB54000590 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 27 Apr 2026 08:40:12 +0200 Received: by mail-yx1-f56.google.com with SMTP id 956f58d0204a3-65014989b1esf19655796d50.1 for ; Sun, 26 Apr 2026 23:40:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1777272006; cv=pass; d=google.com; s=arc-20240605; b=kqMbZnQKE9TxpYb1rL2BCEMjLeb215gAcRN4zqkPrQme2YBsr5gGWDNJvfBql/opDQ MsNnC43/3FSYzhgggy4NFVHJ2L14/5ipibT1GVTTM0jfecX0gAtcj405uF5ftuvLCP9Q UvOM2bPg7+0VMknKuCl+JD28aWKZMAGX0CreaejP+qYvMT0eZkeoLTN9SMHwi8SeakxN D/CFY8zDByMeMYB7wPsDeANSEyoZEYpGaAXYpEVu8dE7m1mzvvR4Czd59X/EjQBMVrYG vCrLtMEo2N4hioMV4p0KEiOJ9wHaVcB+W1D7csOv6vJ8MpKLQmhAhnJY1P+wiolJUWzR +Wew== 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:reply-to:feedback-id:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qOByjre6p7f0XX4VBIlFvubyd4e2Hyooduup/rxreXE=; fh=qnYOPjstdH7xCjGA3IgnOWYsIhOoayNfLJEBKj5d66w=; b=ZmamN59wHYX9E2j8dx5Nc1095k2d7BmvA+4fLvDUORETFkBNE8Xpjwwi0trDl9DUVE 8o4BLtOKvsAouruSX6ORq5kbuMzHLIHY8eaJGTdytTRDGCBJ+/hiM1OtLm9asn9GIUUd 37mGe3MdXTG9w3R9M/yHREuLW2u19pCkPs8okYsqal0Zq+DbydFofYZLJQu8QNMfwmES Xt0ZqlxisI9uVk9zNeM5A9a1qStDJxra/U8NEI4eW3vDIRB8vKJScmKG98Oyo9BfEPCt RNpwC+8m/6W6atYHMgI/qYr6vdKy+o5+88co+mwynpholjClA17rjxUbgXS0Eapb1jc5 60Xw==; darn=isar-build.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=PSimEr1E; spf=pass (google.com: domain of fm-1328757-20260427064002746464b21700020752-c32ud2@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-1328757-20260427064002746464b21700020752-c32uD2@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20251104; t=1777272006; x=1777876806; darn=isar-build.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=qOByjre6p7f0XX4VBIlFvubyd4e2Hyooduup/rxreXE=; b=Q/HkZIifAbdziHcLt2UGM513J5Oy+0PN6VxC919QiDY/QUW3clX3qGWoyTkzagl0Eb VWZgNSdBEJOd6yS4QZHt0W6EUXKs+P+QID1GABTPhYVq1jEMQD/vce1LmgUM2LLkhdOm IV5R0gbu/HK5maE3dicO02TznENk5mfKO+wl/QZxcEUj7yIF3rqJUBIiZKy2mGsn2zeH XWvfVp8hzZi4SioLCx7wqb1nLfESSPQPeCCV8F4hfcYpfhggX8pHJkC0G9m9Vhz4p63G Z3Afvv1R2LDEM8YuUvfWkVA9C5a04cT3VnW/DFOrB/DVqQeB67VdSbWtTq0sJ+E+2kh1 35eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777272006; x=1777876806; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-beenthere:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qOByjre6p7f0XX4VBIlFvubyd4e2Hyooduup/rxreXE=; b=P5fMNu2Ot/le6qwBawlNymZQFUoveqTKjJFv5Gq15YyIEGihZX/Fg/iQ5VlcQY/Zz3 KwVIl5oyFNEAtGrPGbuMq87saHcOtqDg0rC5253FJaq03rI2Hs8VSbLzkWFes78Bra2q BP8VurM/IKoClM8UtCl5De1abpx2yXjb1UPqSPXpsezpRxQbFK0SEfpHjvVSspsLXg8g AMXPZ5/Y6Hk3Od+nibg25Ti2mtZbjjMfDb73GDlfKLSqfwP6e7TXEkrKw46ahXn/ZBA8 sGcglspUPoWnDbTCuA9f4EC8kkaFsFF8XSDqIi3aVcdeFdJEW44+tOWT6t4UC6kuPtPh R5kA== X-Forwarded-Encrypted: i=2; AFNElJ840eQGxGDhZXE6t8UlZsyPxbet/CKy1HbEllgRdhMIoIYnwnSQM22HA5jOlt4pxzsLLuLlqsQ=@isar-build.org X-Gm-Message-State: AOJu0Yx0Nadyej3d/IRlgjCPMKdxSD8NLTKXzqxRHcfuKAR2ykwEsa2P GCfMmm9KYtsb8NZBEmFHlCT55lUDhBPZZOqFrHeLJgzLEkHu3/q0APke X-Received: by 2002:a05:690e:1917:b0:654:52b8:4a8e with SMTP id 956f58d0204a3-65452b84dfdmr19744914d50.45.1777272006305; Sun, 26 Apr 2026 23:40:06 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com; h="AUV6zMPYZu1uVkzeQh4h9GODDIOCSv/MT2aaOZ0SW2wbIFKkoA==" Received: by 2002:a53:ee46:0:b0:652:fc9e:8e14 with SMTP id 956f58d0204a3-6542e8c3cc3ls6348684d50.2.-pod-prod-04-us; Sun, 26 Apr 2026 23:40:05 -0700 (PDT) X-Received: by 2002:a05:690c:348a:b0:7ba:f414:cd28 with SMTP id 00721157ae682-7baf414d250mr311762767b3.42.1777272005347; Sun, 26 Apr 2026 23:40:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777272005; cv=none; d=google.com; s=arc-20240605; b=HymuA4QKwo6KzuEvgDCRHXHpwe2qz6bDDxqKgC1qMJYfOvHIYr/fd3Z3cfxUqnqFsA 0AA88GesA/rqR4HAAYLAC4SZTjIRJGSfVwX8nwQ0q1mw4IGU0Hy15Lg0T/0pjia3hudO pYnsXEwY1UgMgQvfu6fS7IWHaoft/LqdyHCXnSCCQRDlc/V1fueDXU4eiPsZFsvezgUO uFweGAdIyrI4zwHEa8+vOKwBp2+3yVE9osLJa+vqW6zoqn7majGGn8JooILq26MZq8FH RmRG9D9b0XViTtxk8JxuP6Mot2TE2MlDPI+6ksO1wKEpgZICbLz32OthWUtXukqPd0zd o3yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=feedback-id:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=WHXgh3rBwCm2aAohbiZUSP+vLxm2Qv2g01CkH8hhgkI=; fh=kh6mBxUBxYhzFhhtG3ckYICU9JWCX223LZXZsw4oG5w=; b=HBHN5qnY1f98Crxlyi8pPIsJBdMAJuMI9+uBgkt+TnA6wi9HUKYD77QxZWGi/1YOV8 wolTGHlCL0EDDl8of1AhPaqK7W6/iODqaW2+Bu4Qx7ERTuvKuC9BIbpQD0sFiGKdfuYE 6kQm3JZwCPB0AKB+e0ji93GumOuyc2qmV2RMQAHHGvj4tYgfR/IJutRwzUBOJ1Q1mclT JaSA3vE2Ywu4hFEz2tGwDKDi24syF8peaATUYsaMoURvCL2TzuBDK9ikZpyo88ZDoluS x+tYNp31Jl3vQmH6uQfVOX8wI5Yc98aZLWfaftGZtXPjAyUC3BvzVDa1QK/YLRsTVsgF TKGw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=PSimEr1E; spf=pass (google.com: domain of fm-1328757-20260427064002746464b21700020752-c32ud2@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-1328757-20260427064002746464b21700020752-c32uD2@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com 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 00721157ae682-7b9ee9543c0si9425377b3.6.2026.04.26.23.40.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Apr 2026 23:40:05 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-1328757-20260427064002746464b21700020752-c32ud2@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) client-ip=185.136.65.226; Received: by mta-65-226.siemens.flowmailer.net with ESMTPSA id 20260427064002746464b21700020752 for ; Mon, 27 Apr 2026 08:40:02 +0200 X-Patchwork-Original-From: "'Kasturi shekar' via isar-users" From: Kasturi shekar To: isar-users@googlegroups.com Cc: "kasturi.shekar" Subject: [PATCH 4/4] installer: install seprated installer modules in recipe Date: Mon, 27 Apr 2026 12:09:56 +0530 Message-ID: <20260427063957.603123-5-kasturi.shekar@siemens.com> In-Reply-To: <20260427063957.603123-1-kasturi.shekar@siemens.com> References: <20260427063957.603123-1-kasturi.shekar@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1328757:519-21489:flowmailer X-Original-Sender: kasturi.shekar@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=PSimEr1E; spf=pass (google.com: domain of fm-1328757-20260427064002746464b21700020752-c32ud2@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-1328757-20260427064002746464b21700020752-c32uD2@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: Kasturi shekar Reply-To: Kasturi shekar 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-Spam-Status: No, score=-4.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: "kasturi.shekar" Update deploy-image recipe to ship the newly split installer modules. Add the following files to SRC_URI and do_install: - sys_api.sh - installer_ui.sh This finalizes packaging for the refactored installer layout. Signed-off-by: kasturi.shekar --- .../recipes-installer/deploy-image/deploy-image_0.1.bb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb b/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb index 03b082a9..ef161ebd 100644 --- a/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb +++ b/meta-isar/recipes-installer/deploy-image/deploy-image_0.1.bb @@ -1,5 +1,5 @@ # This software is a part of Isar. -# Copyright (C) Siemens AG, 2024 +# Copyright (C) Siemens AG, 2026 # # SPDX-License-Identifier: MIT @@ -9,6 +9,8 @@ MAINTAINER = "isar-users " inherit dpkg-raw SRC_URI = "file://usr/bin/deploy-image-wic.sh \ + file://usr/bin/sys_api.sh \ + file://usr/bin/installer_ui.sh \ file://usr/lib/deploy-image-wic/handle-config.sh \ " @@ -20,5 +22,7 @@ do_install[cleandirs] = "${D}/usr/bin/ \ " do_install() { install -m 0755 ${WORKDIR}/usr/bin/deploy-image-wic.sh ${D}/usr/bin/deploy-image-wic.sh + install -m 0755 ${WORKDIR}/usr/bin/sys_api.sh ${D}/usr/bin/sys_api.sh + install -m 0755 ${WORKDIR}/usr/bin/installer_ui.sh ${D}/usr/bin/installer_ui.sh install -m 0755 ${WORKDIR}/usr/lib/deploy-image-wic/handle-config.sh ${D}/usr/lib/deploy-image-wic/handle-config.sh }