summaryrefslogtreecommitdiffstats
path: root/perl-install/bootloader.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-03-21 16:49:14 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-03-21 16:49:14 +0000
commite219385e870764ee4a6b7f9d26e8617eec60f172 (patch)
treea63e34f728c7f83bc6fea4fb3b1f60eef40c0881 /perl-install/bootloader.pm
parent142593316e874567dfaa7164a6a7c36d46ea7f30 (diff)
downloaddrakx-backup-do-not-use-e219385e870764ee4a6b7f9d26e8617eec60f172.tar
drakx-backup-do-not-use-e219385e870764ee4a6b7f9d26e8617eec60f172.tar.gz
drakx-backup-do-not-use-e219385e870764ee4a6b7f9d26e8617eec60f172.tar.bz2
drakx-backup-do-not-use-e219385e870764ee4a6b7f9d26e8617eec60f172.tar.xz
drakx-backup-do-not-use-e219385e870764ee4a6b7f9d26e8617eec60f172.zip
- bootloader-config, drakboot:
o fix device.map if it is not consistent with the system (eg: it says hd0 in sdb whereas it now is sda) (#39160)
Diffstat (limited to 'perl-install/bootloader.pm')
-rw-r--r--perl-install/bootloader.pm28
1 files changed, 26 insertions, 2 deletions
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm
index 845674276..adca7a9d3 100644
--- a/perl-install/bootloader.pm
+++ b/perl-install/bootloader.pm
@@ -209,16 +209,40 @@ sub read_grub {
my ($fstab) = @_;
my $grub2dev = read_grub_device_map();
+ my $boot_root = read_grub_install_sh();
+ _may_fix_grub2dev($fstab, $grub2dev, $boot_root->{root});
my $bootloader = read_grub_menu_lst($fstab, $grub2dev) or return;
- if (my $boot = read_grub_install_sh()->{boot}) {
- $bootloader->{boot} = grub2dev($boot, $grub2dev);
+ if ($boot_root->{boot}) {
+ $bootloader->{boot} = grub2dev($boot_root->{boot}, $grub2dev);
}
$bootloader;
}
+sub _may_fix_grub2dev {
+ my ($fstab, $grub2dev, $root) = @_;
+ my $real_root_part = fs::get::root($fstab);
+
+ if (my $prev_root_part = fs::get::device2part(grub2dev($root, $grub2dev), $fstab)) { # the root_device as far as grub config files say
+ $real_root_part == $prev_root_part and return;
+ }
+
+ log::l("WARNING: we have detected that device.map is inconsistent with the system");
+
+ my $real_root_dev = $real_root_part->{rootDevice};
+
+ my ($hd_grub, undef, undef) = parse_grub_file($root);
+ if (my $prev_hd_grub = find { $grub2dev->{$_} eq $real_root_dev } keys %$grub2dev) {
+ $grub2dev->{$prev_hd_grub} = $grub2dev->{$hd_grub};
+ log::l("swapping result: $hd_grub/$real_root_dev and $prev_hd_grub/$grub2dev->{$hd_grub}");
+ } else {
+ log::l("argh... can't swap, setting $hd_grub to $real_root_dev anyway");
+ }
+ $grub2dev->{$hd_grub} = $real_root_dev;
+}
+
sub read_grub_install_sh() {
my $s = cat_("$::prefix/boot/grub/install.sh");
my %h;