Merge #434 Replace mount/umount cmds with libguestfs tools

This commit is contained in:
Lubomír Sedlář 2016-10-24 07:52:29 +00:00
commit e02ed6c04b
3 changed files with 9 additions and 4 deletions

View File

@ -37,6 +37,7 @@ Requires: gettext
Requires: syslinux
Requires: git
Requires: python-jsonschema
Requires: libguestfs-tools-c
BuildArch: noarch

View File

@ -253,7 +253,9 @@ def tweak_buildinstall(src, dst, arch, variant, label, volid, kickstart_file=Non
if not os.path.isfile(image):
continue
mount_tmp_dir = tempfile.mkdtemp(prefix="tweak_buildinstall")
cmd = ["mount", "-o", "loop", image, mount_tmp_dir]
# use guestmount to mount the image, which doesn't require root privileges
# LIBGUESTFS_BACKEND=direct: running qemu directly without libvirt
cmd = ["LIBGUESTFS_BACKEND=direct", "guestmount", "-a", image, "-m", "/dev/sda", mount_tmp_dir]
run(cmd)
for config in configs:
@ -264,7 +266,7 @@ def tweak_buildinstall(src, dst, arch, variant, label, volid, kickstart_file=Non
cmd = ["cp", "-v", "--remove-destination", config_path, config_in_image]
run(cmd)
cmd = ["umount", mount_tmp_dir]
cmd = ["fusermount", "-u", mount_tmp_dir]
run(cmd)
shutil.rmtree(mount_tmp_dir)

View File

@ -138,7 +138,9 @@ def create_product_img(compose, arch, variant):
"dd if=/dev/zero of=%s bs=1k count=5760" % pipes.quote(image),
# create file system
"mke2fs -F %s" % pipes.quote(image),
"mount -o loop %s %s" % (pipes.quote(image), pipes.quote(mount_tmp)),
# use guestmount to mount the image, which doesn't require root privileges
# LIBGUESTFS_BACKEND=direct: running qemu directly without libvirt
"LIBGUESTFS_BACKEND=direct guestmount -a %s -m /dev/sda %s" % (pipes.quote(image), pipes.quote(mount_tmp)),
"mkdir -p %s/run/install/product" % pipes.quote(mount_tmp),
"cp -rp %s/* %s/run/install/product/" % (pipes.quote(product_tmp), pipes.quote(mount_tmp)),
"mkdir -p %s/run/install/product/pyanaconda" % pipes.quote(mount_tmp),
@ -148,7 +150,7 @@ def create_product_img(compose, arch, variant):
"ln -s run/install/product/locale %s" % pipes.quote(mount_tmp),
# compat symlink: run/install/product/pyanaconda/installclasses -> ../installclasses
"ln -s ../installclasses %s/run/install/product/pyanaconda/installclasses" % pipes.quote(mount_tmp),
"umount %s" % pipes.quote(mount_tmp),
"fusermount -u %s" % pipes.quote(mount_tmp),
# tweak last mount path written in the image
"tune2fs -M /run/install/product %s" % pipes.quote(image),
]