Merge remote-tracking branch 'origin/issue-1201'

FIXES #1201
main
Adriaan de Groot 5 years ago
commit 28687d0d1e

@ -1,9 +1,12 @@
# Create, overwrite or update /etc/default/grub in the target system.
#
# Write lines to /etc/default/grub (in the target system) based
# on calculated values and the values set in the *defaults* key
# in this configuration file.
#
# Calculated values are:
# - GRUB_DISTRIBUTOR, branding module, *bootloaderEntryName*
# - GRUB_DISTRIBUTOR, branding module, *bootloaderEntryName* (this
# string is sanitized, and see also setting *keepDistributor*)
# - GRUB_ENABLE_CRYPTODISK, based on the presence of filesystems
# that use LUKS
# - GRUB_CMDLINE_LINUX_DEFAULT, adding LUKS setup and plymouth
@ -14,6 +17,12 @@
# already existed. If set to false, edits the existing file instead.
overwrite: false
# If set to true, an **existing** setting for GRUB_DISTRIBUTOR is
# kept, not updated to the *bootloaderEntryName* from the branding file.
# Use this if the GRUB_DISTRIBUTOR setting in the file is "smart" in
# some way (e.g. uses shell-command substitution).
keepDistributor: false
# Default entries to write to /etc/default/grub if it does not exist yet or if
# we are overwriting it.
#

@ -45,7 +45,13 @@ def modify_grub_default(partitions, root_mount_point, distributor):
:param partitions:
:param root_mount_point:
:param distributor:
:param distributor: name of the distributor to fill in for
GRUB_DISTRIBUTOR. Must be a string. If the job setting
*keepDistributor* is set, then this is only used if no
GRUB_DISTRIBUTOR is found at all (otherwise, when *keepDistributor*
is set, the GRUB_DISTRIBUTOR lines are left unchanged).
If *keepDistributor* is unset or false, then GRUB_DISTRIBUTOR
is always updated to set this value.
:return:
"""
default_dir = os.path.join(root_mount_point, "etc/default")
@ -172,8 +178,13 @@ def modify_grub_default(partitions, root_mount_point, distributor):
have_kernel_cmd = True
elif (lines[i].startswith("#GRUB_DISTRIBUTOR")
or lines[i].startswith("GRUB_DISTRIBUTOR")):
lines[i] = distributor_line
have_distributor_line = True
if libcalamares.job.configuration.get("keepDistributor", false):
lines[i] = distributor_line
have_distributor_line = True
else:
# We're not updating because of *keepDistributor*, but if
# this was a comment line, then it's still not been set.
have_distributor_line = have_distributor_line or not lines[i].startsdwith("#")
else:
lines = []

@ -0,0 +1,10 @@
---
bogus: true
firmwareType: bios
bootLoader: grub
rootMountPoint: /tmp/calamares
branding:
bootloaderEntryName: generic
partitions: []

@ -0,0 +1,9 @@
---
overwrite: true
keepDistributor: false
defaults:
GRUB_TIMEOUT: 5
GRUB_DEFAULT: "saved"
GRUB_DISABLE_SUBMENU: true
GRUB_TERMINAL_OUTPUT: "console"
GRUB_DISABLE_RECOVERY: true
Loading…
Cancel
Save