Skip to content
Snippets Groups Projects
Commit 97867af2 authored by Teo Mrnjavac's avatar Teo Mrnjavac
Browse files

Autopep8 pass on bootloader module.

parent 8f250311
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,7 @@ import subprocess ...@@ -28,6 +28,7 @@ import subprocess
from libcalamares.utils import check_chroot_call from libcalamares.utils import check_chroot_call
def detect_firmware_type(): def detect_firmware_type():
# Check for EFI variables support # Check for EFI variables support
if(os.path.exists("/sys/firmware/efi/efivars")): if(os.path.exists("/sys/firmware/efi/efivars")):
...@@ -35,6 +36,7 @@ def detect_firmware_type(): ...@@ -35,6 +36,7 @@ def detect_firmware_type():
else: else:
fw_type = 'bios' fw_type = 'bios'
def get_uuid(): def get_uuid():
root_mount_point = libcalamares.globalstorage.value("rootMountPoint") root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
print(root_mount_point) print(root_mount_point)
...@@ -45,7 +47,8 @@ def get_uuid(): ...@@ -45,7 +47,8 @@ def get_uuid():
print(partition["uuid"]) print(partition["uuid"])
return partition["uuid"] return partition["uuid"]
return "" return ""
def create_conf(uuid, conf_path): def create_conf(uuid, conf_path):
distribution = libcalamares.job.configuration["distribution"] distribution = libcalamares.job.configuration["distribution"]
lines = [ lines = [
...@@ -57,12 +60,13 @@ def create_conf(uuid, conf_path): ...@@ -57,12 +60,13 @@ def create_conf(uuid, conf_path):
'initrd /initramfs-linux.img\n', 'initrd /initramfs-linux.img\n',
'options root=UUID=%s quiet rw\n' % uuid, 'options root=UUID=%s quiet rw\n' % uuid,
] ]
with open(conf_path, 'w') as f: with open(conf_path, 'w') as f:
for l in lines: for l in lines:
f.write(l) f.write(l)
f.close() f.close()
def create_loader(loader_path): def create_loader(loader_path):
distribution = libcalamares.job.configuration["distribution"] distribution = libcalamares.job.configuration["distribution"]
timeout = libcalamares.job.configuration["timeout"] timeout = libcalamares.job.configuration["timeout"]
...@@ -70,20 +74,24 @@ def create_loader(loader_path): ...@@ -70,20 +74,24 @@ def create_loader(loader_path):
'timeout %s\n' % timeout, 'timeout %s\n' % timeout,
'default %s\n' % distribution, 'default %s\n' % distribution,
] ]
with open(loader_path, 'w') as f: with open(loader_path, 'w') as f:
for l in lines: for l in lines:
f.write(l) f.write(l)
f.close() f.close()
def install_bootloader(boot_loader, fw_type): def install_bootloader(boot_loader, fw_type):
if fw_type == 'efi': if fw_type == 'efi':
install_path = libcalamares.globalstorage.value( "rootMountPoint" ) install_path = libcalamares.globalstorage.value("rootMountPoint")
uuid = get_uuid() uuid = get_uuid()
distribution = libcalamares.job.configuration["distribution"] distribution = libcalamares.job.configuration["distribution"]
conf_path = os.path.join(install_path, "boot", "loader", "entries", "%s.conf" % distribution) conf_path = os.path.join(
loader_path = os.path.join(install_path, "boot", "loader", "loader.conf") install_path, "boot", "loader", "entries", "%s.conf" % distribution)
subprocess.call(["gummiboot", "--path=%s/boot" % install_path, "install"]) loader_path = os.path.join(
install_path, "boot", "loader", "loader.conf")
subprocess.call(
["gummiboot", "--path=%s/boot" % install_path, "install"])
create_conf(uuid, conf_path) create_conf(uuid, conf_path)
create_loader(loader_path) create_loader(loader_path)
else: else:
...@@ -91,6 +99,7 @@ def install_bootloader(boot_loader, fw_type): ...@@ -91,6 +99,7 @@ def install_bootloader(boot_loader, fw_type):
check_chroot_call(["grub-install", install_path]) check_chroot_call(["grub-install", install_path])
check_chroot_call(["grub-mkconfig", "-o", "/boot/grub/grub.cfg"]) check_chroot_call(["grub-mkconfig", "-o", "/boot/grub/grub.cfg"])
def run(): def run():
detect_firmware_type() detect_firmware_type()
boot_loader = libcalamares.globalstorage.value("bootLoader") boot_loader = libcalamares.globalstorage.value("bootLoader")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment