diff options
-rw-r--r-- | perl-install/NEWS | 1 | ||||
-rw-r--r-- | perl-install/bootloader.pm | 18 | ||||
-rw-r--r-- | perl-install/install/NEWS | 1 |
3 files changed, 17 insertions, 3 deletions
diff --git a/perl-install/NEWS b/perl-install/NEWS index b3acdf2da..fc21d2d3f 100644 --- a/perl-install/NEWS +++ b/perl-install/NEWS @@ -1,5 +1,6 @@ - drakboot: o add support for crypted grub2 passwords + o grub2: fix setting default entry when in a submenu (mga#18560) Version 17.41 - 20 June 2016 diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index 2f379bd0b..ef0237323 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -313,10 +313,11 @@ sub read_grub2() { $bootloader{entries} = []; my $entry; my $f = "$::prefix/boot/grub2/grub.cfg"; + my @menus; foreach (cat_utf8($f)) { next if /^#/; if (/menuentry\s+['"]([^']+)["']/) { - $entry = { label => $1 }; + $entry = { label => $1, real_label => join('>', @menus, $1) }; } elsif (/linux\s+(\S+)\s+(.*)?/ || /module\s+(\S+vmlinu\S+)\s+(.*)?/) { $entry->{type} = 'image'; @$entry{qw(kernel_or_dev append)} = ($1, $2); @@ -327,10 +328,14 @@ sub read_grub2() { } } elsif (/initrd\s+(\S+)/ || /module\s+(\S+initrd\S+)\s+(.*)?/) { $entry->{initrd} = $1; + } elsif (/^submenu\s+['"]([^']+)["']/) { + push @menus, $1; } elsif (/}/) { if ($entry) { - push @{$bootloader{entries}}, $entry ; + push @{$bootloader{entries}}, $entry; undef $entry; + } else { + pop @menus; } } } @@ -338,6 +343,7 @@ sub read_grub2() { # get default entry: foreach (run_program::rooted_get_stdout($::prefix, qw(grub2-editenv list))) { $bootloader{default} = $1 if /saved_entry=(.*)/; + $bootloader{default} =~ s/.*>//; # strip full menu entry path } # Get password prior to run update-grub2: @@ -1876,11 +1882,17 @@ sub write_grub2 { run_program::rooted($::prefix, 'update-grub2', '2>', \$error) or die "update-grub2 failed: $error"; log::l("update-grub2 logs: $error"); + my $default = $bootloader->{default}; + # menu entry must be identified by its full path. eg: "submenu1>submenu2>title": + if (my $def = find { $_->{label} eq $bootloader->{default} } @{$bootloader->{entries}}) { + $default = $def->{real_label} if $def->{real_label}; + } + # set default entry: eval { my $f2 = "$::prefix/boot/grub2/grubenv"; cp_af($f2, $f2 . ($o_backup_extension || '.old')); - run_program::rooted($::prefix, 'grub2-set-default', '2>', \$error, $bootloader->{default}) or die "grub2-set-default failed: $error"; + run_program::rooted($::prefix, 'grub2-set-default', '2>', \$error, $default) or die "grub2-set-default failed: $error"; }; if (my $err = $@) { log::l("error while running grub2-set-default: $err"); diff --git a/perl-install/install/NEWS b/perl-install/install/NEWS index 9b55ba7b2..9d7a92e8c 100644 --- a/perl-install/install/NEWS +++ b/perl-install/install/NEWS @@ -1,5 +1,6 @@ - bootloader configuration: o add support for crypted grub2 passwords + o grub2: fix setting default entry when in a submenu (mga#18560) Version 17.41 - 20 June 2016 |