Skip to content
Snippets Groups Projects
Commit 0946789f authored by Aurélien Gâteau's avatar Aurélien Gâteau
Browse files

Move mounting of special partitions from grub to mount

parent 8867f6bc
Branches
Tags
No related merge requests found
...@@ -23,40 +23,6 @@ import subprocess ...@@ -23,40 +23,6 @@ import subprocess
import libcalamares 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): def chroot_call(root_mount_point, cmd):
subprocess.check_call(["chroot", root_mount_point] + cmd) subprocess.check_call(["chroot", root_mount_point] + cmd)
...@@ -70,10 +36,5 @@ def install_grub(root_mount_point, boot_loader): ...@@ -70,10 +36,5 @@ def install_grub(root_mount_point, boot_loader):
def run(): def run():
root_mount_point = libcalamares.globalstorage.value("rootMountPoint") root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
boot_loader = libcalamares.globalstorage.value("bootLoader") 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) install_grub(root_mount_point, boot_loader)
finally:
umount_partitions(root_mount_point, extra_mounts)
return None return None
...@@ -4,13 +4,3 @@ interface: "python" ...@@ -4,13 +4,3 @@ interface: "python"
requires: [] requires: []
script: "main.py" script: "main.py"
configuration: 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): ...@@ -54,11 +54,13 @@ def mount_partitions(root_mount_point, partitions):
def run(): def run():
root_mount_point = tempfile.mkdtemp(prefix="calamares-root-") root_mount_point = tempfile.mkdtemp(prefix="calamares-root-")
partitions = libcalamares.globalstorage.value("partitions") partitions = libcalamares.globalstorage.value("partitions")
extra_mounts = libcalamares.job.configuration["extraMounts"]
# Sort by mount points to ensure / is mounted before the rest # Sort by mount points to ensure / is mounted before the rest
partitions.sort(key=lambda x: x["mountPoint"]) partitions.sort(key=lambda x: x["mountPoint"])
mount_partitions( mount_partitions(root_mount_point, partitions)
root_mount_point, libcalamares.globalstorage.value("partitions"))
mount_partitions(root_mount_point, extra_mounts)
libcalamares.globalstorage.insert("rootMountPoint", root_mount_point) libcalamares.globalstorage.insert("rootMountPoint", root_mount_point)
return None return None
...@@ -4,3 +4,13 @@ interface: "python" ...@@ -4,3 +4,13 @@ interface: "python"
requires: [] requires: []
script: "main.py" script: "main.py"
configuration: configuration:
extraMounts:
- device: proc
fs: proc
mountPoint: /proc
- device: sys
fs: sysfs
mountPoint: /sys
- device: /dev
mountPoint: /dev
options: bind
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment