From 3b095707824aa4ac965e92866b919334f8b103ec Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 13 Sep 2005 10:40:19 +0000 Subject: - create cleanup_entries() which remove bad entries (and more verbosely than was done for lilo.conf) and call it for all bootloaders (was only for lilo) - keep removing duplicate labels only for lilo (and use uniq_) (don't do it for grub since duplicate labels are allowed (???)) --- perl-install/bootloader.pm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'perl-install') diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index 26e3d40c0..a17337d3b 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -149,6 +149,8 @@ sub read { my $f = $bootloader::{"read_$main_method"} or die "unknown bootloader method $main_method (read)"; my $bootloader = $f->($fstab); + cleanup_entries($bootloader); + my @devs = $bootloader->{boot}; if ($bootloader->{'raid-extra-boot'} =~ /mbr/ && (my $md = fs::get::device2part($bootloader->{boot}, $all_hds->{raids}))) { @@ -360,15 +362,24 @@ sub read_lilo() { $b{method} = 'lilo-' . (member($b{install}, 'text', 'menu', 'graphic') ? $b{install} : 'graphic'); } - #- cleanup duplicate labels & bad entries (in case file is corrupted) - my %seen; - @{$b{entries}} = - grep { !$seen{$_->{label}}++ } - grep { $_->{type} ne 'image' || -e "$::prefix$_->{kernel_or_dev}" } @{$b{entries}}; + # cleanup duplicate labels (in case file is corrupted) + @{$b{entries}} = uniq_ { $_->{label} } @{$b{entries}}; \%b; } +sub cleanup_entries { + my ($bootloader) = @_; + + #- cleanup bad entries (in case file is corrupted) + @{$bootloader->{entries}} = + grep { + my $pb = $_->{type} eq 'image' && dirname($_->{kernel_or_dev}) eq '/boot' && ! -e "$::prefix$_->{kernel_or_dev}"; + log::l("dropping bootloader entry $_->{label} since $_->{kernel_or_dev} doesn't exist") if $pb; + !$pb; + } @{$bootloader->{entries}}; +} + sub suggest_onmbr { my ($hd) = @_; -- cgit v1.2.1