From 4d0805d58380ee8645542919c7b3ea8b2be19114 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 19 Sep 2008 13:36:16 +0000 Subject: create _parse_grub_menu_lst() out of read_grub_menu_lst() nb: no functional change. all computation using $fstab and $grub2dev are moved out of _parse_grub_menu_lst() to read_grub_menu_lst() --- perl-install/bootloader.pm | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'perl-install') diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index cb0839598..1bc6a05ea 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -268,8 +268,7 @@ sub read_grub_install_sh() { \%h; } -sub read_grub_menu_lst { - my ($fstab, $grub2dev) = @_; +sub _parse_grub_menu_lst() { my $global = 1; my ($e, %b); @@ -293,21 +292,17 @@ sub read_grub_menu_lst { push @{$b{entries}}, $e = { label => $v }; $global = 0; } elsif ($global) { - $b{$keyword} = $v eq '' ? 1 : grub2file($v, $grub2dev, $fstab, \%b); + $b{$keyword} = $v; } else { if ($keyword eq 'kernel') { $e->{type} = 'image'; $e->{kernel} = $v; } elsif ($keyword eq 'chainloader') { $e->{type} = 'other'; - $e->{kernel_or_dev} = grub2dev($e->{rootnoverify} || $e->{grub_root}, $grub2dev); $e->{append} = ""; } elsif ($keyword eq 'configfile') { $e->{type} = 'grub_configfile'; - $e->{kernel_or_dev} = grub2dev($e->{rootnoverify} || $e->{grub_root}, $grub2dev); $e->{configfile} = $v; - } elsif ($keyword eq 'initrd') { - $e->{initrd} = grub2file($v, $grub2dev, $fstab, $e); } elsif ($keyword eq 'map') { $e->{mapdrive}{$2} = $1 if $v =~ m/\((.*)\) \((.*)\)/; } elsif ($keyword eq 'module') { @@ -319,8 +314,26 @@ sub read_grub_menu_lst { $e and $e->{verbatim} .= $verbatim; } + %b; +} + +sub read_grub_menu_lst { + my ($fstab, $grub2dev) = @_; + + my %b = _parse_grub_menu_lst(); + + foreach my $keyword (grep { $_ ne 'entries' } keys %b) { + $b{$keyword} = $b{$keyword} eq '' ? 1 : grub2file($b{$keyword}, $grub2dev, $fstab, \%b); + } + #- sanitize foreach my $e (@{$b{entries}}) { + if (member($e->{type}, 'chainloader', 'configfile')) { + $e->{kernel_or_dev} = grub2dev($e->{rootnoverify} || $e->{grub_root}, $grub2dev); + } elsif ($e->{initrd}) { + $e->{initrd} = grub2file($e->{initrd}, $grub2dev, $fstab, $e); + } + if ($e->{kernel} =~ /xen/ && @{$e->{modules} || []} == 2 && $e->{modules}[1] =~ /initrd/) { (my $xen, $e->{xen_append}) = split(' ', $e->{kernel}, 2); ($e->{kernel}, my $initrd) = @{delete $e->{modules}}; -- cgit v1.2.1