[bootloader] fix issue when /EFI/Boot exists
This commit is contained in:
parent
c8d043f6df
commit
36f87f5f35
@ -25,6 +25,7 @@
|
|||||||
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import libcalamares
|
import libcalamares
|
||||||
@ -193,9 +194,11 @@ def install_grub(efi_directory, fw_type):
|
|||||||
"""
|
"""
|
||||||
if fw_type == "efi":
|
if fw_type == "efi":
|
||||||
print("Bootloader: grub (efi)")
|
print("Bootloader: grub (efi)")
|
||||||
|
install_path = libcalamares.globalstorage.value("rootMountPoint")
|
||||||
|
install_efi_directory = install_path + efi_directory
|
||||||
|
|
||||||
if not os.path.isdir(efi_directory):
|
if not os.path.isdir(install_efi_directory):
|
||||||
check_target_env_call(["mkdir", "-p", "{!s}".format(efi_directory)])
|
os.mkdirs(install_efi_directory)
|
||||||
|
|
||||||
if "efiBootloaderId" in libcalamares.job.configuration:
|
if "efiBootloaderId" in libcalamares.job.configuration:
|
||||||
efi_bootloader_id = libcalamares.job.configuration["efiBootloaderId"]
|
efi_bootloader_id = libcalamares.job.configuration["efiBootloaderId"]
|
||||||
@ -220,24 +223,21 @@ def install_grub(efi_directory, fw_type):
|
|||||||
"--force"])
|
"--force"])
|
||||||
|
|
||||||
# VFAT is weird, see issue CAL-385
|
# VFAT is weird, see issue CAL-385
|
||||||
efi_directory_firmware = os.path.join(efi_directory, "EFI")
|
install_efi_directory_firmware = vfat_correct_case(install_efi_directory, "EFI")
|
||||||
if os.path.exists(efi_directory_firmware):
|
if not os.path.exists(install_efi_directory_firmware):
|
||||||
efi_directory_firmware = vfat_correct_case(efi_directory, "EFI")
|
os.mkdirs(install_efi_directory_firmware)
|
||||||
|
|
||||||
efi_boot_directory = os.path.join(efi_directory_firmware, "boot")
|
# there might be several values for the boot directory
|
||||||
if os.path.exists(efi_boot_directory):
|
# most usual they are boot, Boot, BOOT
|
||||||
efi_boot_directory = vfat_correct_case(efi_directory_firmware, "boot")
|
|
||||||
else:
|
install_efi_boot_directory = vfat_correct_case(install_efi_directory_firmware, "boot")
|
||||||
check_target_env_call(["mkdir", "-p", efi_boot_directory])
|
if not os.path.exists(install_efi_boot_directory):
|
||||||
|
os.mkdirs(install_efi_boot_directory)
|
||||||
|
|
||||||
# Workaround for some UEFI firmwares
|
# Workaround for some UEFI firmwares
|
||||||
efi_file_source = {"32": os.path.join(efi_directory_firmware, efi_bootloader_id, "grubia32.efi"),
|
efi_file_source = {"32": os.path.join(install_efi_directory_firmware, efi_bootloader_id, "grubia32.efi"),
|
||||||
"64": os.path.join(efi_directory_firmware, efi_bootloader_id, "grubx64.efi")}
|
"64": os.path.join(install_efi_directory_firmware, efi_bootloader_id, "grubx64.efi")}
|
||||||
efi_file_target = {"32": os.path.join(efi_boot_directory, "bootia32.efi"),
|
shutil.copy2(efi_file_source[efi_bitness], install_efi_boot_directory)
|
||||||
"64": os.path.join(efi_boot_directory, "bootx64.efi")}
|
|
||||||
check_target_env_call(["cp",
|
|
||||||
efi_file_source[efi_bitness],
|
|
||||||
efi_file_target[efi_bitness]])
|
|
||||||
else:
|
else:
|
||||||
print("Bootloader: grub (bios)")
|
print("Bootloader: grub (bios)")
|
||||||
if libcalamares.globalstorage.value("bootLoader") is None:
|
if libcalamares.globalstorage.value("bootLoader") is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user