Skip to content

Commit 027f05b

Browse files
authored
VM: Replace __EOF__ commands with echo (#8)
Some __EOF__ commands does not work in certain environments, this commit replace them with echo commands which are safer.
1 parent 4986899 commit 027f05b

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

lib/rift/VM.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,6 @@ def prepare(self):
425425
repos.append(f"proxy={repo.proxy}\n")
426426

427427
# Build the full command line
428-
429428
def joinl(items):
430429
"""
431430
Join list of strings with new line character. This inner function is
@@ -434,32 +433,31 @@ def joinl(items):
434433
"""
435434
return "\n".join(items)
436435

436+
# Construct the command to write fstab entries
437+
fstab_cmd = joinl([f'echo "{line}" >> /etc/fstab' for line in fstab])
438+
437439
cmd = textwrap.dedent(f"""
438440
# Static host resolution
439441
echo '{self.address} {self.NAME}' >> /etc/hosts
440442
441443
echo '{userline}' >> /etc/passwd
442444
echo '{groupline}' >> /etc/group
443-
445+
446+
# Mount shared fs (9p, virtiofs,...)
444447
mkdir {' '.join(mkdirs)}
445-
cat <<__EOF__ >>/etc/fstab
446-
{joinl(fstab)}
447-
__EOF__
448+
{fstab_cmd}
448449
mount -t {self.shared_fs_type} -a
449450
451+
# Uses repos from the Rift configuration
450452
/bin/rm -f /etc/yum.repos.d/*.repo
451-
452-
cat <<__EOC__ >/etc/yum.repos.d/rift.repo
453-
{joinl(repos)}
454-
__EOC__
453+
echo "{joinl(repos)}" > /etc/yum.repos.d/rift.repo
455454
456455
if [ -x /usr/bin/dnf ] ; then
457456
dnf -d1 makecache
458457
else
459458
yum -d1 makecache fast
460459
fi
461-
462-
""")
460+
""")
463461
self.cmd(cmd)
464462

465463
def cmd(self, command=None, options=('-T',), **kwargs):

0 commit comments

Comments
 (0)