From 51c97621ccb1790cd125800af1add6a3c47c7869 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 26 Nov 2007 12:17:34 +0000 Subject: - bootloader: o handle "alien" grub entries that will be kept verbatim (#23591) --- perl-install/NEWS | 1 + perl-install/bootloader.pm | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/perl-install/NEWS b/perl-install/NEWS index e2dfe4854..85e8dbf44 100644 --- a/perl-install/NEWS +++ b/perl-install/NEWS @@ -1,6 +1,7 @@ - bootloader: o when reading existing menu.lst, keep verbatim entries for which the device has no mount-point + o handle "alien" grub entries that will be kept verbatim (#23591) o handle "root (hd...)" for menu.lst entries (#23591) (nb: when writing, "root ..." will not be used) - diskdrake: diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index b6f8a8938..fee1d22e1 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -239,6 +239,7 @@ sub read_grub_menu_lst { -e $menu_lst_file or return; foreach (cat_($menu_lst_file)) { + my $verbatim = $_; chomp; s/^\s*//; s/\s*$//; next if /^#/ || /^$/; @@ -273,6 +274,7 @@ sub read_grub_menu_lst { $e->{$keyword} = $v eq '' ? 1 : $v; } } + $e and $e->{verbatim} .= $verbatim; } #- sanitize @@ -288,6 +290,7 @@ sub read_grub_menu_lst { $e->{append} = join(' ', grep { !/^BOOT_IMAGE=/ } split(' ', $e->{append})); $e->{root} = $1 if $e->{append} =~ s/root=(\S*)\s*//; $e->{kernel_or_dev} = grub2file($kernel, $grub2dev, $fstab, $e); + $e->{keep_verbatim} = 1 if dirname($e->{kernel_or_dev}) ne '/boot'; } my ($vga, $other) = partition { /^vga=/ } split(' ', $e->{append}); if (@$vga) { @@ -433,7 +436,7 @@ sub cleanup_entries { #- 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}"; + my $pb = $_->{type} eq 'image' && !$_->{keep_verbatim} && ! -e "$::prefix$_->{kernel_or_dev}"; log::l("dropping bootloader entry $_->{label} since $_->{kernel_or_dev} doesn't exist") if $pb; !$pb; } @{$bootloader->{entries}}; @@ -1600,7 +1603,9 @@ sub write_grub { foreach my $entry (@{$bootloader->{entries}}) { my $title = "\ntitle $entry->{label}"; - if ($entry->{type} eq "image") { + if ($entry->{keep_verbatim}) { + push @conf, '', $entry->{verbatim}; + } elsif ($entry->{type} eq "image") { push @conf, $title; push @conf, grep { $entry->{$_} } 'lock'; push @conf, join(' ', 'kernel', $file2grub->($entry->{xen}), $entry->{xen_append}) if $entry->{xen}; -- cgit v1.2.1