diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2007-11-27 10:34:35 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2007-11-27 10:34:35 +0000 |
commit | a5e67c61e1aa38b6fe40d1c4e51f93300236dec4 (patch) | |
tree | 7a4eb3845ee7de5c0067d096f2439549e4c536c5 | |
parent | f3e78a2ebf8c9dbb6bbdf8fd2b062d92e2607a73 (diff) | |
download | drakx-a5e67c61e1aa38b6fe40d1c4e51f93300236dec4.tar drakx-a5e67c61e1aa38b6fe40d1c4e51f93300236dec4.tar.gz drakx-a5e67c61e1aa38b6fe40d1c4e51f93300236dec4.tar.bz2 drakx-a5e67c61e1aa38b6fe40d1c4e51f93300236dec4.tar.xz drakx-a5e67c61e1aa38b6fe40d1c4e51f93300236dec4.zip |
- save bootloader on MBR when calling grub/install.sh, and restore it before
calling it again (#35255) (ie implement "lilo -u" for grub)
-rw-r--r-- | perl-install/bootloader.pm | 33 | ||||
-rw-r--r-- | perl-install/install/NEWS | 2 |
2 files changed, 35 insertions, 0 deletions
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index fee1d22e1..496ac1ee4 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -1685,12 +1685,45 @@ sub sync_partition_data_to_disk { } } +sub _dev_to_MBR_backup { + my ($dev) = @_; + $dev =~ s!/dev/!!; + $dev =~ s!/!_!g; + "$::prefix/boot/boot.backup.$dev"; +} + +sub save_previous_MBR_bootloader { + my ($dev) = @_; + my $t; + open(my $F, $dev); + CORE::read($F, $t, 0x1b8); #- up to disk magic + output(_dev_to_MBR_backup($dev), $t); +} + +sub restore_previous_MBR_bootloader { + my ($dev) = @_; + log::l("restoring previous bootloader on $dev"); + output($dev, scalar cat_(_dev_to_MBR_backup($dev))); +} + sub install_grub { my ($bootloader, $all_hds) = @_; write_grub($bootloader, $all_hds); if (!$::testing) { + if ($bootloader->{previous_boot} && $bootloader->{previous_boot} eq $bootloader->{boot}) { + # nothing to do + } else { + if ($bootloader->{previous_boot}) { + restore_previous_MBR_bootloader(delete $bootloader->{previous_boot}); + } + if (fs::get::device2part($bootloader->{boot}, [ fs::get::hds($all_hds) ])) { + save_previous_MBR_bootloader($bootloader->{boot}); + $bootloader->{previous_boot} = $bootloader->{boot}; + } + } + my @files = grep { /(stage1|stage2|_stage1_5)$/ } glob("$::prefix/lib/grub/*/*"); cp_af(@files, "$::prefix/boot/grub"); sync_partition_data_to_disk(fs::get::root([ fs::get::fstab($all_hds) ], 'boot')); diff --git a/perl-install/install/NEWS b/perl-install/install/NEWS index 4287cfdcf..02ee14218 100644 --- a/perl-install/install/NEWS +++ b/perl-install/install/NEWS @@ -1,3 +1,5 @@ +- save bootloader on MBR when calling grub/install.sh, and restore it before + calling it again (#35255) (ie implement "lilo -u" for grub) - ensure /etc/sysconfig/console/default.kmap is generated with installed keymaps, not installer simplified (?) .bkmap (#35376) - add /etc/mke2fs.conf symlink so that mke2fs can use it (cf #27377) |