From patchwork Tue Oct 8 10:22:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "alexander.heinisch" X-Patchwork-Id: 3857 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Tue, 08 Oct 2024 12:23:27 +0200 X-Sieve: CMU Sieve 2.4 Received: from mail-io1-f60.google.com (mail-io1-f60.google.com [209.85.166.60]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 498ANP9o023278 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 8 Oct 2024 12:23:25 +0200 Received: by mail-io1-f60.google.com with SMTP id ca18e2360f4ac-82cf5d58f5dsf51663539f.3 for ; Tue, 08 Oct 2024 03:23:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1728382999; cv=pass; d=google.com; s=arc-20240605; b=aPTpEEwJEySSyqvC/HoLLyo2AD/U3jccMBGsjYb9/MfwPQ+YBeK2795qIp1p6f25iH iYCejcn1zjJjCkE+m0gIZwDM4I97JC1ab9V6a0bFopGih7l3UK1hyn/gNQWHVMkSJS9L lZn25pT0mXEuHB872nVwE1fbTyyhQ21LKEU5t7AOiKHll2E3LxzghiQNsrkvJ6LQr+qq BqE/nDd12/fa8V0cJtBIylppoVUOFoKkaryHoAGKL0w7uNtNy9BLaUh85JXmeP4PQP9L mqjpjyVouqS2QDrfzr0haM2ksUIUH0LE2QOFpLMnDqf5k/50WkeamDqJZXvFY6LkS0Ep clMw== 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=KVeESprMNesuyzJ9SFN4F0mr+15gahmY5ao2Hh0r+54=; fh=7U6q0tjD7EmYe4Ww96DuzcjdfzXTC0oMErxheIRiZXI=; b=GXXWIx2huh4jPwXVtq0zKyZN9LhhTCp/awFUlbPcMjZZDP7wzKtmpZDcDT06gGPXmI oF1Li6p0vVmapqjK2jP1zJW4yJnqrAXJDtERUYh09LsfEPP+dFpPEx9JTN7N4dsvMVMy KY/5ZyY7esuOokoats9GqepzoqM6klGsAj8JPK2UDtI/Ii0HOWSfFgxAkBvG3zqfBsoE L2zlkQ6iyyZdVp4mWtWeCtVXeOXPioi1VDVz3h8XBRQVRAF9jFI6CurRcAFPrAtdsxY/ 7RVpmj4J7in6x+xX3G37MDZQYtsTamhQhhjATEvGyhsaty/5zm98nFs460L9tvRK6SZK KHlw==; darn=isar-build.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=nv1or8T2; spf=pass (google.com: domain of fm-1326448-20241008102315ecb55d46381941bb0b-pl2cdj@rts-flowmailer.siemens.com designates 185.136.64.225 as permitted sender) smtp.mailfrom=fm-1326448-20241008102315ecb55d46381941bb0b-pl2cDJ@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=20230601; t=1728382999; x=1728987799; 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=KVeESprMNesuyzJ9SFN4F0mr+15gahmY5ao2Hh0r+54=; b=l8mGjEKE8vxcJ/TYhzknTgFi9AMmGX31CusbHc9oMJuZcg7pcFGyuwEj3R7r1YHDvY /O7VYqM3mBAgx9WbFNARh/QCwYfByex9W8VnAiyLSCgxIbHxkoMm2bdWE7r0JR1dqtxK 60JH9hw1XIP48AYMC9jJvTT2JNDElHb9ZeYnqe2n7fyWOWDMRy4oYqBPSmuW1hcZgRy7 fXgEh6XMwsKv029dd//j2oKZOAgbQ3AWJCZr9lWKY8b5s4HmkxUWrqIZrqTpqSmW9cTj NXcJKmprSQyzTd/vS8mHtnbgSagIiPkWpsTpLX+YTUmLtGlBOZXlYeNdLN0k2qUahic5 c72Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728382999; x=1728987799; 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=KVeESprMNesuyzJ9SFN4F0mr+15gahmY5ao2Hh0r+54=; b=apSL/qYhIRQ3AXZJMiPZEbAah0ex8C1qX1gCEBdSQ4p7TOA9gWn5vrmqW9LaN+BBKS rn5/wr70OSiuqizFGyreRpaBHPZPsPLa1wp7unaDYfqyrYtJUVYhDS3H8ZT6HQy1xLsP rpEx+Twzs64ZXLIfyJlTwx+jukLDGrpFgFHN8ipIMjrKyLZX7X26fzD6aQ8V9jDViiWw svK4cXBEOd/jbye7OtsEazWh/qYLVbQGDETVe96PYBuntk87OLg02J9+7FovgkPRhZJ+ IoULjV+n4ZzoF5BRE+FIMk3eLsIjTgAZYWjW8mWk4kvJwXxCc6aaTdUHS7AQUlUuhzVc BY6Q== X-Forwarded-Encrypted: i=2; AJvYcCVyh6JCPukVMHMvU/FDltkyceWdwEsmQXteRMyUW6xGk9ADqg8A8WdNAvVkXjwuxHJ57B6kYW8=@isar-build.org X-Gm-Message-State: AOJu0Yz4u+uZtbymvwPqiYJ28CP2UKpczTJvQlJTa3xrxBSHKw0uNSGG XnjNcg0ddMLW8kODDeUKh3vcrXZiNOqVByTIFaQDMNuVYvMf4WKt X-Google-Smtp-Source: AGHT+IEds+Ux7lN5gm1kJidlby6Zq8kndvUqGz+vXFEOuRNfBkFLYDtS63x/XH84p7ExRQXXn0Mlzg== X-Received: by 2002:a05:6e02:13a2:b0:39f:5472:c37 with SMTP id e9e14a558f8ab-3a375986faemr40737615ab.2.1728382998960; Tue, 08 Oct 2024 03:23:18 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6e02:1d8b:b0:3a2:7592:2bf with SMTP id e9e14a558f8ab-3a36e4982dcls3098355ab.2.-pod-prod-03-us; Tue, 08 Oct 2024 03:23:17 -0700 (PDT) X-Received: by 2002:a05:6e02:148e:b0:3a0:8c83:91fb with SMTP id e9e14a558f8ab-3a375bc840dmr145264525ab.20.1728382997619; Tue, 08 Oct 2024 03:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728382997; cv=none; d=google.com; s=arc-20240605; b=eMrVxCk7v8gQbGov9cmyX8sJ6OTDQmNIdrJgydmR594oZsFLFsbYkP2NRKfB4VmiZQ BbYs1e7rdVY4OVoO7kBUJGPDwtAm6EG+IZAAXsipQXGOjfk2aYSV1YXn70XniD47YkrB fm1vLLvJQYDWFQgi5xyw4elJtF9jEW+x0MY3S9WTF1b+PpjkrdwI99gMtEfhz78BtMAq rqB0qPrKytX91xQn2hDMvJUZbVgVk7tYobQOz/FZdgtQuVBCMr0cQ3EH7BdBuujtL9NP EaQ5l1MqFbxp+igXlWUf8WZzgUew+fh1NU9/2DKRzLCHwCAkNW79ywfHgbuDApsxuldH bUkQ== 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=5LYz6Uwk0PQEWTQ57GgtWFzxJu8KSdyvqzMVDaHunbo=; fh=lKRNNdAU0IICONvfa+KjpneoIxBGWimmAGb9Xm7u9s8=; b=TrSN0FF/IDJwOjOBOijjRSJIpK2HTKvqAfGY77Sio0SxbDyxA9PfkZ2jY74xR0w+9I A3ALwU1Jcp54KkJS4Tqu5oPKZp7ijATDHBU9NIjGIZWf0jyRxEBcZR21h6eNySOcOV9h 5glhqkkfzUgbjKuVpun2X8RKeq4Vqu3DOqxZyfQndeTtUIoUK7MkGnFr5kLSQHpqqs/5 7WiwxT+FRYTHfNEitGM9zpfqudnVbvrMvfUWybFnlKp1zoR2w8afiANIutBKBspLjbRn JrDPxS9OSwh8TBTyM6iDv37C17Ts8+uGEaY2qbvfmbYcSU0wQeP+ZtcjrPrIhWZdie3a RP0g==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=nv1or8T2; spf=pass (google.com: domain of fm-1326448-20241008102315ecb55d46381941bb0b-pl2cdj@rts-flowmailer.siemens.com designates 185.136.64.225 as permitted sender) smtp.mailfrom=fm-1326448-20241008102315ecb55d46381941bb0b-pl2cDJ@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from mta-64-225.siemens.flowmailer.net (mta-64-225.siemens.flowmailer.net. [185.136.64.225]) by gmr-mx.google.com with ESMTPS id 8926c6da1cb9f-4db81a1d497si202656173.3.2024.10.08.03.23.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2024 03:23:17 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-1326448-20241008102315ecb55d46381941bb0b-pl2cdj@rts-flowmailer.siemens.com designates 185.136.64.225 as permitted sender) client-ip=185.136.64.225; Received: by mta-64-225.siemens.flowmailer.net with ESMTPSA id 20241008102315ecb55d46381941bb0b for ; Tue, 08 Oct 2024 12:23:15 +0200 X-Patchwork-Original-From: "alexander.heinisch via isar-users" From: "alexander.heinisch" To: isar-users@googlegroups.com Cc: jan.kiszka@siemens.com, quirin.gylstorff@siemens.com, Alexander Heinisch Subject: [PATCH 1/2] meta-isar: Added unattended mode for deploy-image-wic installer script. Date: Tue, 8 Oct 2024 12:22:34 +0200 Message-ID: <20241008102235.34078-2-alexander.heinisch@siemens.com> In-Reply-To: <20241008102235.34078-1-alexander.heinisch@siemens.com> References: <20241008102235.34078-1-alexander.heinisch@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1326448:519-21489:flowmailer X-Original-Sender: alexander.heinisch@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=nv1or8T2; spf=pass (google.com: domain of fm-1326448-20241008102315ecb55d46381941bb0b-pl2cdj@rts-flowmailer.siemens.com designates 185.136.64.225 as permitted sender) smtp.mailfrom=fm-1326448-20241008102315ecb55d46381941bb0b-pl2cDJ@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: alexander.heinisch@siemens.com Reply-To: alexander.heinisch@siemens.com 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: Alexander Heinisch In some cases (e.g. automated mass rollouts for precomissioning devices) it is valueable to not rely on a screen and a keyboard to deploy the target images on the device. Therefore, extended on the auto.install patch to allow for completely unattended installations. In addition to the auto.install file to provide configuration for the installer we added support for the kernel cmdline. - installer.unattended - installer.image.uri ...file name of the image to be installed (parameter name uri chosen since we plan to support download of images in upcoming patches) - installer.target.dev ...target device name (e.g. /dev/sda) for the image to be installed to - installer.target.overwrite ...strategy how to handle target devices not empty (possible values: OVERWRITE - overwrite data on target | ABORT - abort installation if target not empty) This introduces a **Breaking change!** This patch changes behaviour since when auto.install is found the script is assumed to run unattended. That means no dialogs are shown and no user interaction is enforced! It also requires all the configurations to be in place and valid when such file is provided! Signed-off-by: Alexander Heinisch --- .../deploy-image/deploy-image_0.1.bb | 7 +- .../files/{ => usr/bin}/deploy-image-wic.sh | 76 ++++++++++------- .../usr/lib/deploy-image-wic/handle-config.sh | 83 +++++++++++++++++++ 3 files changed, 134 insertions(+), 32 deletions(-) rename meta-isar/recipes-installer/deploy-image/files/{ => usr/bin}/deploy-image-wic.sh (71%) mode change 100644 => 100755 create mode 100644 meta-isar/recipes-installer/deploy-image/files/usr/lib/deploy-image-wic/handle-config.sh 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 fe524e52..242ca88e 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 @@ -7,11 +7,14 @@ DESCRIPTION = "Install image to device" inherit dpkg-raw -SRC_URI = "file://deploy-image-wic.sh \ +SRC_URI = "file://usr/bin/deploy-image-wic.sh \ + file://usr/lib/deploy-image-wic/handle-config.sh \ " DEBIAN_DEPENDS = "bmap-tools, pv, dialog, util-linux, parted, fdisk, gdisk, pigz, xz-utils, pbzip2, zstd" do_install[cleandirs] = "${D}/usr/bin/ \ + ${D}/usr/lib/deploy-image-wic \ " do_install() { - install -m 0755 ${WORKDIR}/deploy-image-wic.sh ${D}/usr/bin/deploy-image-wic.sh + install -m 0755 ${WORKDIR}/usr/bin/deploy-image-wic.sh ${D}/usr/bin/deploy-image-wic.sh + install -m 0755 ${WORKDIR}/usr/lib/deploy-image-wic/handle-config.sh ${D}/usr/lib/deploy-image-wic/handle-config.sh } diff --git a/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh old mode 100644 new mode 100755 similarity index 71% rename from meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh rename to meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh index 95188fe3..108a5975 --- a/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh +++ b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh @@ -6,21 +6,18 @@ installdata=${INSTALL_DATA:-/install} -AUTO_INSTALL=false -OVERWRITE= - -if [ -f "$installdata/auto.install" ]; then - exec 3<"$installdata/auto.install" - read -r DISK_IMAGE <&3 - read -r TARGET_DEVICE <&3 - read -r OVERWRITE <&3 - exec 3>&- - if [ ! -b ${TARGET_DEVICE} ]; then - dialog --msgbox "Target device is not a valid block device. Installation aborted." 6 60 - exit 1 - fi - AUTO_INSTALL=true -else +SCRIPT_DIR=$( dirname -- "$( readlink -f -- "$0"; )"; ) + +. ${SCRIPT_DIR}/../lib/deploy-image-wic/handle-config.sh + + +# Map config params +AUTO_INSTALL=${installer_unattended} +DISK_IMAGE=${installer_image_uri} +TARGET_DEVICE=${installer_target_dev} +OVERWRITE=${installer_target_overwrite} + +if ! $AUTO_INSTALL; then DISK_IMAGE=$(find "$installdata" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;) if [ -z "$DISK_IMAGE" ] || [ ! -f "$installdata/$DISK_IMAGE" ]; then pushd "$installdata" @@ -36,16 +33,14 @@ else fi fi fi -fi -if [ ! -f "$installdata/$DISK_IMAGE" ]; then - dialog --msgbox "Could not find an image to install. Installation aborted." 6 60 - exit 1 -fi -DISK_BMAP=$(find "$installdata" -type f -iname "${DISK_IMAGE%.wic*}.wic.bmap") -# inspired by poky/meta/recipes-core/initrdscripts/files/install-efi.sh + if [ ! -f "$installdata/$DISK_IMAGE" ]; then + dialog --msgbox "Could not find an image to install. Installation aborted." 6 60 + exit 1 + fi + DISK_BMAP=$(find "$installdata" -type f -iname "${DISK_IMAGE%.wic*}.wic.bmap") -if ! $AUTO_INSTALL; then + # inspired by poky/meta/recipes-core/initrdscripts/files/install-efi.sh target_device_list="" current_root_dev_type=$(findmnt / -o fstype -n) if [ ${current_root_dev_type} = "nfs" ]; then @@ -126,25 +121,46 @@ if ! $AUTO_INSTALL; then --yesno "Start installing\n'$DISK_IMAGE'\nto $TARGET_DEVICE (capacity: $TARGET_DEVICE_SIZE)" 7 60; then exit 0 fi + + # set absolute paths to be compatible with unattended mode + DISK_IMAGE="$installdata/$DISK_IMAGE" + + if [ -z "$DISK_BMAP" ]; then + DISK_BMAP="$installdata/$DISK_BMAP" + fi fi -if [ "$OVERWRITE" != "OVERWRITE" ] && ! cmp /dev/zero "$TARGET_DEVICE" -n 1M && \ - ! dialog --defaultno \ - --yesno "WARNING: Target device is not empty! Continue anyway?" 5 60; then - exit 0 +if ! cmp /dev/zero "$TARGET_DEVICE" -n 1M; then + if ! $AUTO_INSTALL && \ + ! dialog --defaultno \ + --yesno "WARNING: Target device is not empty! Continue anyway?" 5 60; then + exit 0 + else + if [ "$OVERWRITE" != "OVERWRITE" ]; then + echo "Target device is not empty! -> Abort" + echo "If you want to override existing data set \"installer_target_overwrite=OVERWRITE\"" + fi + fi fi bmap_options="" if [ -z "$DISK_BMAP" ]; then bmap_options="--nobmap" fi -clear -if ! bmaptool copy ${bmap_options} "$installdata/$DISK_IMAGE" "${TARGET_DEVICE}"; then + +if ! $AUTO_INSTALL; then + clear +fi + +if ! bmaptool copy ${bmap_options} "$DISK_IMAGE" "${TARGET_DEVICE}"; then exit 1 fi if ! $AUTO_INSTALL; then dialog --title "Reboot" \ - --msgbox "Installation is successful. System will be rebooted. Please remove the USB stick." 6 60 + --msgbox "Installation was successful. System will be rebooted. Please remove the USB stick." 6 60 +else + echo "Installation was successful." fi + exit 0 diff --git a/meta-isar/recipes-installer/deploy-image/files/usr/lib/deploy-image-wic/handle-config.sh b/meta-isar/recipes-installer/deploy-image/files/usr/lib/deploy-image-wic/handle-config.sh new file mode 100644 index 00000000..af37150e --- /dev/null +++ b/meta-isar/recipes-installer/deploy-image/files/usr/lib/deploy-image-wic/handle-config.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# This software is a part of ISAR. +# Copyright (C) Siemens AG, 2024 +# +# SPDX-License-Identifier: MIT + +installer_unattended=false +installer_image_uri= +installer_target_dev= +installer_target_overwrite= + +if [ -f "$installdata/auto.install" ]; then + exec 3<"$installdata/auto.install" + read -r installer_image_uri <&3 + read -r installer_target_dev <&3 + read -r installer_target_overwrite <&3 + exec 3>&- + + installer_unattended=true +fi + +# But let kernel cmdline overrule +for x in $(cat /proc/cmdline); do + case $x in + installer.unattended*) + installer_unattended=true + ;; + installer.image.uri=*) + installer_image_uri=${x#installer.image.uri=} + installer_unattended=true + ;; + installer.target.dev=*) + installer_target_dev=${x#installer.target.dev=} + installer_unattended=true + ;; + installer.target.overwrite*) + installer_target_overwrite="OVERWRITE" + installer_unattended=true + ;; + esac +done + +## Check config +all_values_set=false +if [ -n "${installer_image_uri}" ] && [ -n "${installer_target_dev}" ] && [ -n "${installer_target_overwrite}" ]; then + all_values_set=true +fi + +if ${installer_unattended} && ! ${all_values_set}; then + echo "When running in unattended mode all values needed for installation have to be set! -> Abort" + exit 1 +fi + +if ${installer_unattended}; then + echo "Got config:" + echo " installer_unattended=${installer_unattended}" + echo " installer_image_uri=${installer_image_uri}" + echo " installer_target_dev=${installer_target_dev}" + echo " installer_target_overwrite=${installer_target_overwrite}" + + case ${installer_target_overwrite} in + OVERWRITE|ABORT) + ;; + *) + echo "When running in unattended mode only \"installer_target_overwrite=OVERWRITE | ABORT\" is valid! You specified \"${installer_target_overwrite}\" -> Abort" + exit 1 + ;; + esac + + if [ ! -b ${installer_target_dev} ]; then + echo "Target device \"${installer_target_dev}\" is not a valid block device. -> Abort" + exit 1 + fi + + if [ ! -f "${installer_image_uri}" ]; then + if [ ! -f "$installdata/${installer_image_uri}" ]; then + echo "Could not find image file ${installer_image_uri} nor $installdata/${installer_image_uri} to install. -> Abort" + exit 1 + else + installer_image_uri=$installdata/${installer_image_uri} + fi + fi +fi From patchwork Tue Oct 8 10:22:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "alexander.heinisch" X-Patchwork-Id: 3856 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Tue, 08 Oct 2024 12:23:26 +0200 X-Sieve: CMU Sieve 2.4 Received: from mail-qt1-f188.google.com (mail-qt1-f188.google.com [209.85.160.188]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 498ANOXj023277 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 8 Oct 2024 12:23:25 +0200 Received: by mail-qt1-f188.google.com with SMTP id d75a77b69052e-45d94168de2sf113863001cf.2 for ; Tue, 08 Oct 2024 03:23:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1728382999; cv=pass; d=google.com; s=arc-20240605; b=RyjImrKOSbDOoGVEWoJoa4kaY+RxkevQ1BMliQ7CpZIUad1e30wf48NTzHtYbfxv71 G2b16/SCoMKhpKWbbwIlmCE1e7nucgn0N1sfykKekzOeGvjs6My2GGrSlzpB0UUOlhb8 IYxAcVCOMfLw12G+ciPnxNAxLYBAloNzq6z77mys/IJ94WWygH8+dDN7BI3ttYOKZu5O DeyownpWeUL07lBh6z0x8SPkmok2/+jWXEoKYNfQ0istEol841429IdhPK8GBXNdeZDk botqTD/4PPJr9reVkW+vB9m+wFx52VxgctHcywpoawoKKCs9VMu0ch6ZPb6Xsf8kvazg RwHQ== 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=xbrLM3XmID/wf6D1GmWV3GiXDEEy7u5jCiH/AtGsC+c=; fh=y09aqYxvR1mJuI5wh/rBk3QUYEGUEgFeqJ+CNaElGV8=; b=ch0PMM4+uPWQWA97E97iFx9YoZJSC1PF8WoFSHjTCs6BrkTvNXDSs0DMvmlMFT7IgI nJPGJd8rgYI6QKzcCknAi+8PIvF9BRQ5eF0Tz68Ck+fr5a+acddX9F913NBimPXeyshr 8UqwX2VQNbpoDUjpUIibcGnnog81z3N5/V7mhIZS7D5t/pXh3RJpWscgRT8wY3Hf45XT /vOkgP567TynyJ8RLSoIDJo4kKXhn4MwrenSKFlLLcNbln8r4tExOql7dSPceKJZ1PV1 FaWSNF75lh6Q5C66ycx5enit/vwVpNxyIIMb01BnzcRPm4pjG2wsQrdIIV0L2zPWnpfF Utdw==; darn=isar-build.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b="oF/Xw1S6"; spf=pass (google.com: domain of fm-1326448-20241008102316e23d00a67da423706e-mikmcd@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-1326448-20241008102316e23d00a67da423706e-mIkMCD@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=20230601; t=1728382999; x=1728987799; 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=xbrLM3XmID/wf6D1GmWV3GiXDEEy7u5jCiH/AtGsC+c=; b=s7gs959XnJdokhq0d+kYhfFoYm9zioMzpGuzHHxBkYigK5sLhukOVWpdOjrqN1MZmq NuowGXw9s0AEH28TMu3bH+t/+rDj9R56N6nuj5yWJU6HBmWYQ4/lfbq9Jwa4WuvXmz9G qYlyHn0erB45mpZ09iQ8ZPaB48RX+7a+K84uOGBinnS1SgcYcGvkZ1+PYGW5VHH0KOMM WCPs0+UtPRsQYXgDkGlYziV2nIN7i/SphiFNLsKLCoB/whfZFWm1IKh+pUIu0TU3v6Rk /f5kYYhrf/Xc8+NexSsrOmqHmNRv3FwXkyPGoF8SlJReb3cphUbUyQeJ8RAeg3+as3Zg oq9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728382999; x=1728987799; 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=xbrLM3XmID/wf6D1GmWV3GiXDEEy7u5jCiH/AtGsC+c=; b=MVWdyT37FhrN22oMix8sbWu6zOhBVWccF0T6KS54o4ojzif2pQJPZfg0tbvZ93392F s/Utqtarh862ucj87ooOI4XkVo8AGrQ9u5mj20VszHQdo5GDlmM+xlNfERhCYGHFd7Gl 8HbT71qetjONjLso0uohddWb20Q6ZY7xhdfcBrzELvUzTpbegIZakztUH4jQ2+8yrpG6 vVSCS2VLX1iKgHT8/3K0FEmCY8MQU4BiuRxcB/9ZZsd78YSrcLFf3/3URgZ1Jy+PNWVA zzpAJ+XGMq5+Vvyw1MqW2zjXj++pmntFUfoNssD3yiHVoxEYjcoz9KM3Nywc2KxmGwSE 8t9w== X-Forwarded-Encrypted: i=2; AJvYcCUEiix26DC5upUzyA3uogMMD2oLdgwUk309gl1misg6WZYLdfJd6QOjbMSzwxsP51E/HztOJGI=@isar-build.org X-Gm-Message-State: AOJu0Yx1rQySaNaE6CELDfuNwO5sFlKTqV1robIdrnkQJB+lJsYlunyc NTvkyMwO6NUDNPqcp+xtuNHLE4GusHQ5APWrVSa5jpHxNLEeaadN X-Google-Smtp-Source: AGHT+IFCm4XqkHCmqKpPNNZjx8koiiduCCO3vTEjo16Y3NUTurUjxc6cvEKkRk6QhvISVBSZA0IMhQ== X-Received: by 2002:a05:622a:199c:b0:458:59e3:2b4c with SMTP id d75a77b69052e-45d9ba5b20fmr249329021cf.24.1728382998718; Tue, 08 Oct 2024 03:23:18 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:ad4:5ae8:0:b0:6b5:da50:ac19 with SMTP id 6a1803df08f44-6cb902a9a61ls23942616d6.2.-pod-prod-07-us; Tue, 08 Oct 2024 03:23:18 -0700 (PDT) X-Received: by 2002:a05:6102:50a4:b0:4a3:aa99:5f07 with SMTP id ada2fe7eead31-4a4058f499dmr9349413137.23.1728382997981; Tue, 08 Oct 2024 03:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728382997; cv=none; d=google.com; s=arc-20240605; b=SPywGGRPGvD4N4M+vN/1dr0IEk3AalremGQLh/osgjqxtoR6NM1Jh4N+E/XkMLlJNN q9w+qm41Is/DB/ehV/ZFVLvz5hWqnFcPmMCT9XdPuUwd+85mB1KHedFcLlB8Psf6+fw0 uCWHycsjudUkkNSZ4mWjvRFU23WmYNIor2l/0KaFC8sM7uKjk2lU6jAMufRCBoUO9aCH sb2XbNkH3CnYob/qtyEoH0r4UFnUGP3xk1D6aE96WJiMX9SUkxDQaz3afdYrV3oSZNOt QlDVWhM8xXIxLdWw83RZajz38OZm1gxVMtBUBnrktRndGTw7t2jBtXtn2JI5+gENAiHu 8TkA== 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=Ux8R2yxdx8q7M5EH9+TkDAwKA6zovq3Gci+iAA2AlUQ=; fh=lKRNNdAU0IICONvfa+KjpneoIxBGWimmAGb9Xm7u9s8=; b=HKAjJw/7nAHIQrVchkha/7YfcoEZzHWnth1XI4EAg+8udDJ0/RkPQsENelF0I0uzI+ 7ThpBZt+W4u2mfTW7ShrSc40WVGR5fR84veBa1q87XTrKuJ8L6RlxpeoqOOzuBEWUcsl u2en+tqIXCp+xmmQEWTWlq/kA4dQitDW3STCLGvP7O6SXYeWa/Tlv9Z66Ahrc9FM9XSV gOiNEnXH+Jr2s2jLsaxH9p+hKY1p/dbQVwQb46/PBZ8SkhMcEU1C5c02CW2eixHp9Sk5 JIvqM+nk89HSpNchdRt87evq3ixNirYuV8USohz/eDzMYoY5b6bszjWuAkohvWIy0p6N OjVQ==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b="oF/Xw1S6"; spf=pass (google.com: domain of fm-1326448-20241008102316e23d00a67da423706e-mikmcd@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-1326448-20241008102316e23d00a67da423706e-mIkMCD@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 ada2fe7eead31-4a412c92906si367807137.0.2024.10.08.03.23.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2024 03:23:17 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-1326448-20241008102316e23d00a67da423706e-mikmcd@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 20241008102316e23d00a67da423706e for ; Tue, 08 Oct 2024 12:23:16 +0200 X-Patchwork-Original-From: "alexander.heinisch via isar-users" From: "alexander.heinisch" To: isar-users@googlegroups.com Cc: jan.kiszka@siemens.com, quirin.gylstorff@siemens.com, Alexander Heinisch Subject: [PATCH 2/2] meta-isar: Unified variable names in deploy-image script. Date: Tue, 8 Oct 2024 12:22:35 +0200 Message-ID: <20241008102235.34078-3-alexander.heinisch@siemens.com> In-Reply-To: <20241008102235.34078-1-alexander.heinisch@siemens.com> References: <20241008102235.34078-1-alexander.heinisch@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1326448:519-21489:flowmailer X-Original-Sender: alexander.heinisch@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b="oF/Xw1S6"; spf=pass (google.com: domain of fm-1326448-20241008102316e23d00a67da423706e-mikmcd@rts-flowmailer.siemens.com designates 185.136.65.226 as permitted sender) smtp.mailfrom=fm-1326448-20241008102316e23d00a67da423706e-mIkMCD@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: alexander.heinisch@siemens.com Reply-To: alexander.heinisch@siemens.com 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: Alexander Heinisch Unified shell variable names between deploy image config handling and actual deploy script. renamed AUTO_INSTALL to installer_unattended renamed DISK_IMAGE to installer_image_uri renamed TARGET_DEVICE to installer_target_dev renamed OVERWRITE to installer_target_overwrite Signed-off-by: Alexander Heinisch --- .../files/usr/bin/deploy-image-wic.sh | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh index 108a5975..e6ee426d 100755 --- a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh +++ b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh @@ -11,22 +11,16 @@ SCRIPT_DIR=$( dirname -- "$( readlink -f -- "$0"; )"; ) . ${SCRIPT_DIR}/../lib/deploy-image-wic/handle-config.sh -# Map config params -AUTO_INSTALL=${installer_unattended} -DISK_IMAGE=${installer_image_uri} -TARGET_DEVICE=${installer_target_dev} -OVERWRITE=${installer_target_overwrite} - -if ! $AUTO_INSTALL; then - DISK_IMAGE=$(find "$installdata" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;) - if [ -z "$DISK_IMAGE" ] || [ ! -f "$installdata/$DISK_IMAGE" ]; then +if ! $installer_unattended; then + installer_image_uri=$(find "$installdata" -type f -iname "*.wic*" -a -not -iname "*.wic.bmap" -exec basename {} \;) + if [ -z "$installer_image_uri" ] || [ ! -f "$installdata/$installer_image_uri" ]; then pushd "$installdata" for f in $(find . -type f); do array+=("$f" "$f") done popd if [ ${#array[@]} -gt 0 ]; then - if ! DISK_IMAGE=$(dialog --no-tags \ + if ! installer_image_uri=$(dialog --no-tags \ --menu "Select image to be installed" 10 60 3 \ "${array[@]}" --output-fd 1); then exit 0 @@ -34,11 +28,11 @@ if ! $AUTO_INSTALL; then fi fi - if [ ! -f "$installdata/$DISK_IMAGE" ]; then + if [ ! -f "$installdata/$installer_image_uri" ]; then dialog --msgbox "Could not find an image to install. Installation aborted." 6 60 exit 1 fi - DISK_BMAP=$(find "$installdata" -type f -iname "${DISK_IMAGE%.wic*}.wic.bmap") + DISK_BMAP=$(find "$installdata" -type f -iname "${installer_image_uri%.wic*}.wic.bmap") # inspired by poky/meta/recipes-core/initrdscripts/files/install-efi.sh target_device_list="" @@ -108,37 +102,37 @@ if ! $AUTO_INSTALL; then fi array+=("/dev/$target" "/dev/$target ($target_size, $state)") done - if ! TARGET_DEVICE=$(dialog --no-tags \ + if ! installer_target_dev=$(dialog --no-tags \ --menu "Select device to install image to" 10 60 3 \ "${array[@]}" --output-fd 1); then exit 0 fi else - TARGET_DEVICE=/dev/$(echo "$target_device_list" | tr -d " ") + installer_target_dev=/dev/$(echo "$target_device_list" | tr -d " ") fi - TARGET_DEVICE_SIZE=$(lsblk --nodeps --noheadings -o SIZE "$TARGET_DEVICE" | tr -d " ") + TARGET_DEVICE_SIZE=$(lsblk --nodeps --noheadings -o SIZE "$installer_target_dev" | tr -d " ") if ! dialog --yes-label Ok --no-label Cancel \ - --yesno "Start installing\n'$DISK_IMAGE'\nto $TARGET_DEVICE (capacity: $TARGET_DEVICE_SIZE)" 7 60; then + --yesno "Start installing\n'$installer_image_uri'\nto $installer_target_dev (capacity: $TARGET_DEVICE_SIZE)" 7 60; then exit 0 fi # set absolute paths to be compatible with unattended mode - DISK_IMAGE="$installdata/$DISK_IMAGE" + installer_image_uri="$installdata/$installer_image_uri" if [ -z "$DISK_BMAP" ]; then DISK_BMAP="$installdata/$DISK_BMAP" fi fi -if ! cmp /dev/zero "$TARGET_DEVICE" -n 1M; then - if ! $AUTO_INSTALL && \ +if ! cmp /dev/zero "$installer_target_dev" -n 1M; then + if ! $installer_unattended && \ ! dialog --defaultno \ --yesno "WARNING: Target device is not empty! Continue anyway?" 5 60; then exit 0 else - if [ "$OVERWRITE" != "OVERWRITE" ]; then + if [ "$installer_target_overwrite" != "installer_target_overwrite" ]; then echo "Target device is not empty! -> Abort" - echo "If you want to override existing data set \"installer_target_overwrite=OVERWRITE\"" + echo "If you want to override existing data set \"installer_target_overwrite=installer_target_overwrite\"" fi fi fi @@ -148,15 +142,15 @@ if [ -z "$DISK_BMAP" ]; then bmap_options="--nobmap" fi -if ! $AUTO_INSTALL; then +if ! $installer_unattended; then clear fi -if ! bmaptool copy ${bmap_options} "$DISK_IMAGE" "${TARGET_DEVICE}"; then +if ! bmaptool copy ${bmap_options} "$installer_image_uri" "${installer_target_dev}"; then exit 1 fi -if ! $AUTO_INSTALL; then +if ! $installer_unattended; then dialog --title "Reboot" \ --msgbox "Installation was successful. System will be rebooted. Please remove the USB stick." 6 60 else