|
|
|
@ -23,40 +23,6 @@ import subprocess
|
|
|
|
|
import libcalamares
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# FIXME: Duplicated between mount and grub
|
|
|
|
|
def mount(device_path, mount_point, fs=None, options=None):
|
|
|
|
|
assert device_path
|
|
|
|
|
assert mount_point
|
|
|
|
|
if not os.path.exists(mount_point):
|
|
|
|
|
os.makedirs(mount_point)
|
|
|
|
|
cmd = ["mount", device_path, mount_point]
|
|
|
|
|
if fs:
|
|
|
|
|
cmd += ("-t", fs)
|
|
|
|
|
if options:
|
|
|
|
|
cmd += ("-o", options)
|
|
|
|
|
subprocess.check_call(cmd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mount_partitions(root_mount_point, partitions):
|
|
|
|
|
for partition in partitions:
|
|
|
|
|
if not partition["mountPoint"]:
|
|
|
|
|
continue
|
|
|
|
|
# Create mount point with `+` rather than `os.path.join()` because
|
|
|
|
|
# `partition["mountPoint"]` starts with a '/'.
|
|
|
|
|
mount_point = root_mount_point + partition["mountPoint"]
|
|
|
|
|
mount(partition["device"], mount_point,
|
|
|
|
|
fs=partition.get("fs"),
|
|
|
|
|
options=partition.get("options")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def umount_partitions(root_mount_point, partitions):
|
|
|
|
|
for partition in partitions:
|
|
|
|
|
if not partition["mountPoint"]:
|
|
|
|
|
continue
|
|
|
|
|
subprocess.call(["umount", root_mount_point + partition["mountPoint"]])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def chroot_call(root_mount_point, cmd):
|
|
|
|
|
subprocess.check_call(["chroot", root_mount_point] + cmd)
|
|
|
|
|
|
|
|
|
@ -70,10 +36,5 @@ def install_grub(root_mount_point, boot_loader):
|
|
|
|
|
def run():
|
|
|
|
|
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
|
|
|
|
boot_loader = libcalamares.globalstorage.value("bootLoader")
|
|
|
|
|
extra_mounts = libcalamares.job.configuration["extraMounts"]
|
|
|
|
|
mount_partitions(root_mount_point, extra_mounts)
|
|
|
|
|
try:
|
|
|
|
|
install_grub(root_mount_point, boot_loader)
|
|
|
|
|
finally:
|
|
|
|
|
umount_partitions(root_mount_point, extra_mounts)
|
|
|
|
|
install_grub(root_mount_point, boot_loader)
|
|
|
|
|
return None
|
|
|
|
|