diff options
author | William A. Kennington III <william@wkennington.com> | 2015-07-05 18:34:45 -0700 |
---|---|---|
committer | William A. Kennington III <william@wkennington.com> | 2015-07-05 18:34:47 -0700 |
commit | cb343e7be6445a643a22992871a76e4911af2c49 (patch) | |
tree | 1d092e06d93b1d0f141252b36c11e8c43c464cf1 /nixos | |
parent | c61d048427719d6e0c131f58825331df0a9d4ccc (diff) | |
download | nixpkgs-cb343e7be6445a643a22992871a76e4911af2c49.tar nixpkgs-cb343e7be6445a643a22992871a76e4911af2c49.tar.gz nixpkgs-cb343e7be6445a643a22992871a76e4911af2c49.tar.bz2 nixpkgs-cb343e7be6445a643a22992871a76e4911af2c49.tar.lz nixpkgs-cb343e7be6445a643a22992871a76e4911af2c49.tar.xz nixpkgs-cb343e7be6445a643a22992871a76e4911af2c49.tar.zst nixpkgs-cb343e7be6445a643a22992871a76e4911af2c49.zip |
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.
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/system/boot/loader/grub/install-grub.pl | 16 |
1 files changed, 6 insertions, 10 deletions
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"; } } |