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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions nixos/modules/system/boot/loader/grub/grub.nix
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,22 @@ in
type = types.nullOr types.path;
example = literalExample "./my-background.png";
description = ''
Background image used for GRUB. It must be a 640x480,
Background image used for GRUB.
Set to <literal>null</literal> to run GRUB in text mode.

<note><para>
For grub 1:
It must be a 640x480,
14-colour image in XPM format, optionally compressed with
<command>gzip</command> or <command>bzip2</command>. Set to
<literal>null</literal> to run GRUB in text mode.
<command>gzip</command> or <command>bzip2</command>.
</para></note>

<note><para>
For grub 2:
File must be one of .png, .tga, .jpg, or .jpeg. JPEG images must
not be progressive.
The image will be scaled if necessary to fit the screen.
</para></note>
'';
};

Expand Down
14 changes: 9 additions & 5 deletions nixos/modules/system/boot/loader/grub/install-grub.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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!

# doesn't match the video resolution.
copy $splashImage, "$bootPath/background.png" or die "cannot copy $splashImage to $bootPath\n";
# Keeps the image's extension.
my ($filename, $dirs, $suffix) = fileparse($splashImage, qr"\..[^.]*$");
# The module for jpg is jpeg.
if ($suffix eq ".jpg") {
$suffix = ".jpeg";
}
copy $splashImage, "$bootPath/background$suffix" or die "cannot copy $splashImage to $bootPath\n";
$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.

if background_image " . $grubBoot->path . "/background$suffix; then
set color_normal=white/black
set color_highlight=black/white
else
Expand Down