Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow command substitutions for GRUB_DISTRIBUTOR #1201

Open
apt-ghetto opened this issue Jul 26, 2019 · 2 comments

Comments

@apt-ghetto
Copy link
Contributor

commented Jul 26, 2019

Is your feature request related to a problem? Please describe.
In branding.desc or bootloader.conf, the distributor can set the value for the GRUB_DISTRIBUTOR variable in /etc/default/grub.

Unfortunately, it looks like it is currently not possible to use command substitutions.
For example, Ubuntu sets the value to

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`

or Fedora:

GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"

Describe the solution you'd like
I prefer a solution, where the value for GRUB_DISTRIBUTOR is set character by character (without newline?) as it is defined in bootloaderEntryName.

Additional context
The variable GRUB_DISTRIBUTOR is not only used to set the label in the Grub menu, but it is also used, when you (re-)install Grub on an ESP. This leads to problems, if the values of efibootloaderId and bootloaderEntryName differ.

@kkofler

This comment has been minimized.

Copy link
Contributor

commented Jul 26, 2019

To clarify the situation on Fedora: The efiBootloaderId is always fedora on Fedora and any Fedora Remix. This is hardcoded directly in the grub2 package (it installs files to that directory), so if you want to change the efiBootloaderId setting in Calamares, you have to rebuild grub2. grub2-install is never run on UEFI systems in Fedora. Instead, the package installs the files directly to the location in the ESP expected by shim, and shim is what gets installed (using efibootmgr). That is also why the directory is hardcoded. Thus, GRUB_DISTRIBUTOR is used only for display purposes in the menu. (We run grub2-mkconfig, but not grub2-install.) Hence, it is perfectly fine to have the bootloaderEntryName/GRUB_DISTRIBUTOR differ from the efiBootloaderId. It will be the same on a system installed with Anaconda, where the above sed is used for GRUB_DISTRIBUTOR (resulting in essentially the same value that my Calamares package sets bootloaderEntryName to; in my package, it just happens at the Calamares package install time rather than at each system boot, but that should not really matter), but the EFI bootloader ID is always fedora (as explained above).

The situation on Fedora is actually the whole reason why I introduced a separate efiBootloaderId setting to begin with, as opposed to always using bootloaderEntryName.

@apt-ghetto

This comment has been minimized.

Copy link
Contributor Author

commented Jul 26, 2019

@kkofler Thank you for the interesting explanation.

The background for my "Additional context" is Launchpad bug 1833490.

After digging a bit in the code, I don't see a reason, why GRUB_DISTRIBUTOR is changed, when the key overwritein grubcfg.conf is set to false.
This led me to this, maybe not beautiful, but short workaround/improvement/idea to change grubcfg main.py as follows:

            elif (lines[i].startswith("#GRUB_DISTRIBUTOR")
                   or lines[i].startswith("GRUB_DISTRIBUTOR")):
                if "doNotOverwrite" != distributor:
                    lines[i] = distributor_line
                have_distributor_line = True

This works, if bootloaderEntryName: doNotOverwrite is set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.