diff options
author | Thierry Vignaud <tv@mageia.org> | 2012-12-07 11:34:51 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mageia.org> | 2012-12-07 11:34:51 +0000 |
commit | 1e2c383108a6ab96a7f968e9b34f1d276e0fe340 (patch) | |
tree | 983289ba0b45af85a89ee82140009123382527d7 /perl-install | |
parent | a0256593c7c7503728dcf032b7f84b35c2d8c8da (diff) | |
download | drakx-1e2c383108a6ab96a7f968e9b34f1d276e0fe340.tar drakx-1e2c383108a6ab96a7f968e9b34f1d276e0fe340.tar.gz drakx-1e2c383108a6ab96a7f968e9b34f1d276e0fe340.tar.bz2 drakx-1e2c383108a6ab96a7f968e9b34f1d276e0fe340.tar.xz drakx-1e2c383108a6ab96a7f968e9b34f1d276e0fe340.zip |
(parse_grub2_config) introduce it in order to parse grub2 config
(from rosa but cleaned)
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/bootloader.pm | 37 |
1 files changed, 37 insertions, 0 deletions
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) = @_; |