Fixes suggested by linter.
This commit is contained in:
parent
282f1f9135
commit
dd7cd42118
@ -125,9 +125,9 @@ def create_systemd_boot_conf(uuid, conf_path, kernel_line):
|
||||
"options {!s} rw\n".format(" ".join(kernel_params)),
|
||||
]
|
||||
|
||||
with open(conf_path, 'w') as f:
|
||||
for l in lines:
|
||||
f.write(l)
|
||||
with open(conf_path, 'w') as conf_file:
|
||||
for line in lines:
|
||||
conf_file.write(line)
|
||||
|
||||
|
||||
def create_loader(loader_path):
|
||||
@ -144,9 +144,9 @@ def create_loader(loader_path):
|
||||
"default {!s}\n".format(distribution_translated),
|
||||
]
|
||||
|
||||
with open(loader_path, 'w') as f:
|
||||
for l in lines:
|
||||
f.write(l)
|
||||
with open(loader_path, 'w') as loader_file:
|
||||
for line in lines:
|
||||
loader_file.write(line)
|
||||
|
||||
|
||||
def install_systemd_boot(efi_directory):
|
||||
@ -162,12 +162,20 @@ def install_systemd_boot(efi_directory):
|
||||
distribution = get_bootloader_entry_name()
|
||||
file_name_sanitizer = str.maketrans(" /", "_-")
|
||||
distribution_translated = distribution.translate(file_name_sanitizer)
|
||||
conf_path = os.path.join(install_efi_directory, "loader", "entries",
|
||||
conf_path = os.path.join(install_efi_directory,
|
||||
"loader",
|
||||
"entries",
|
||||
"{!s}.conf".format(distribution_translated))
|
||||
fallback_path = os.path.join(install_efi_directory, "loader", "entries",
|
||||
fallback_path = os.path.join(install_efi_directory,
|
||||
"loader",
|
||||
"entries",
|
||||
"{!s}-fallback.conf".format(distribution_translated))
|
||||
loader_path = os.path.join(install_efi_directory, "loader", "loader.conf")
|
||||
subprocess.call(["bootctl", "--path={!s}".format(install_efi_directory), "install"])
|
||||
loader_path = os.path.join(install_efi_directory,
|
||||
"loader",
|
||||
"loader.conf")
|
||||
subprocess.call(["bootctl",
|
||||
"--path={!s}".format(install_efi_directory),
|
||||
"install"])
|
||||
kernel_line = get_kernel_line("default")
|
||||
print("Configure: \"{!s}\"".format(kernel_line))
|
||||
create_systemd_boot_conf(uuid, conf_path, kernel_line)
|
||||
@ -197,29 +205,35 @@ def install_grub(efi_directory, fw_type):
|
||||
efi_bootloader_id = distribution.translate(file_name_sanitizer)
|
||||
# get bitness of the underlying UEFI
|
||||
try:
|
||||
f = open("/sys/firmware/efi/fw_platform_size", "r")
|
||||
efi_bitness = f.read(2)
|
||||
except:
|
||||
# if the kernel is older than 4.0, the UEFI bitness likely isn't exposed to the userspace
|
||||
# so we assume a 64 bit UEFI here
|
||||
sysfile = open("/sys/firmware/efi/fw_platform_size", "r")
|
||||
efi_bitness = sysfile.read(2)
|
||||
except Exception:
|
||||
# if the kernel is older than 4.0, the UEFI bitness likely isn't
|
||||
# exposed to the userspace so we assume a 64 bit UEFI here
|
||||
efi_bitness = "64"
|
||||
bitness_translate = {"32": "--target=i386-efi", "64": "--target=x86_64-efi"}
|
||||
check_target_env_call([libcalamares.job.configuration["grubInstall"], bitness_translate[efi_bitness],
|
||||
"--efi-directory={!s}".format(efi_directory),
|
||||
"--bootloader-id={!s}".format(efi_bootloader_id),
|
||||
"--force"])
|
||||
check_target_env_call([libcalamares.job.configuration["grubInstall"],
|
||||
bitness_translate[efi_bitness],
|
||||
"--efi-directory={!s}".format(efi_directory),
|
||||
"--bootloader-id={!s}".format(efi_bootloader_id),
|
||||
"--force"])
|
||||
# Workaround for some UEFI firmwares
|
||||
check_target_env_call(["mkdir", "-p", "{!s}/boot".format(efi_directory_firmware)])
|
||||
check_target_env_call(["cp", "{!s}/{!s}/grubx64.efi".format(efi_directory_firmware, efi_bootloader_id),
|
||||
"{!s}/boot/bootx64.efi".format(efi_directory_firmware)])
|
||||
check_target_env_call(["cp", "{!s}/{!s}/grubx64.efi".format(efi_directory_firmware,
|
||||
efi_bootloader_id),
|
||||
"{!s}/boot/bootx64.efi".format(efi_directory_firmware)])
|
||||
else:
|
||||
print("Bootloader: grub (bios)")
|
||||
boot_loader = libcalamares.globalstorage.value("bootLoader")
|
||||
check_target_env_call([libcalamares.job.configuration["grubInstall"], "--target=i386-pc",
|
||||
"--recheck", "--force", boot_loader["installPath"]])
|
||||
check_target_env_call([libcalamares.job.configuration["grubInstall"],
|
||||
"--target=i386-pc",
|
||||
"--recheck",
|
||||
"--force",
|
||||
boot_loader["installPath"]])
|
||||
|
||||
check_target_env_call([libcalamares.job.configuration["grubMkconfig"], "-o",
|
||||
libcalamares.job.configuration["grubCfg"]])
|
||||
check_target_env_call([libcalamares.job.configuration["grubMkconfig"],
|
||||
"-o",
|
||||
libcalamares.job.configuration["grubCfg"]])
|
||||
|
||||
|
||||
def prepare_bootloader(fw_type):
|
||||
|
Loading…
Reference in New Issue
Block a user