[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.
This commit is contained in:
Adriaan de Groot 2019-05-10 15:28:37 -04:00
parent 5b8a54edce
commit 9bf1d83c2f

View File

@ -43,6 +43,9 @@ _ = gettext.translation("calamares-python",
languages=libcalamares.utils.gettext_languages(), languages=libcalamares.utils.gettext_languages(),
fallback=True).gettext 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(): def pretty_name():
return _("Install bootloader.") return _("Install bootloader.")
@ -211,7 +214,6 @@ def efi_label():
branding = libcalamares.globalstorage.value("branding") branding = libcalamares.globalstorage.value("branding")
efi_bootloader_id = branding["bootloaderEntryName"] efi_bootloader_id = branding["bootloaderEntryName"]
file_name_sanitizer = str.maketrans(" /", "_-")
return efi_bootloader_id.translate(file_name_sanitizer) 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 install_efi_directory = install_path + efi_directory
uuid = get_uuid() uuid = get_uuid()
distribution = get_bootloader_entry_name() distribution = get_bootloader_entry_name()
file_name_sanitizer = str.maketrans(" /", "_-")
distribution_translated = distribution.translate(file_name_sanitizer) distribution_translated = distribution.translate(file_name_sanitizer)
loader_path = os.path.join(install_efi_directory, loader_path = os.path.join(install_efi_directory,
"loader", "loader",