From patchwork Tue Oct 15 11:34:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez via B4 Relay X-Patchwork-Id: 13836231 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA3E81EABC6 for ; Tue, 15 Oct 2024 11:35:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728992111; cv=none; b=OlfmpXioehwtMz2lvdb6Bgf4Y7otPOB1ndslRfdP5RzITZeCzpQk1sEBxyrTWvSVkXBXs4slvgvVN2xedZ4ziQG9uXG6NEg/X6zfUAyWJ0qi5xYHdoCik7yqFejyDRVSTNGuZvdz9F8dDefHijuR+60FWifqQxyxN5jZFcdHhCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728992111; c=relaxed/simple; bh=Hcn6dP383vkZPL63xHaVBCH2TgFTuSXdQgqEtIOd93g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V6fHJcv5zKGHceX0pQDF48fLbL3mQHSo9KfBBSiLmqu6Nv81SJmJekh6Gqe1PjdCcyZxdUANRIXrhqyEe3NMEUH+9YDG3mZ72cPnSW37YMlKhlMSUZQbxQI4OMY+8ql6Y40+3gdGh4qqkIlJtS4J+jAcBqKqjNLm2ufdj7AItnE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lX7E5b+o; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lX7E5b+o" Received: by smtp.kernel.org (Postfix) with ESMTPS id 9D150C4CECF; Tue, 15 Oct 2024 11:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728992110; bh=Hcn6dP383vkZPL63xHaVBCH2TgFTuSXdQgqEtIOd93g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=lX7E5b+oBFSE/J7h0oqvNIZzoThZmgks0vi/rV7QHFQhkNIKCqPCGvHQRd3KfIdLK HvMVPORUCYHEMMGW8dSbF0O2REdK+ONflUnT9h1HLTzRwtTbp/Pvpb9T3XfNs7Juq5 oCjnReJSKKX1UA+kGWvcWYCmToasmlsg8ib+9ff0JZZbpbfCHMLeVsm5JrAQSRh2E1 Tm0hD8rSlu7Qrx+u0uuZKtfLqGG1dG6/JoDqLYbJRJVjBkeMiL2jOCcvJXw97t/CgV x+d0Mh7hoicxAtLssB/mkBq90zSQBbPeavk6hDkpDFfIspmLTJi4Zj+ZsES0F7C6eT yPzDjVKlrIQdA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93EF8CFC28F; Tue, 15 Oct 2024 11:35:10 +0000 (UTC) From: Daniel Gomez via B4 Relay Date: Tue, 15 Oct 2024 13:34:53 +0200 Subject: [PATCH 3/5] guestfs: bringup: fix unbound variable when debug Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241015-bringup-guestfs-debug-v1-3-bd74c0c31412@samsung.com> References: <20241015-bringup-guestfs-debug-v1-0-bd74c0c31412@samsung.com> In-Reply-To: <20241015-bringup-guestfs-debug-v1-0-bd74c0c31412@samsung.com> To: kdevops@lists.linux.dev, Luis Chamberlain Cc: "Daniel Gomez (Samsung)" , Daniel Gomez X-Mailer: b4 0.15-dev-2a633 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728992109; l=2993; i=da.gomez@samsung.com; s=20240621; h=from:subject:message-id; bh=mFkyyCRh3HwHjMp/IgHLJ4cqQP62CHIqv6gemSsgnE8=; b=Jt/kkJEI6ktLXMUtu1kKbL9M140AoCagJnhw3VfAVlHEtiL2SxIuNt5E0To1Ol6iDoUWfLcY8 1U59PJP/+2XDtAhD54ADhpDvO67zIckcSza95emHl4q/xeaLiSv9OQw X-Developer-Key: i=da.gomez@samsung.com; a=ed25519; pk=BqYk31UHkmv0WZShES6pIZcdmPPGay5LbzifAdZ2Ia4= X-Endpoint-Received: by B4 Relay for da.gomez@samsung.com/20240621 with auth_id=175 X-Original-From: Daniel Gomez Reply-To: da.gomez@samsung.com From: Daniel Gomez Fix unbound variable errors. This is a silent error only found while debugging. A variable may not be set, so check if set before comparing the value to avoid 'unbound variable' error. ++ mktemp + cmdfile=/tmp/tmp.cn0hNYMZbt + '[' '!' -f /var/lib/libvirt/images/kdevops/guestfs/base_images/debian-12.raw ']' .//scripts/bringup_guestfs.sh: line 289: CONFIG_GUESTFS_HAS_CUSTOM_RAW_IMAGE: unbound variable make: *** [scripts/guestfs.Makefile:77: bringup_guestfs] Error 1 Signed-off-by: Daniel Gomez --- scripts/bringup_guestfs.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/bringup_guestfs.sh b/scripts/bringup_guestfs.sh index 5786975e48647321ecbc71ca9be6fb09c8aa63ff..19117e9a6ab55cfbe7c79f17e4a9b736edeb2607 100755 --- a/scripts/bringup_guestfs.sh +++ b/scripts/bringup_guestfs.sh @@ -242,7 +242,7 @@ _EOT # For the life of me I can't get the following line to work with # the virt-builder command and so we do a full edit of the file for now # edit /etc/nsswitch.conf:'s/\[!UNAVAIL=return\]//' - if [[ "$CONFIG_GUESTFS_DEBIAN_TRIXIE" == "y" ]]; then + if [[ "${CONFIG_GUESTFS_DEBIAN_TRIXIE+x}" && "$CONFIG_GUESTFS_DEBIAN_TRIXIE" == "y" ]]; then cat <<_EOT >>$cmdfile write /etc/nsswitch.conf: # kdevops generated /etc/nsswitch.conf append-line /etc/nsswitch.conf:passwd: files @@ -266,7 +266,7 @@ firstboot-command DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=tru firstboot-command systemctl stop ssh firstboot-command systemctl start ssh _EOT - if [[ "$CONFIG_GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST" == "y" ]]; then + if [[ "${CONFIG_GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST+x}" && "$CONFIG_GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST" == "y" ]]; then cat <<_EOT >>$cmdfile delete /etc/apt/sources.list.d/debian.sources _EOT @@ -292,7 +292,7 @@ fi cmdfile=$(mktemp) if [ ! -f $BASE_IMAGE ]; then - if [[ "$CONFIG_GUESTFS_HAS_CUSTOM_RAW_IMAGE" == "y" ]]; then + if [[ "${CONFIG_GUESTFS_HAS_CUSTOM_RAW_IMAGE+x}" && "$CONFIG_GUESTFS_HAS_CUSTOM_RAW_IMAGE" == "y" ]]; then build_custom_image fi @@ -305,7 +305,7 @@ if [ ! -f $BASE_IMAGE ]; then copy_yum_repo fi - if [[ "$CONFIG_GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST" == "y" ]]; then + if [[ "${CONFIG_GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST+x}" && "$CONFIG_GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST" == "y" ]]; then copy_host_sources fi @@ -360,7 +360,7 @@ do TZ="$(timedatectl show -p Timezone --value)" $USE_SUDO virt-sysprep -a $ROOTIMG --hostname $name --ssh-inject "kdevops:file:$SSH_KEY.pub" --timezone $TZ - if [[ "$CONFIG_LIBVIRT_ENABLE_LARGEIO" == "y" ]]; then + if [[ "${CONFIG_LIBVIRT_ENABLE_LARGEIO+x}" && "$CONFIG_LIBVIRT_ENABLE_LARGEIO" == "y" ]]; then lbs_idx=0 for i in $(seq 1 $(($CONFIG_QEMU_LARGEIO_MAX_POW_LIMIT+1))); do for x in $(seq 0 $CONFIG_QEMU_EXTRA_DRIVE_LARGEIO_NUM_DRIVES_PER_SPACE); do