diff options
author | Thomas Strobel <ts468@cam.ac.uk> | 2015-07-05 18:54:35 +0200 |
---|---|---|
committer | Thomas Strobel <ts468@cam.ac.uk> | 2015-07-05 19:51:53 +0200 |
commit | 65cbbc75b0f9c91037c7eb8e82fea9a48fb2d96e (patch) | |
tree | 867f10a99ef71baa5a42099e63b995f6890db766 /nixos/modules/system/boot/loader/grub/install-grub.pl | |
parent | d7869f46ca107535fd6c975b6a4c91537628bfbd (diff) | |
download | nixlib-65cbbc75b0f9c91037c7eb8e82fea9a48fb2d96e.tar nixlib-65cbbc75b0f9c91037c7eb8e82fea9a48fb2d96e.tar.gz nixlib-65cbbc75b0f9c91037c7eb8e82fea9a48fb2d96e.tar.bz2 nixlib-65cbbc75b0f9c91037c7eb8e82fea9a48fb2d96e.tar.lz nixlib-65cbbc75b0f9c91037c7eb8e82fea9a48fb2d96e.tar.xz nixlib-65cbbc75b0f9c91037c7eb8e82fea9a48fb2d96e.tar.zst nixlib-65cbbc75b0f9c91037c7eb8e82fea9a48fb2d96e.zip |
grub installation: integrate trustedGRUB + fix broken equality check
Diffstat (limited to 'nixos/modules/system/boot/loader/grub/install-grub.pl')
-rw-r--r-- | nixos/modules/system/boot/loader/grub/install-grub.pl | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl index cad9013bf5ad..de0a4c7f0567 100644 --- a/nixos/modules/system/boot/loader/grub/install-grub.pl +++ b/nixos/modules/system/boot/loader/grub/install-grub.pl @@ -433,15 +433,18 @@ foreach my $fn (glob "$bootPath/kernels/*") { # struct(GrubState => { + name => '$', version => '$', efi => '$', devices => '$', efiMountPoint => '$', }); sub readGrubState { - my $defaultGrubState = GrubState->new(version => "", efi => "", devices => "", efiMountPoint => "" ); + my $defaultGrubState = GrubState->new(name => "", version => "", efi => "", devices => "", efiMountPoint => "" ); open FILE, "<$bootPath/grub/state" or return $defaultGrubState; local $/ = "\n"; + my $name = <FILE>; + chomp($name); my $version = <FILE>; chomp($version); my $efi = <FILE>; @@ -451,7 +454,7 @@ sub readGrubState { my $efiMountPoint = <FILE>; chomp($efiMountPoint); close FILE; - my $grubState = GrubState->new(version => $version, efi => $efi, devices => $devices, efiMountPoint => $efiMountPoint ); + my $grubState = GrubState->new(name => $name, version => $version, efi => $efi, devices => $devices, efiMountPoint => $efiMountPoint ); return $grubState } @@ -497,10 +500,11 @@ my $prevGrubState = readGrubState(); my @prevDeviceTargets = split/:/, $prevGrubState->devices; my $devicesDiffer = scalar (List::Compare->new( '-u', '-a', \@deviceTargets, \@prevDeviceTargets)->get_symmetric_difference() ); -my $versionDiffer = (get("fullVersion") eq \$prevGrubState->version); -my $efiDiffer = ($efiTarget eq \$prevGrubState->efi); -my $efiMountPointDiffer = ($efiSysMountPoint eq \$prevGrubState->efiMountPoint); -my $requireNewInstall = $devicesDiffer || $versionDiffer || $efiDiffer || $efiMountPointDiffer || (($ENV{'NIXOS_INSTALL_GRUB'} // "") eq "1"); +my $nameDiffer = !(get("fullName") eq $prevGrubState->name); +my $versionDiffer = !(get("fullVersion") eq $prevGrubState->version); +my $efiDiffer = !($efiTarget eq $prevGrubState->efi); +my $efiMountPointDiffer = !($efiSysMountPoint eq $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 @@ -543,6 +547,7 @@ if (($requireNewInstall != 0) && ($efiTarget eq "only" || $efiTarget eq "both")) # update GRUB state file if ($requireNewInstall != 0) { open FILE, ">$bootPath/grub/state" or die "cannot create $bootPath/grub/state: $!\n"; + print FILE get("fullName"), "\n" or die; print FILE get("fullVersion"), "\n" or die; print FILE $efiTarget, "\n" or die; print FILE join( ":", @deviceTargets ), "\n" or die; |