From 1e2c383108a6ab96a7f968e9b34f1d276e0fe340 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Fri, 7 Dec 2012 11:34:51 +0000 Subject: (parse_grub2_config) introduce it in order to parse grub2 config (from rosa but cleaned) --- perl-install/bootloader.pm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index 0d79777d5..60972d42a 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -2000,6 +2000,43 @@ sub ensure_pkg_is_installed { 1; } +sub parse_grub2_config { + my ($l, $grubcfg, $part) = @_; + + my ($linux, $menuentry, $root, $root_dev, $initrd); + + foreach (cat_($grubcfg)) { + chomp; + if (/^menuentry\s+['"]([^']+)["']/) { + if ($menuentry && $root) { + my $parttype = partition_table::raw::typeOfMBR($root_dev); + if ((!$parttype || $parttype eq "empty") && $linux) { + push @$l, { menuentry => $menuentry, bootpart => $part, root => $root, linux => $linux, initrd => $initrd, grub_conf => $grubcfg }; + } + } + $menuentry = $1; + $root = $linux = undef; + } elsif (/set root='(\([^\)]+\))'/) { + $root = $1; + + if ($root =~ /\(([^,]+),msdos(\d+)\)/) { + my $dev_title = "/" . $1; + my $part_num = $2; + my $dec_part_num = $part_num-1; + $dev_title =~ s!hd!dev/sd!; + $dev_title =~ tr/0123456789/abcdefghi/; + + $root_dev = $part_num ? $dev_title . $part_num : $dev_title; + $root =~ s/msdos$part_num/$dec_part_num/; + } + } elsif (/^\s+linux\s+(.+)/) { + $linux = $1; + } elsif (/^\s+initrd\s+(.+)/) { + $initrd = $1; + } + } +} + sub find_other_distros_grub_conf { my ($fstab) = @_; -- cgit v1.2.1