From: Daniel Gomez <da.gomez@kernel.org>
To: kdevops@lists.linux.dev, Luis Chamberlain <mcgrof@kernel.org>,
Daniel Gomez <da.gomez@samsung.com>
Cc: Daniel Gomez <da.gomez@kernel.org>
Subject: [PATCH v2 2/4] guestfs: bringup: fix unbound variable when debug
Date: Mon, 12 May 2025 15:36:03 +0200 [thread overview]
Message-ID: <20250512-bringup-guestfs-debug-v2-2-bd5691108448@samsung.com> (raw)
In-Reply-To: <20250512-bringup-guestfs-debug-v2-0-bd5691108448@samsung.com>
From: Daniel Gomez <da.gomez@samsung.com>
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 <da.gomez@samsung.com>
---
scripts/bringup_guestfs.sh | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/scripts/bringup_guestfs.sh b/scripts/bringup_guestfs.sh
index 1d377faf387888a4523a838fd292654e5deddd82..3681423eff2849bc63519641ad09d974d421589a 100755
--- a/scripts/bringup_guestfs.sh
+++ b/scripts/bringup_guestfs.sh
@@ -234,7 +234,8 @@ _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
@@ -258,7 +259,8 @@ 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
@@ -274,7 +276,8 @@ 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
@@ -287,7 +290,8 @@ 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
@@ -342,7 +346,8 @@ 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
--
2.49.0
next prev parent reply other threads:[~2025-05-12 13:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 13:36 [PATCH v2 0/4] guestfs: bringup: add debug mode Daniel Gomez
2025-05-12 13:36 ` [PATCH v2 1/4] guestfs: bringup: check if domain exists Daniel Gomez
2025-05-12 13:36 ` Daniel Gomez [this message]
2025-05-12 13:36 ` [PATCH v2 3/4] guestfs: bringup: fix user check when debug Daniel Gomez
2025-05-12 13:36 ` [PATCH v2 4/4] guestfs: bringup: add debug mode Daniel Gomez
2025-05-12 15:43 ` [PATCH v2 0/4] " Chuck Lever
2025-05-13 5:49 ` Daniel Gomez
2025-05-14 18:28 ` Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250512-bringup-guestfs-debug-v2-2-bd5691108448@samsung.com \
--to=da.gomez@kernel.org \
--cc=da.gomez@samsung.com \
--cc=kdevops@lists.linux.dev \
--cc=mcgrof@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox