Here-documents break the indentation of the script; replace them with the
"printf" shell utility. (We could use the <<- redirection operator for
stripping leading TABs from the here-docs, but the script itself does not
use TABs for indentation, so that would introduce a different kind of
inconsistency.)
Because we use a quoted word ('EOF') for our delimiter in the
here-documents, variables in the here-docs are not expanded; stick with
that.
Use a sole '%s\n' format operand with each printf invocation: "[t]he
/format/ operand shall be reused as often as necessary to satisfy the
/argument/ operands"
<
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html>.
(I've tried to regression-test this with the two latest Ubuntu images:
ubuntu-18.04, ubuntu-20.04. The former wouldn't build, and the latter only
booted to a GDM login screen. My build host is RHEL-9.1, so the kiosk is
not actually expected to work. Any further investigation here is left to
Ubuntu users.
The Fedora 37 image works fine, even with the virt-p2v binary coming from
RHEL-9.1.)
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
---
virt-p2v-make-disk.in | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/virt-p2v-make-disk.in b/virt-p2v-make-disk.in
index 44ff0b45ac7a..0bf7f0e0414f 100644
--- a/virt-p2v-make-disk.in
+++ b/virt-p2v-make-disk.in
@@ -170,15 +170,15 @@ xzcat "$virt_p2v_xz_binary" >
"$virt_p2v_binary"
case "$osversion" in
centos-*|fedora-*|rhel-*|scientificlinux-*|oraclelinux-*)
depsfile="$datadir/dependencies.redhat"
- cat > $tmpdir/p2v.conf <<'EOF'
-add_drivers+=" usb-storage "
-EOF
- cat > $tmpdir/post-install <<'EOF'
-#!/bin/bash
-# Rebuild the initramfs.
-latest_version="$(cd /lib/modules; ls -1vr | head -1)"
-dracut -v -f --kver $latest_version
-EOF
+ printf '%s\n' \
+ 'add_drivers+=" usb-storage "' \
+ > $tmpdir/p2v.conf
+ printf '%s\n' \
+ '#!/bin/bash' \
+ '# Rebuild the initramfs.' \
+ 'latest_version="$(cd /lib/modules; ls -1vr | head -1)"' \
+ 'dracut -v -f --kver $latest_version' \
+ > $tmpdir/post-install
# Double quotes because we want $tmpdir to be expanded:
extra_args="
--selinux-relabel
@@ -201,11 +201,11 @@ EOF
;;
debian-*|ubuntu-*)
depsfile="$datadir/dependencies.debian"
- cat > $tmpdir/policy-rc.d <<'EOF'
-#!/bin/sh
-# Avoid running daemons during the upgrade/installation
-exit 101
-EOF
+ printf '%s\n' \ \
+ '#!/bin/sh' \
+ '# Avoid running daemons during the upgrade/installation' \
+ 'exit 101' \
+ > $tmpdir/policy-rc.d
chmod +x $tmpdir/policy-rc.d
# Double quotes because we want $tmpdir to be expanded:
preinstall_args="