install-grub.pl: avoid double '/' in menu.lst and grub.conf (#45907)

Although double '/' in paths is not a problem for GRUB supplied with nixpkgs, sometimes NixOS's grub.conf read by external GRUB and there are versions of GRUB which fail

volth a9a8043b 6a7cd788

Changed files
+4 -4
nixos
modules
system
boot
loader
+4 -4
nixos/modules/system/boot/loader/grub/install-grub.pl
···
";
if ($splashImage) {
copy $splashImage, "$bootPath/background.xpm.gz" or die "cannot copy $splashImage to $bootPath\n";
-
$conf .= "splashimage " . $grubBoot->path . "/background.xpm.gz\n";
+
$conf .= "splashimage " . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/background.xpm.gz\n";
}
}
···
copy $font, "$bootPath/converted-font.pf2" or die "cannot copy $font to $bootPath\n";
$conf .= "
insmod font
-
if loadfont " . $grubBoot->path . "/converted-font.pf2; then
+
if loadfont " . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/converted-font.pf2; then
insmod gfxterm
if [ \"\${grub_platform}\" = \"efi\" ]; then
set gfxmode=$gfxmodeEfi
···
copy $splashImage, "$bootPath/background$suffix" or die "cannot copy $splashImage to $bootPath\n";
$conf .= "
insmod " . substr($suffix, 1) . "
-
if background_image --mode '$splashMode' " . $grubBoot->path . "/background$suffix; then
+
if background_image --mode '$splashMode' " . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/background$suffix; then
set color_normal=white/black
set color_highlight=black/white
else
···
rename $tmp, $dst or die "cannot rename $tmp to $dst\n";
}
$copied{$dst} = 1;
-
return $grubBoot->path . "/kernels/$name";
+
return ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/kernels/$name";
}
sub addEntry {