summaryrefslogtreecommitdiffstats
path: root/perl-install/bootloader.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-09-06 13:46:10 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-09-06 13:46:10 +0000
commite4574304c36e42356547919bffdfea895a265635 (patch)
treed96ffc1ef75454f6d020c943db45f8ee48afa3a5 /perl-install/bootloader.pm
parent50386a6e0778cb7ad87254d004e0536da3ba904d (diff)
downloaddrakx-backup-do-not-use-e4574304c36e42356547919bffdfea895a265635.tar
drakx-backup-do-not-use-e4574304c36e42356547919bffdfea895a265635.tar.gz
drakx-backup-do-not-use-e4574304c36e42356547919bffdfea895a265635.tar.bz2
drakx-backup-do-not-use-e4574304c36e42356547919bffdfea895a265635.tar.xz
drakx-backup-do-not-use-e4574304c36e42356547919bffdfea895a265635.zip
(read): cleanup duplicate labels (in case file is corrupted)
(get_label): compare labels using 15 first characters (to be compliant with lilo) (add_entry): fix removing duplicate entries
Diffstat (limited to 'perl-install/bootloader.pm')
-rw-r--r--perl-install/bootloader.pm18
1 files changed, 13 insertions, 5 deletions
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm
index df2020bb6..837908c57 100644
--- a/perl-install/bootloader.pm
+++ b/perl-install/bootloader.pm
@@ -47,7 +47,7 @@ sub get {
}
sub get_label {
my ($label, $bootloader) = @_;
- $_->{label} && $_->{label} eq $label and return $_ foreach @{$bootloader->{entries}};
+ $_->{label} && substr($_->{label}, 0, 15) eq substr($label, 0, 15) and return $_ foreach @{$bootloader->{entries}};
undef;
}
@@ -121,6 +121,11 @@ sub read() {
$b{timeout} = $b{timeout} / 10 if $b{timeout};
$b{message} = cat_("$::prefix$b{message}") if $b{message};
}
+
+ #- cleanup duplicate labels (in case file is corrupted)
+ my %seen;
+ @{$b{entries}} = grep { !$seen{$_->{label}}++ } @{$b{entries}};
+
\%b;
}
@@ -159,15 +164,18 @@ sub add_entry {
foreach my $label ($v->{label}, map { 'old' . $_ . '_' . $v->{label} } ('', 2..10)) {
my $conflicting = get_label($label, $bootloader);
+ $to_add->{label} = $label;
+
if ($conflicting) {
#- replacing $conflicting with $to_add
- $to_add->{label} = $label;
@{$bootloader->{entries}} = map { $_ == $conflicting ? $to_add : $_ } @{$bootloader->{entries}};
- }
- if (!$conflicting || same_entries($conflicting, $to_add)) {
+ } else {
#- we have found an unused label
- $to_add->{label} = $label;
push @{$bootloader->{entries}}, $to_add;
+ }
+
+ if (!$conflicting || same_entries($conflicting, $to_add)) {
+ log::l("current labels: " . join(" ", map { $_->{label} } @{$bootloader->{entries}}));
return $v;
}
$to_add = $conflicting;