From 9bf1d83c2f58f24cbaef3a6820fbe3b79f3246f8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 May 2019 15:28:37 -0400 Subject: [PATCH 1/3] [bootloader] Centralize the filename sanitizer - Centralize the sanitizer so that it's consistent in different environments. - While here, add () to the sanitizer to avoid some distro's with parenthesized names from creating weird EFI dirs. --- src/modules/bootloader/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 4a0bef326..2c384ca30 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -43,6 +43,9 @@ _ = gettext.translation("calamares-python", languages=libcalamares.utils.gettext_languages(), fallback=True).gettext +# This is the sanitizer used all over to tidy up filenames +# to make identifiers (or to clean up names to make filenames). +file_name_sanitizer = str.maketrans(" /()", "_-__") def pretty_name(): return _("Install bootloader.") @@ -211,7 +214,6 @@ def efi_label(): branding = libcalamares.globalstorage.value("branding") efi_bootloader_id = branding["bootloaderEntryName"] - file_name_sanitizer = str.maketrans(" /", "_-") return efi_bootloader_id.translate(file_name_sanitizer) @@ -238,7 +240,6 @@ def install_systemd_boot(efi_directory): install_efi_directory = install_path + efi_directory uuid = get_uuid() distribution = get_bootloader_entry_name() - file_name_sanitizer = str.maketrans(" /", "_-") distribution_translated = distribution.translate(file_name_sanitizer) loader_path = os.path.join(install_efi_directory, "loader", From 23ae6b77bdfff6331cbbd1b4fd483fde73ac51f0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 May 2019 15:35:00 -0400 Subject: [PATCH 2/3] [bootloader] Convert to str - The output of subprocess is a bytes object, which needs to be decoded so we can use it like a regular string (alternatively, we could have changed more code to manipulate bytes, but eventually we need a string to pass to a subsequent command anyway). --- src/modules/bootloader/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 2c384ca30..f69cf8aa3 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -366,10 +366,10 @@ def install_secureboot(efi_directory): # of that tuple. efi_drive = subprocess.check_output([ libcalamares.job.configuration["grubProbe"], - "-t", "drive", "--device-map=", install_efi_directory]) + "-t", "drive", "--device-map=", install_efi_directory]).decode("ascii") efi_disk = subprocess.check_output([ libcalamares.job.configuration["grubProbe"], - "-t", "disk", "--device-map=", install_efi_directory]) + "-t", "disk", "--device-map=", install_efi_directory]).decode("ascii") efi_drive_partition = efi_drive.replace("(","").replace(")","").split(",")[1] # Get the first run of digits from the partition From e972c175d826b7539ce36ce5de17791bb825ec15 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 10 May 2019 18:26:59 -0400 Subject: [PATCH 3/3] [bootloader] Fix typo's - There's a general "partititon" typo, but the variable name also is misused. --- src/modules/bootloader/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index f69cf8aa3..40e9f1613 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -373,17 +373,17 @@ def install_secureboot(efi_directory): efi_drive_partition = efi_drive.replace("(","").replace(")","").split(",")[1] # Get the first run of digits from the partition - efi_partititon_number = None + efi_partition_number = None c = 0 start = None while c < len(efi_drive_partition): if efi_drive_partition[c].isdigit() and start is None: start = c if not efi_drive_partition[c].isdigit() and start is not None: - efi_drive_number = efi_drive_partition[start:c] + efi_partition_number = efi_drive_partition[start:c] break c += 1 - if efi_partititon_number is None: + if efi_partition_number is None: raise ValueError("No partition number found for %s" % install_efi_directory) subprocess.call([ @@ -392,7 +392,7 @@ def install_secureboot(efi_directory): "-w", "-L", efi_bootloader_id, "-d", efi_disk, - "-p", efi_partititon_number, + "-p", efi_partition_number, "-l", install_efi_directory + "/" + install_efi_bin])