summaryrefslogtreecommitdiffstats
path: root/perl-install/any.pm
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2018-09-14 01:01:09 +0100
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2018-09-23 21:19:28 +0100
commit7c1fa8e6d5debac06726cec9d22e1120043ddd5a (patch)
tree57ceb798886764886987ac0c2ba1cbfbe15e4a2d /perl-install/any.pm
parent95e71ef9d338c52bfd99cfd072caf7142cc6e83e (diff)
downloaddrakx-7c1fa8e6d5debac06726cec9d22e1120043ddd5a.tar
drakx-7c1fa8e6d5debac06726cec9d22e1120043ddd5a.tar.gz
drakx-7c1fa8e6d5debac06726cec9d22e1120043ddd5a.tar.bz2
drakx-7c1fa8e6d5debac06726cec9d22e1120043ddd5a.tar.xz
drakx-7c1fa8e6d5debac06726cec9d22e1120043ddd5a.zip
drakboot: add support for the rEFInd boot manager (mga#15153)
Diffstat (limited to 'perl-install/any.pm')
-rw-r--r--perl-install/any.pm86
1 files changed, 80 insertions, 6 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm
index 36d201be6..13229965e 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -377,7 +377,7 @@ sub setupBootloader__mbr_or_not {
}
sub setupBootloader__general {
- my ($in, $b, $all_hds, $_fstab, $_security) = @_;
+ my ($in, $b, $all_hds, $fstab, $_security) = @_;
return if detect_devices::is_xbox();
my @method_choices = bootloader::method_choices($all_hds);
@@ -472,6 +472,54 @@ sub setupBootloader__general {
log::l("switching for lilo to grub, ensure we don't read lilo.conf anymore");
renamef("$::prefix/etc/lilo.conf", "$::prefix/etc/lilo.conf.unused");
}
+ if ($prev_method eq 'refind' && $b->{method} ne 'refind') {
+ log::l("switching from rEFInd, ensure we don't detect refind as the active boot method");
+ renamef("$::prefix/boot/refind_linux.conf", "$::prefix/boot/refind_linux.conf.unused");
+ }
+ if ($b->{method} eq 'refind') {
+ if (bootloader::main_method($prev_method) eq 'grub2') {
+ #- grub2 doesn't provide any entries we can use, so revert to the defaults
+ %$b = ();
+ setupBootloaderBeforeStandalone($in->do_pkgs, $b, $all_hds, $fstab);
+ $b->{method} = 'refind';
+ undef $b->{default};
+ }
+ setupBootloader__refind($in, $b, $fstab);
+ } else {
+ 1;
+ }
+}
+
+sub setupBootloader__refind {
+ my ($in, $b, $fstab) = @_;
+
+ my $already_in_refind = -e "$::prefix/boot/EFI/EFI/refind/refind.conf";
+ my $already_in_default = -e "$::prefix/boot/EFI/EFI/BOOT/refind.conf";
+ my $already_installed = $already_in_refind || $already_in_default;
+
+ my $update_esp = !$already_installed;
+ my $as_default = $already_in_default;
+ $in->ask_from_(
+ {
+ title => N("Bootloader Configuration"),
+ interactive_help_id => 'setupBootloader',
+ },
+ [
+ { text => N("Install or update rEFInd in the EFI system partition"),
+ val => \$update_esp, type => 'bool', disabled => sub { !$already_installed } },
+ { text => N("Install in /EFI/BOOT (workaround for some BIOSs)"),
+ val => \$as_default, type => 'bool', disabled => sub { !$update_esp } },
+ ]
+ ) or return 0;
+
+ if ($update_esp) {
+ $b->{install_mode} = $as_default ? 'as_default' : 'as_refind';
+ } else {
+ $b->{install_mode} = $as_default ? 'no_install' : 'nvram_only';
+ }
+ if (my @esp = grep { $_->{mntpoint} eq '/boot/EFI' } @$fstab) {
+ $b->{esp_device} = $esp[0]{real_device} || fs::wild_device::from_part('', $esp[0]);
+ }
1;
}
@@ -497,7 +545,14 @@ sub setupBootloader__entries {
} @$fstab;
my @l;
- if ($e->{type} eq "image") {
+ if ($b->{method} eq 'refind') {
+ @l = (
+ { label => N("Label"), val => \$e->{label} },
+ { label => N("Append"), val => \$append },
+ { label => N("Video mode"), val => \$vga, list => [ '', Xconfig::resolution_and_depth::bios_vga_modes() ],
+ format => \&Xconfig::resolution_and_depth::to_string, advanced => 1 },
+ );
+ } elsif ($e->{type} eq "image") {
@l = (
{ label => N("Image"), val => \$e->{kernel_or_dev}, list => [ map { "/boot/$_" } bootloader::installed_vmlinuz() ], not_edit => 0 },
{ label => N("Root"), val => \$e->{root}, list => [ map { fs::wild_device::from_part('', $_) } grep { !isSwap($_) } @$fstab ], format => sub { $root_descr{$_[0]} } },
@@ -515,12 +570,13 @@ sub setupBootloader__entries {
{ label => N("Root"), val => \$e->{kernel_or_dev}, list => [ map { "/dev/$_->{device}" } @$fstab, detect_devices::floppies() ] },
);
}
+ if ($b->{method} ne 'refind') {
@l = (
{ label => N("Label"), val => \$e->{label} },
@l,
{ text => N("Default"), val => \$default, type => 'bool' },
);
-
+ }
$in->ask_from_(
{
interactive_help_id => 'setupBootloaderAddEntry',
@@ -546,9 +602,15 @@ sub setupBootloader__entries {
my $Add = sub {
my @labels = map { $_->{label} } @{$b->{entries}};
my ($e, $prefix);
- if ($in->ask_from_list_('', N("Which type of entry do you want to add?"),
- [ N_("Linux"), N_("Other OS (Windows...)") ]
- ) eq "Linux") {
+ if ($b->{method} eq 'refind') {
+ $e = { type => 'image',
+ kernel_or_dev => '/boot/vmlinuz',
+ root => '/dev/' . fs::get::root($fstab)->{device}, #- assume a good default.
+ };
+ $prefix = "linux";
+ } elsif ($in->ask_from_list_('', N("Which type of entry do you want to add?"),
+ [ N_("Linux"), N_("Other OS (Windows...)") ]
+ ) eq "Linux") {
$e = { type => 'image',
root => '/dev/' . fs::get::root($fstab)->{device}, #- assume a good default.
};
@@ -594,6 +656,18 @@ sub setupBootloader__entries {
};
my @prev_entries = @{$b->{entries}};
+
+ #- the rEFInd configuration file just provides alternative kernel command lines
+ #- so we only want to display entries that relate to the default kernel.
+ if ($b->{method} eq 'refind') {
+ @{$b->{entries}} =
+ grep {
+ my $pb = $_->{type} ne 'image' || $_->{kernel_or_dev} ne '/boot/vmlinuz';
+ log::l("dropping bootloader entry $_->{label} because it is not needed by rEFInd") if $pb;
+ !$pb;
+ } @{$b->{entries}};
+ }
+
if ($in->ask_from__add_modify_remove(N("Bootloader Configuration"),
N("Here are the entries on your boot menu so far.
You can create additional entries or change the existing ones."), [ {