PEPify grub
This commit is contained in:
parent
98b62808de
commit
1c984c7bf9
@ -19,62 +19,61 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
|
|
||||||
import libcalamares
|
import libcalamares
|
||||||
|
|
||||||
|
|
||||||
# FIXME: Duplicated between mount and grub
|
# FIXME: Duplicated between mount and grub
|
||||||
def mount( devicePath, mountPoint, fs = None, options = None ):
|
def mount(device_path, mount_point, fs=None, options=None):
|
||||||
assert devicePath
|
assert device_path
|
||||||
assert mountPoint
|
assert mount_point
|
||||||
if not os.path.exists( mountPoint ):
|
if not os.path.exists(mount_point):
|
||||||
os.makedirs( mountPoint )
|
os.makedirs(mount_point)
|
||||||
cmd = [ "mount", devicePath, mountPoint ]
|
cmd = ["mount", device_path, mount_point]
|
||||||
if fs:
|
if fs:
|
||||||
cmd += ( "-t", fs )
|
cmd += ("-t", fs)
|
||||||
if options:
|
if options:
|
||||||
cmd += ( "-o", options )
|
cmd += ("-o", options)
|
||||||
subprocess.check_call( cmd )
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
|
|
||||||
def mountPartitions( rootMountPoint, partitions ):
|
def mount_partitions(root_mount_point, partitions):
|
||||||
for partition in partitions:
|
for partition in partitions:
|
||||||
if not partition[ "mountPoint" ]:
|
if not partition["mountPoint"]:
|
||||||
continue
|
continue
|
||||||
# Create mount point with `+` rather than `os.path.join()` because
|
# Create mount point with `+` rather than `os.path.join()` because
|
||||||
# `partition["mountPoint"]` starts with a '/'.
|
# `partition["mountPoint"]` starts with a '/'.
|
||||||
mountPoint = rootMountPoint + partition[ "mountPoint" ]
|
mount_point = root_mount_point + partition["mountPoint"]
|
||||||
mount( partition[ "device" ], mountPoint,
|
mount(partition["device"], mount_point,
|
||||||
fs = partition.get( "fs" ),
|
fs=partition.get("fs"),
|
||||||
options = partition.get( "options" )
|
options=partition.get("options")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def umountPartitions( rootMountPoint, partitions ):
|
def umount_partitions(root_mount_point, partitions):
|
||||||
for partition in partitions:
|
for partition in partitions:
|
||||||
if not partition[ "mountPoint" ]:
|
if not partition["mountPoint"]:
|
||||||
continue
|
continue
|
||||||
subprocess.call( [ "umount", rootMountPoint + partition[ "mountPoint" ] ] )
|
subprocess.call(["umount", root_mount_point + partition["mountPoint"]])
|
||||||
|
|
||||||
|
|
||||||
def chroot_call( rootMountPoint, cmd ):
|
def chroot_call(root_mount_point, cmd):
|
||||||
subprocess.check_call( [ "chroot", rootMountPoint ] + cmd )
|
subprocess.check_call(["chroot", root_mount_point] + cmd)
|
||||||
|
|
||||||
|
|
||||||
def installGrub( rootMountPoint, bootLoader ):
|
def install_grub(root_mount_point, boot_loader):
|
||||||
installPath = bootLoader[ "installPath" ]
|
install_path = boot_loader["installPath"]
|
||||||
chroot_call( rootMountPoint, [ "grub-install", installPath ] )
|
chroot_call(root_mount_point, ["grub-install", install_path])
|
||||||
chroot_call( rootMountPoint, [ "grub-mkconfig", "-o", "/boot/grub/grub.cfg" ] )
|
chroot_call(root_mount_point, ["grub-mkconfig", "-o", "/boot/grub/grub.cfg"])
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
rootMountPoint = libcalamares.globalStorage.value( "rootMountPoint" )
|
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
||||||
bootLoader = libcalamares.globalStorage.value( "bootLoader" )
|
boot_loader = libcalamares.globalstorage.value("bootLoader")
|
||||||
extraMounts = libcalamares.job.configuration[ "extraMounts" ]
|
extra_mounts = libcalamares.job.configuration["extraMounts"]
|
||||||
mountPartitions( rootMountPoint, extraMounts )
|
mount_partitions(root_mount_point, extra_mounts)
|
||||||
try:
|
try:
|
||||||
installGrub( rootMountPoint, bootLoader )
|
install_grub(root_mount_point, boot_loader)
|
||||||
finally:
|
finally:
|
||||||
umountPartitions( rootMountPoint, extraMounts )
|
umount_partitions(root_mount_point, extra_mounts)
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user