From cb343e7be6445a643a22992871a76e4911af2c49 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sun, 5 Jul 2015 18:34:45 -0700 Subject: 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. --- nixos/modules/system/boot/loader/grub/install-grub.pl | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'nixos') diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl index e8cd45e8221..c4b1abc8cb0 100644 --- a/nixos/modules/system/boot/loader/grub/install-grub.pl +++ b/nixos/modules/system/boot/loader/grub/install-grub.pl @@ -7,6 +7,7 @@ use File::Path; use File::stat; use File::Copy; use File::Slurp; +use File::Temp; require List::Compare; use POSIX; use Cwd; @@ -506,14 +507,9 @@ my $efiDiffer = $efiTarget ne $prevGrubState->efi; my $efiMountPointDiffer = $efiSysMountPoint ne $prevGrubState->efiMountPoint; 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 -# as the root directory -if (! -l "$bootPath/boot") { - if (-e "$bootPath/boot") { - unlink "$bootPath/boot"; - } - symlink ".", "$bootPath/boot"; -} +# install a symlink so that grub can detect the boot drive +my $tmpDir = File::Temp::tempdir(CLEANUP => 1) or die "Failed to create temporary space"; +symlink "$bootPath", "$tmpDir/boot" or die "Failed to symlink $tmpDir/boot"; # install non-EFI GRUB 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"; print STDERR "installing the GRUB $grubVersion boot loader on $dev...\n"; 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"; } 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"; } } -- cgit 1.4.1