nixos/install-grub: fix whitespace

This time hopefully without changing the generated boot script.
This commit is contained in:
Dominik Xaver Hörl
2021-02-21 09:24:23 +01:00
parent 19447850a2
commit 0360e03520

View File

@@ -164,7 +164,7 @@ sub GrubFs {
my $fs = GetFs($dir); my $fs = GetFs($dir);
my $path = substr($dir, length($fs->mount)); my $path = substr($dir, length($fs->mount));
if (substr($path, 0, 1) ne "/") { if (substr($path, 0, 1) ne "/") {
$path = "/$path"; $path = "/$path";
} }
my $search = ""; my $search = "";
@@ -371,11 +371,11 @@ else {
if ($suffix eq ".jpg") { if ($suffix eq ".jpg") {
$suffix = ".jpeg"; $suffix = ".jpeg";
} }
if ($backgroundColor) { if ($backgroundColor) {
$conf .= " $conf .= "
background_color '$backgroundColor' background_color '$backgroundColor'
"; ";
} }
copy $splashImage, "$bootPath/background$suffix" or die "cannot copy $splashImage to $bootPath: $!\n"; copy $splashImage, "$bootPath/background$suffix" or die "cannot copy $splashImage to $bootPath: $!\n";
$conf .= " $conf .= "
insmod " . substr($suffix, 1) . " insmod " . substr($suffix, 1) . "
@@ -399,17 +399,17 @@ else {
set theme=" . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/theme/theme.txt set theme=" . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/theme/theme.txt
export theme export theme
# Load theme fonts, if any # Load theme fonts, if any
"; ";
find( { wanted => sub { find( { wanted => sub {
if ($_ =~ /\.pf2$/i) { if ($_ =~ /\.pf2$/i) {
$font = File::Spec->abs2rel($File::Find::name, $theme); $font = File::Spec->abs2rel($File::Find::name, $theme);
$conf .= " $conf .= "
loadfont " . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/theme/$font loadfont " . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/theme/$font
"; ";
} }
}, no_chdir => 1 }, $theme ); }, no_chdir => 1 }, $theme );
} }
} }
$conf .= "$extraConfig\n"; $conf .= "$extraConfig\n";
@@ -448,25 +448,25 @@ sub addEntry {
# Include second initrd with secrets # Include second initrd with secrets
if (-e -x "$path/append-initrd-secrets") { if (-e -x "$path/append-initrd-secrets") {
my $initrdName = basename($initrd); my $initrdName = basename($initrd);
my $initrdSecretsPath = "$bootPath/kernels/$initrdName-secrets"; my $initrdSecretsPath = "$bootPath/kernels/$initrdName-secrets";
mkpath(dirname($initrdSecretsPath), 0, 0755); mkpath(dirname($initrdSecretsPath), 0, 0755);
my $oldUmask = umask; my $oldUmask = umask;
# Make sure initrd is not world readable (won't work if /boot is FAT) # Make sure initrd is not world readable (won't work if /boot is FAT)
umask 0137; umask 0137;
my $initrdSecretsPathTemp = File::Temp::mktemp("$initrdSecretsPath.XXXXXXXX"); my $initrdSecretsPathTemp = File::Temp::mktemp("$initrdSecretsPath.XXXXXXXX");
system("$path/append-initrd-secrets", $initrdSecretsPathTemp) == 0 or die "failed to create initrd secrets: $!\n"; system("$path/append-initrd-secrets", $initrdSecretsPathTemp) == 0 or die "failed to create initrd secrets: $!\n";
# Check whether any secrets were actually added # Check whether any secrets were actually added
if (-e $initrdSecretsPathTemp && ! -z _) { if (-e $initrdSecretsPathTemp && ! -z _) {
rename $initrdSecretsPathTemp, $initrdSecretsPath or die "failed to move initrd secrets into place: $!\n"; rename $initrdSecretsPathTemp, $initrdSecretsPath or die "failed to move initrd secrets into place: $!\n";
$copied{$initrdSecretsPath} = 1; $copied{$initrdSecretsPath} = 1;
$initrd .= " " . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/kernels/$initrdName-secrets"; $initrd .= " " . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/kernels/$initrdName-secrets";
} else { } else {
unlink $initrdSecretsPathTemp; unlink $initrdSecretsPathTemp;
rmdir dirname($initrdSecretsPathTemp); rmdir dirname($initrdSecretsPathTemp);
} }
umask $oldUmask; umask $oldUmask;
} }
my $xen = -e "$path/xen.gz" ? copyToKernelsDir(Cwd::abs_path("$path/xen.gz")) : undef; my $xen = -e "$path/xen.gz" ? copyToKernelsDir(Cwd::abs_path("$path/xen.gz")) : undef;
@@ -587,7 +587,7 @@ $extraPrepareConfig =~ s/\@bootPath\@/$bootPath/g;
# Run extraPrepareConfig in sh # Run extraPrepareConfig in sh
if ($extraPrepareConfig ne "") { if ($extraPrepareConfig ne "") {
system((get("shell"), "-c", $extraPrepareConfig)); system((get("shell"), "-c", $extraPrepareConfig));
} }
# write the GRUB config. # write the GRUB config.