* switch-to-configuration: force a reinstallation of GRUB whenever the

GRUB version changes.  (That's the complete version from the name
  attribute, not the boot.loader.grub.version attribute.)  The current
  version is recorded in /boot/grub/version.  This is required to
  prevent massive breakage when we change the default value of
  boot.loader.grub.version to "2".

svn path=/nixos/trunk/; revision=18997
This commit is contained in:
Eelco Dolstra 2009-12-16 18:11:26 +00:00
parent 48d5ea1077
commit 8d588424d2
3 changed files with 26 additions and 10 deletions

View File

@ -158,6 +158,8 @@ in
environment.systemPackages = mkIf config.boot.loader.grub.enable [ grub ];
system.build.grub = grub;
};
}

View File

@ -21,26 +21,38 @@ EOF
exit 1
fi
if test "$action" = "switch" -o "$action" = "boot"; then
if [ "@bootLoader@" == "grub" ]; then
if test -n "@grubDevice@"; then
# Install or update the bootloader.
if [ "$action" = "switch" -o "$action" = "boot" ]; then
if [ "@bootLoader@" = "grub" ]; then
if [ -n "@grubDevice@" ]; then
mkdir -m 0700 -p /boot/grub
@menuBuilder@ @out@
if test "$NIXOS_INSTALL_GRUB" = 1; then
echo "running \`@grub@/sbin/grub-install'..."
# If the GRUB version has changed, then force a reinstall.
oldGrubVersion="$(cat /boot/grub/version 2>/dev/null || true)"
newGrubVersion="@grubVersion@"
if [ "$NIXOS_INSTALL_GRUB" = 1 -o "$oldGrubVersion" != "$newGrubVersion" ]; then
echo "installing the GRUB bootloader..."
@grub@/sbin/grub-install "@grubDevice@" --no-floppy --recheck
echo "$newGrubVersion" > /boot/grub/version
fi
else
echo "Warning: don't know how to make this configuration bootable; please set \`boot.grubDevice'." 1>&2
fi
elif [ "@bootLoader@" == "generationsDir" ]; then
elif [ "@bootLoader@" = "generationsDir" ]; then
@menuBuilder@ @out@
else
echo "Warning: don't know how to make this configuration bootable; please enable a boot loader." 1>&2
fi
fi
if test "$action" = "switch" -o "$action" = "test"; then
# Activate the new configuration.
if [ "$action" = "switch" -o "$action" = "test" ]; then
oldVersion=$(cat /var/run/current-system/upstart-interface-version 2> /dev/null || echo 0)
newVersion=$(cat @out@/upstart-interface-version 2> /dev/null || echo 0)

View File

@ -122,10 +122,12 @@ let
bootLoader = config.system.boot.loader.id;
grub =
if config.boot.loader.grub.enable
then (if config.boot.loader.grub.version == 1
then pkgs.grub
else pkgs.grub2)
then config.system.build.grub
else null;
grubVersion =
if config.boot.loader.grub.enable
then (builtins.parseDrvName config.system.build.grub.name).version
else "";
grubDevice = config.boot.loader.grub.device;
configurationName = config.boot.loader.grub.configurationName;
};