[grubcfg] Update GRUB_DISTRIBUTION as needed
- Previous fix would erase the distribution information (using an empty string to flag 'preserve existing GRUB_DISTRIBUTION lines'), but that is fragile. A distro might set that, and yet **not** set a GRUB_DISTRIBUTION line, in which case it would end up with a setup without any GRUB_DISTRIBUTION set. - When a GRUB_DISTRIBUTION line is found, **then** check if it should update the line or not. This way, we have a suitable distribution to write if no GRUB_DISTRIBUTION is found at all.
This commit is contained in:
parent
ac3b50fabb
commit
c6c861654d
@ -46,9 +46,12 @@ def modify_grub_default(partitions, root_mount_point, distributor):
|
|||||||
:param partitions:
|
:param partitions:
|
||||||
:param root_mount_point:
|
:param root_mount_point:
|
||||||
:param distributor: name of the distributor to fill in for
|
:param distributor: name of the distributor to fill in for
|
||||||
GRUB_DISTRIBUTOR. Must be a string, but if it is empty ("")
|
GRUB_DISTRIBUTOR. Must be a string. If the job setting
|
||||||
then the existing GRUB_DISTRIBUTOR lines are kept instead
|
*keepDistributor* is set, then this is only used if no
|
||||||
of replaced by a new line.
|
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:
|
:return:
|
||||||
"""
|
"""
|
||||||
default_dir = os.path.join(root_mount_point, "etc/default")
|
default_dir = os.path.join(root_mount_point, "etc/default")
|
||||||
@ -175,7 +178,7 @@ def modify_grub_default(partitions, root_mount_point, distributor):
|
|||||||
have_kernel_cmd = True
|
have_kernel_cmd = True
|
||||||
elif (lines[i].startswith("#GRUB_DISTRIBUTOR")
|
elif (lines[i].startswith("#GRUB_DISTRIBUTOR")
|
||||||
or lines[i].startswith("GRUB_DISTRIBUTOR")):
|
or lines[i].startswith("GRUB_DISTRIBUTOR")):
|
||||||
if distributor:
|
if libcalamares.job.configuration.get("keepDistributor", false):
|
||||||
lines[i] = distributor_line
|
lines[i] = distributor_line
|
||||||
have_distributor_line = True
|
have_distributor_line = True
|
||||||
else:
|
else:
|
||||||
@ -240,10 +243,6 @@ def run():
|
|||||||
|
|
||||||
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
||||||
branding = libcalamares.globalstorage.value("branding")
|
branding = libcalamares.globalstorage.value("branding")
|
||||||
|
|
||||||
if libcalamares.job.configuration.get("keepDistributor", false):
|
|
||||||
distributor = ""
|
|
||||||
else:
|
|
||||||
distributor = branding["bootloaderEntryName"]
|
distributor = branding["bootloaderEntryName"]
|
||||||
|
|
||||||
return modify_grub_default(partitions, root_mount_point, distributor)
|
return modify_grub_default(partitions, root_mount_point, distributor)
|
||||||
|
Loading…
Reference in New Issue
Block a user