diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-02-13 16:39:58 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-02-13 16:39:58 +0000 |
commit | 7e09679225247fe5869cf15e7ea82632fc8ea037 (patch) | |
tree | 8a2f7e0e2fe0558628a79c8ccb3abc0d6b90fb94 /perl-install | |
parent | 5a046db2174aaa509f4c27315ceabf27d106e951 (diff) | |
download | drakx-7e09679225247fe5869cf15e7ea82632fc8ea037.tar drakx-7e09679225247fe5869cf15e7ea82632fc8ea037.tar.gz drakx-7e09679225247fe5869cf15e7ea82632fc8ea037.tar.bz2 drakx-7e09679225247fe5869cf15e7ea82632fc8ea037.tar.xz drakx-7e09679225247fe5869cf15e7ea82632fc8ea037.zip |
try hard to update_bootloader_for_renumbered_partitions()
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/bootloader.pm | 43 | ||||
-rw-r--r-- | perl-install/diskdrake/interactive.pm | 15 |
2 files changed, 57 insertions, 1 deletions
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index 3b741825f..4ceabb33d 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -1181,4 +1181,47 @@ sub install { $f->($bootloader, $fstab, $hds, $bootloader->{method}); } +sub update_for_renumbered_partitions { + my ($in, $renumbering) = @_; + + my %files = ( + lilo => '/etc/lilo.conf', + grub => '/boot/grub/menu.lst', + grub_install => '/boot/grub/install.sh', + ); + + my %configs = map { + my $f = cat_("$::prefix/$files{$_}"); + $_ => { orig => $f, new => $f, file => $files{$_} }; + } keys %files; + + my $grub2dev = read_grub_device_map(); + my %dev2grub = reverse %$grub2dev; + + foreach (@$renumbering) { + my ($old, $new) = @$_; + my $old_grub = dev2grub($old, \%dev2grub); + my $new_grub = dev2grub($new, \%dev2grub); + log::l("renaming $old -> $new and $old_grub -> $new_grub"); + foreach (values %configs) { + $_->{new} =~ s/\b$old/$new/g; + $_->{new} =~ s/\Q$old_grub/$new_grub/g; + } + } + + any { $_->{orig} ne $_->{new} } values %configs or return 1; # no need to update + + $in->ask_okcancel('', N("Your bootloader configuration must be updated because partition has been renumbered")) or return; + + foreach (values %configs) { + output("$::prefix/$_->{file}", $_->{new}) if $_->{new} ne $_->{orig}; + } + if ($configs{lilo}{orig} ne $configs{lilo}{new} && detect_bootloader() =~ /LILO/ || + $configs{grub_install}{orig} ne $configs{grub_install}{new} && detect_bootloader() =~ /GRUB/) { + $in->ask_warn('', N("The bootloader can't be installed correctly. You have to boot rescue and choose \"%s\"", + N("Re-install Boot Loader"))); + } + 1; +} + 1; diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm index 88b959d1d..80294d42b 100644 --- a/perl-install/diskdrake/interactive.pm +++ b/perl-install/diskdrake/interactive.pm @@ -113,9 +113,10 @@ struct hd { list will_tell_kernel # list of actions to tell to the kernel so that it knows the new partition table bool hasBeenDirty # for undo bool rebootNeeded # happens when a kernel reread failed - bool partitionsRenumbered # happens when you + list partitionsRenumbered # happens when you # - remove an extended partition which is not the last one # - add an extended partition which is the first extended partition + list allPartitionsRenumbered # used to update bootloader configuration int bus, id partition_table_elem primary @@ -270,6 +271,8 @@ sub Done { $all_hds->{current_fstab} = $new; fs::write_fstab($all_hds); } + update_bootloader_for_renumbered_partitions($in, $all_hds); + if (any { $_->{rebootNeeded} } @{$all_hds->{hds}}) { $in->ask_warn('', N("You need to reboot for the partition table modifications to take place")); tell_wm_and_reboot(); @@ -1119,6 +1122,8 @@ sub warn_if_renumbered { my $l = delete $hd->{partitionsRenumbered}; return if is_empty_array_ref($l); + push @{$hd->{allPartitionsRenumbered}}, @$l; + my @l = map { my ($old, $new) = @$_; N("partition %s is now known as %s", $old, $new) } @$l; @@ -1279,3 +1284,11 @@ sub tell_wm_and_reboot() { ), $wm, $pid; } } + +sub update_bootloader_for_renumbered_partitions { + my ($in, $all_hds) = @_; + my @renumbering = map { @{$_->{allPartitionsRenumbered} || []} } @{$all_hds->{hds}} or return; + + require bootloader; + bootloader::update_for_renumbered_partitions($in, \@renumbering); +} |