From 76450b44a3786a50a2878d7bc3ca64ab5eb0420c Mon Sep 17 00:00:00 2001 From: Kevin Kofler Date: Sun, 16 Nov 2014 04:56:11 +0100 Subject: [PATCH] bootloader: Ensure that the file names are valid. Change any '/' slashes to '-' dashes. Also change spaces to underscores while we are at it. --- src/modules/bootloader/main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 50ae9d773..e27473ba3 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -110,9 +110,10 @@ def create_loader(loader_path): branding = libcalamares.globalstorage.value("branding") distribution = branding["productName"] timeout = libcalamares.job.configuration["timeout"] + file_name_sanitizer = str.maketrans(" /", "_-") lines = [ 'timeout %s\n' % timeout, - 'default %s\n' % distribution, + 'default %s\n' % distribution.translate(file_name_sanitizer), ] with open(loader_path, 'w') as f: @@ -127,10 +128,11 @@ def install_bootloader(boot_loader, fw_type): uuid = get_uuid() branding = libcalamares.globalstorage.value("branding") distribution = branding["productName"] + file_name_sanitizer = str.maketrans(" /", "_-") conf_path = os.path.join( - install_path, "boot", "loader", "entries", "%s.conf" % distribution) + install_path, "boot", "loader", "entries", "%s.conf" % distribution.translate(file_name_sanitizer)) fallback_path = os.path.join( - install_path, "boot", "loader", "entries", "%s-fallback.conf" % distribution) + install_path, "boot", "loader", "entries", "%s-fallback.conf" % distribution.translate(file_name_sanitizer)) loader_path = os.path.join( install_path, "boot", "loader", "loader.conf") partitions = libcalamares.globalstorage.value("partitions")