diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index f30a9857d..ccd4715a4 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -29,17 +29,6 @@ import subprocess from libcalamares.utils import check_chroot_call -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 get_uuid(): root_mount_point = libcalamares.globalstorage.value("rootMountPoint") print(root_mount_point) @@ -161,7 +150,6 @@ def install_bootloader(boot_loader, fw_type): def run(): - detect_firmware_type() boot_loader = libcalamares.globalstorage.value("bootLoader") fw_type = libcalamares.globalstorage.value("firmwareType") install_bootloader(boot_loader, fw_type) diff --git a/src/modules/grub/main.py b/src/modules/grub/main.py index b5c6d9bad..000623cdc 100644 --- a/src/modules/grub/main.py +++ b/src/modules/grub/main.py @@ -3,6 +3,8 @@ # === This file is part of Calamares - === # # Copyright 2014, Aurélien Gâteau +# Copyright 2014, Daniel Hillenbrand +# Copyright 2014, Kevin Kofler # # 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,22 @@ 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 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(): boot_loader = libcalamares.globalstorage.value("bootLoader") - install_grub(boot_loader) + fw_type = libcalamares.globalstorage.value("firmwareType") + install_grub(boot_loader, fw_type) return None diff --git a/src/modules/grub/test.yaml b/src/modules/grub/test.yaml index 3b9852e63..1cd6c418f 100644 --- a/src/modules/grub/test.yaml +++ b/src/modules/grub/test.yaml @@ -1,3 +1,5 @@ rootMountPoint: /tmp/mount bootLoader: installPath: /dev/sdb +branding: + shortProductName: "Generic Distro" diff --git a/src/modules/prepare/PrepareViewStep.cpp b/src/modules/prepare/PrepareViewStep.cpp index ef6c24a65..58eb480f2 100644 --- a/src/modules/prepare/PrepareViewStep.cpp +++ b/src/modules/prepare/PrepareViewStep.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -133,6 +134,9 @@ PrepareViewStep::PrepareViewStep( QObject* parent ) m_nextEnabled = canGoNext; emit nextStatusChanged( m_nextEnabled ); + if ( canGoNext ) + detectFirmwareType(); + timer->deleteLater(); } ); timer->start( 0 ); @@ -363,3 +367,10 @@ PrepareViewStep::checkHasInternet() return nmState == NM_STATE_CONNECTED_GLOBAL; } + +void +PrepareViewStep::detectFirmwareType() +{ + QString fwType = QFile::exists( "/sys/firmware/efi/efivars" ) ? "efi" : "bios"; + Calamares::JobQueue::instance()->globalStorage()->insert( "firmwareType", fwType ); +} diff --git a/src/modules/prepare/PrepareViewStep.h b/src/modules/prepare/PrepareViewStep.h index 3b9ada8f2..cf13a908b 100644 --- a/src/modules/prepare/PrepareViewStep.h +++ b/src/modules/prepare/PrepareViewStep.h @@ -75,6 +75,7 @@ private: bool checkBatteryExists(); bool checkHasPower(); bool checkHasInternet(); + void detectFirmwareType(); QWidget* m_widget; qreal m_requiredStorageGB;