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

Fixes suggested by linter.

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