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

Fixes grub splashImage documentation + implementation #40462

Merged
merged 2 commits into from May 24, 2018

Conversation

samueldr
Copy link
Member

@samueldr samueldr commented May 14, 2018

Motivation for this change

nixos/grub: Implements use of file format for splashImage.
GRUB 2.0 supports png, jpeg and tga. This will use the image's suffix to
load the right module.
As jpeg module is named jpeg, jpg is renamed jpeg.
If the user uses wrong image suffix for an image, it wouldn't work anyway.
This will leave up to two additional left-over files in /boot/ if user switches
through all the supported file formats. The module already left the png
image if the user disabled the splash image.

nixos/grub: Updates splashImage description to match reality.
Fixes #4911

This (first) fixes the documentation for the option, adding the details about the file format for grub 2.

Then, this fixes the implementation to make jpg and tga files loadable too. This will not work with a progressive jpeg, this is a known issue. This implementation will simply fail without background (grub behaviour) if a progressive jpeg image is used. I don't think (tell me if I'm wrong) that it's the module system's job to check for this.

Things done
  • ✔️ Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • ✔️ NixOS
    • 🆖 macOS
    • ❌ other Linux distributions
  • ❌ Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • ✔️ Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • ✔️ Tested execution of all binary files (usually in ./result/bin/)
  • ✔️ Fits CONTRIBUTING.md.

I can split the PR if it is wanted, though it will mean the documentation for the option will be slightly wrong until both commits are applied.

GRUB 2.0 supports png, jpeg and tga. This will use the image's suffix to
load the right module.

As jpeg module is named jpeg, jpg is renamed jpeg.

If the user uses wrong image suffix for an image, it wouldn't work anyway.

This will leave up to two additional left-over files in /boot/ if user switches
through all the supported file formats. The module already left the png
image if the user disabled the splash image.
@@ -299,12 +299,16 @@ sub GrubFs {
copy $font, "$bootPath/converted-font.pf2" or die "cannot copy $font to $bootPath\n";
}
if ($splashImage) {
# FIXME: GRUB 1.97 doesn't resize the background image if it
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before anyone asks, this comment has been "wrong" for a while.

GRUB 1.97 may still not resize the background image, but GRUB 2.02 does!

$conf .= "
insmod png
if background_image " . $grubBoot->path . "/background.png; then
insmod " . substr($suffix, 1) . "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we validate the suffix is one of N supported formats?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the image format isn't supported?

Copy link
Member Author

@samueldr samueldr May 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous behaviour:

  • Image did not load, text mode console

(Just tested) the new behaviour:

  • Exact same thing, image does not load, text mode console.

I'm guessing that an error message is quickly shown and hidden (error: file '/grub/x86_64-efi/ext.mod) as it would if I tried insmod ext in the console.

@grahamc grahamc merged commit 290505b into NixOS:master May 24, 2018
@samueldr samueldr deleted the fix/grub-background branch June 1, 2018 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NixOS manual has incorrect information regarding the configuration of the GRUB bootloader image
3 participants