grub: Add EFI support.
Fixes #110. This is based on Daniel Hillenbrand's submissions, but it makes the same adjustments already done in the bootloader module that's already merged: * Put detect_firmware_type into the grub module itself until a better place is found. * Get the distribution name from the branding configuration and use the file_name_sanitizer on it. * Get the grub-install executable name from the module configuration. It also fixes a Python syntax error in the original submission.
This commit is contained in:
parent
869ace58b8
commit
132628c175
@ -3,6 +3,8 @@
|
||||
# === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
#
|
||||
# Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
||||
# Copyright 2014, Daniel Hillenbrand <codeworkx@bbqlinux.org>
|
||||
# Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
|
||||
#
|
||||
# Calamares is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -21,13 +23,34 @@ import libcalamares
|
||||
from libcalamares.utils import check_chroot_call
|
||||
|
||||
|
||||
def install_grub(boot_loader):
|
||||
install_path = boot_loader["installPath"]
|
||||
check_chroot_call([libcalamares.job.configuration["grubInstall"], install_path])
|
||||
def detect_firmware_type():
|
||||
# Check for EFI variables support
|
||||
if(os.path.exists("/sys/firmware/efi/efivars")):
|
||||
fw_type = 'efi'
|
||||
else:
|
||||
fw_type = 'bios'
|
||||
|
||||
libcalamares.globalstorage.insert("firmwareType", fw_type)
|
||||
libcalamares.utils.debug("Firmware type: {!s}".format(fw_type))
|
||||
|
||||
|
||||
def install_grub(boot_loader, fw_type):
|
||||
if fw_type == 'efi':
|
||||
efi_directory = "/boot/efi"
|
||||
branding = libcalamares.globalstorage.value("branding")
|
||||
distribution = branding["shortProductName"]
|
||||
file_name_sanitizer = str.maketrans(" /", "_-")
|
||||
check_chroot_call([libcalamares.job.configuration["grubInstall"], "--target=x86_64-efi", "--efi-directory={!s}".format(efi_directory), "--bootloader-id={!s}".format(distribution.translate(file_name_sanitizer))])
|
||||
else:
|
||||
install_path = boot_loader["installPath"]
|
||||
check_chroot_call([libcalamares.job.configuration["grubInstall"], install_path])
|
||||
|
||||
check_chroot_call([libcalamares.job.configuration["grubMkconfig"], "-o", libcalamares.job.configuration["grubCfg"]])
|
||||
|
||||
|
||||
def run():
|
||||
detect_firmware_type()
|
||||
boot_loader = libcalamares.globalstorage.value("bootLoader")
|
||||
install_grub(boot_loader)
|
||||
fw_type = libcalamares.globalstorage.value("firmwareType")
|
||||
install_grub(boot_loader, fw_type)
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user