Preserve kernel parameters that aren't handled by grubcfg.

This commit is contained in:
Teo Mrnjavac 2015-03-31 18:14:33 +02:00
parent 9b516281d8
commit 41e7a9ae3c

View File

@ -4,6 +4,7 @@
# === This file is part of Calamares - <http://github.com/calamares> ===
#
# Copyright 2014-2015, Philip Müller <philm@manjaro.org>
# Copyright 2015, Teo Mrnjavac <teo@kde.org>
#
# Calamares is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -20,6 +21,7 @@
import libcalamares
import os
import re
def modify_grub_default(partitions, root_mount_point, distributor):
@ -46,10 +48,11 @@ def modify_grub_default(partitions, root_mount_point, distributor):
if partition["fs"] == "linuxswap":
swap_uuid = partition["uuid"]
if swap_uuid != "":
kernel_cmd = "GRUB_CMDLINE_LINUX_DEFAULT=\"resume=UUID={!s} quiet {!s}\"".format(swap_uuid, use_splash)
else:
kernel_cmd = "GRUB_CMDLINE_LINUX_DEFAULT=\"quiet {!s}\"".format(use_splash)
kernel_params = ["quiet"]
if use_splash:
kernel_params.append(use_splash)
if swap_uuid:
kernel_params.append("resume=UUID={!s}".format(swap_uuid))
distributor_line = "GRUB_DISTRIBUTOR=\"{!s}\"".format(distributor_replace)
@ -70,9 +73,24 @@ def modify_grub_default(partitions, root_mount_point, distributor):
for i in range(len(lines)):
if lines[i].startswith("#GRUB_CMDLINE_LINUX_DEFAULT"):
kernel_cmd = "GRUB_CMDLINE_LINUX_DEFAULT=\"{!s}\"".format(" ".join(kernel_params))
lines[i] = kernel_cmd
have_kernel_cmd = True
elif lines[i].startswith("GRUB_CMDLINE_LINUX_DEFAULT"):
regex = re.compile(r"^GRUB_CMDLINE_LINUX_DEFAULT.*=")
line = regex.sub("", lines[i])
line.lstrip()
line.lstrip("\"")
line.rstrip()
line.rstrip("\"")
existing_params = line.split()
for existing_param in existing_params:
existing_param_name = existing_param.split("=")[0]
if existing_param_name not in ["quiet", "resume", "splash"]: #the only ones we ever add
kernel_params.append(existing_param)
kernel_cmd = "GRUB_CMDLINE_LINUX_DEFAULT=\"{!s}\"".format(" ".join(kernel_params))
lines[i] = kernel_cmd
have_kernel_cmd = True
elif lines[i].startswith("#GRUB_DISTRIBUTOR") or lines[i].startswith("GRUB_DISTRIBUTOR"):