Move mounting of special partitions from grub to mount

main
Aurélien Gâteau 11 years ago
parent 8867f6bc67
commit 0946789f9e

@ -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

@ -4,13 +4,3 @@ interface: "python"
requires: []
script: "main.py"
configuration:
extraMounts:
- device: proc
fs: proc
mountPoint: /proc
- device: sys
fs: sysfs
mountPoint: /sys
- device: /dev
mountPoint: /dev
options: bind

@ -54,11 +54,13 @@ def mount_partitions(root_mount_point, partitions):
def run():
root_mount_point = tempfile.mkdtemp(prefix="calamares-root-")
partitions = libcalamares.globalstorage.value("partitions")
extra_mounts = libcalamares.job.configuration["extraMounts"]
# Sort by mount points to ensure / is mounted before the rest
partitions.sort(key=lambda x: x["mountPoint"])
mount_partitions(
root_mount_point, libcalamares.globalstorage.value("partitions"))
mount_partitions(root_mount_point, partitions)
mount_partitions(root_mount_point, extra_mounts)
libcalamares.globalstorage.insert("rootMountPoint", root_mount_point)
return None

@ -4,3 +4,13 @@ interface: "python"
requires: []
script: "main.py"
configuration:
extraMounts:
- device: proc
fs: proc
mountPoint: /proc
- device: sys
fs: sysfs
mountPoint: /sys
- device: /dev
mountPoint: /dev
options: bind

Loading…
Cancel
Save