From f8c5002658cd61df336e6862376dea73d5c852eb Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 16 Aug 2002 17:31:36 +0000 Subject: (add_entry): new entry will now keep its label, the conflicting one will be renamed "old_xxx" (and not the opposite) --- perl-install/bootloader.pm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'perl-install/bootloader.pm') diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index 274abe8ef..57524dd1c 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -148,19 +148,22 @@ sub same_entries { sub add_entry { my ($bootloader, $v) = @_; + my $to_add = $v; foreach my $label ($v->{label}, map { 'old' . $_ . '_' . $v->{label} } ('', 2..10)) { my $conflicting = get_label($label, $bootloader); - if ($conflicting && same_entries($conflicting, $v)) { - #- removing $conflicting. - #- It's better than better $conflicting and not adding $v because same_entries can match not so same entries, esp. regarding symlinks - @{$bootloader->{entries}} = grep { $_ != $conflicting } @{$bootloader->{entries}}; - undef $conflicting; + + if ($conflicting) { + #- replacing $conflicting with $to_add + $to_add->{label} = $label; + @{$bootloader->{entries}} = map { $_ == $conflicting ? $to_add : $_ } @{$bootloader->{entries}}; } - if (!$conflicting) { - $v->{label} = $label; - push @{$bootloader->{entries}}, $v; + if (!$conflicting || same_entries($conflicting, $to_add)) { + #- we have found an unused label + $to_add->{label} = $label; + push @{$bootloader->{entries}}, $to_add; return $v; } + $to_add = $conflicting; } die 'add_entry'; } -- cgit v1.2.1