mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-12 05:16:25 +03:00
nixos/install-grub: Fix symlink installation for boot filesystems which don't support symlinking
Some filesystems like fat32 don't support symlinking and need to be supported on /boot as an efi system partition. Instead of creating the symlink directly in boot, create the symlink in a temporary directory which has to support symlinking.
This commit is contained in:
parent
c61d048427
commit
cb343e7be6
1 changed files with 6 additions and 10 deletions
|
@ -7,6 +7,7 @@ use File::Path;
|
||||||
use File::stat;
|
use File::stat;
|
||||||
use File::Copy;
|
use File::Copy;
|
||||||
use File::Slurp;
|
use File::Slurp;
|
||||||
|
use File::Temp;
|
||||||
require List::Compare;
|
require List::Compare;
|
||||||
use POSIX;
|
use POSIX;
|
||||||
use Cwd;
|
use Cwd;
|
||||||
|
@ -506,14 +507,9 @@ my $efiDiffer = $efiTarget ne $prevGrubState->efi;
|
||||||
my $efiMountPointDiffer = $efiSysMountPoint ne $prevGrubState->efiMountPoint;
|
my $efiMountPointDiffer = $efiSysMountPoint ne $prevGrubState->efiMountPoint;
|
||||||
my $requireNewInstall = $devicesDiffer || $nameDiffer || $versionDiffer || $efiDiffer || $efiMountPointDiffer || (($ENV{'NIXOS_INSTALL_GRUB'} // "") eq "1");
|
my $requireNewInstall = $devicesDiffer || $nameDiffer || $versionDiffer || $efiDiffer || $efiMountPointDiffer || (($ENV{'NIXOS_INSTALL_GRUB'} // "") eq "1");
|
||||||
|
|
||||||
# install a symlink so that grub can detect the boot drive when set
|
# install a symlink so that grub can detect the boot drive
|
||||||
# as the root directory
|
my $tmpDir = File::Temp::tempdir(CLEANUP => 1) or die "Failed to create temporary space";
|
||||||
if (! -l "$bootPath/boot") {
|
symlink "$bootPath", "$tmpDir/boot" or die "Failed to symlink $tmpDir/boot";
|
||||||
if (-e "$bootPath/boot") {
|
|
||||||
unlink "$bootPath/boot";
|
|
||||||
}
|
|
||||||
symlink ".", "$bootPath/boot";
|
|
||||||
}
|
|
||||||
|
|
||||||
# install non-EFI GRUB
|
# install non-EFI GRUB
|
||||||
if (($requireNewInstall != 0) && ($efiTarget eq "no" || $efiTarget eq "both")) {
|
if (($requireNewInstall != 0) && ($efiTarget eq "no" || $efiTarget eq "both")) {
|
||||||
|
@ -521,10 +517,10 @@ if (($requireNewInstall != 0) && ($efiTarget eq "no" || $efiTarget eq "both")) {
|
||||||
next if $dev eq "nodev";
|
next if $dev eq "nodev";
|
||||||
print STDERR "installing the GRUB $grubVersion boot loader on $dev...\n";
|
print STDERR "installing the GRUB $grubVersion boot loader on $dev...\n";
|
||||||
if ($grubTarget eq "") {
|
if ($grubTarget eq "") {
|
||||||
system("$grub/sbin/grub-install", "--recheck", "--root-directory=$bootPath", Cwd::abs_path($dev)) == 0
|
system("$grub/sbin/grub-install", "--recheck", "--root-directory=$tmpDir", Cwd::abs_path($dev)) == 0
|
||||||
or die "$0: installation of GRUB on $dev failed\n";
|
or die "$0: installation of GRUB on $dev failed\n";
|
||||||
} else {
|
} else {
|
||||||
system("$grub/sbin/grub-install", "--recheck", "--root-directory=$bootPath", "--target=$grubTarget", Cwd::abs_path($dev)) == 0
|
system("$grub/sbin/grub-install", "--recheck", "--root-directory=$tmpDir", "--target=$grubTarget", Cwd::abs_path($dev)) == 0
|
||||||
or die "$0: installation of GRUB on $dev failed\n";
|
or die "$0: installation of GRUB on $dev failed\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue