summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/NEWS1
-rw-r--r--perl-install/any.pm5
-rw-r--r--perl-install/bootloader.pm41
-rw-r--r--perl-install/install/NEWS1
4 files changed, 47 insertions, 1 deletions
diff --git a/perl-install/NEWS b/perl-install/NEWS
index f957b43b8..20d64fdd7 100644
--- a/perl-install/NEWS
+++ b/perl-install/NEWS
@@ -1,5 +1,6 @@
- drakboot:
o fix false detection of GRUB2 when installed in ESP but not in /boot (mga#27816)
+ o add option to configure rEFInd to not use EFI NVRAM (mga#27838)
- diskdrake:
o fix adding parts to extended partition on hybrid ISO (mga#27862)
o erase iso9660 signature when clearing hybrid ISO disk (mga#27864)
diff --git a/perl-install/any.pm b/perl-install/any.pm
index bf35e8ec0..24c3575ad 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -509,6 +509,8 @@ sub setupBootloader__refind {
my $update_esp = !$already_installed;
my $as_default = $already_in_default || $b->{removable};
+ my $use_nvram = $b->{use_nvram};
+ $use_nvram //= 1;
$in->ask_from_(
{
title => N("Bootloader Configuration"),
@@ -519,6 +521,8 @@ sub setupBootloader__refind {
val => \$update_esp, type => 'bool', disabled => sub { !$already_installed } },
{ text => N("Install in /EFI/BOOT (removable device or workaround for some BIOSs)"),
val => \$as_default, type => 'bool', disabled => sub { !$update_esp } },
+ { text => N("Configure rEFInd to store its variables in the EFI NVRAM"),
+ val => \$use_nvram, type => 'bool' },
]
) or return 0;
@@ -527,6 +531,7 @@ sub setupBootloader__refind {
} else {
$b->{install_mode} = $as_default ? 'no_install' : 'nvram_only';
}
+ $b->{use_nvram} = $use_nvram;
if (my @esp = grep { $_->{mntpoint} eq '/boot/EFI' } @$fstab) {
$b->{esp_device} = $esp[0]{real_device} || fs::wild_device::from_part('', $esp[0]);
}
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm
index a9f3077a8..85278c547 100644
--- a/perl-install/bootloader.pm
+++ b/perl-install/bootloader.pm
@@ -705,9 +705,19 @@ sub read_refind() {
}
}
$bootloader{method} = 'refind';
+ #- Try both possible locations for the main config file. The default is to use NVRAM if the
+ #- config file isn't found.
+ $bootloader{use_nvram} = get_refind_use_nvram("$::prefix/boot/EFI/EFI/refind/refind.conf")
+ && get_refind_use_nvram("$::prefix/boot/EFI/EFI/BOOT/refind.conf");
\%bootloader;
}
+sub get_refind_use_nvram {
+ my ($path) = @_;
+ #- The default is to use NVRAM, so test if it is explicitly disabled.
+ -r $path && (grep { /^\s*use_nvram\s+(false|off|0)/ } cat_utf8($path)) ? 0 : 1;
+}
+
# FIXME: actually read back previous conf
sub read_cromwell() {
+{ method => 'cromwell' };
@@ -2426,7 +2436,12 @@ sub write_refind {
my $default_kernel = readlink("$::prefix/boot/vmlinuz");
if ($default_kernel) {
- write_refind_previous_boot_var($default_kernel);
+ if ($bootloader->{use_nvram}) {
+ write_refind_previous_boot_var($default_kernel);
+ } else {
+ write_refind_previous_boot_file($default_kernel, "$::prefix/boot/EFI/EFI/refind");
+ write_refind_previous_boot_file($default_kernel, "$::prefix/boot/EFI/EFI/BOOT");
+ }
}
}
@@ -2450,6 +2465,20 @@ sub write_refind_previous_boot_var {
run_program::run('umount', $efivars) if !$already_mounted;
}
+sub write_refind_previous_boot_file {
+ my ($kernel, $base_path) = @_;
+ return if ! -e "$base_path/refind.conf" || ! mkdir_p("$base_path/vars");
+ if (open(my $f, '>:raw', "$base_path/vars/PreviousBoot")) {
+ require Encode;
+ log::l("writing rEFInd $base_path/vars/PreviousBoot file");
+ print $f Encode::encode('UTF16-LE', "Boot boot\\$kernel");
+ print $f "\x00\x00";
+ close($f);
+ } else {
+ log::l("failed to write rEFInd $base_path/vars/PreviousBoot file");
+ }
+}
+
sub install_refind {
my ($bootloader, $all_hds) = @_;
@@ -2469,9 +2498,19 @@ sub install_refind {
run_program::rooted($::prefix, '/sbin/refind-install', '2>', \$error, @options)
or die "refind-install failed: $error";
}
+ #- Try both possible locations for the main config file.
+ set_refind_use_nvram($bootloader->{use_nvram}, "$::prefix/boot/EFI/EFI/refind/refind.conf");
+ set_refind_use_nvram($bootloader->{use_nvram}, "$::prefix/boot/EFI/EFI/BOOT/refind.conf");
write_refind($bootloader, $all_hds);
}
+sub set_refind_use_nvram {
+ my ($use_nvram, $path) = @_;
+ return if ! -w $path;
+ my $script = 's/^#?\s*use_nvram\s+.*/use_nvram ' . ($use_nvram ? 'true' : 'false') . '/';
+ run_program::run('sed', '-i', '-E', $script, $path) or die "failed to update $path";
+}
+
sub when_config_changed_refind {
my ($_bootloader) = @_;
#- do not do anything
diff --git a/perl-install/install/NEWS b/perl-install/install/NEWS
index 974a5d1a2..44afbbb3b 100644
--- a/perl-install/install/NEWS
+++ b/perl-install/install/NEWS
@@ -1,6 +1,7 @@
- bootloader:
o fix false detection of GRUB2 when installed in ESP but not in /boot,
which caused boot method to default to non-graphical GRUB2 (mga#27816)
+ o add option to configure rEFInd to not use EFI NVRAM (mga#27838)
- partitioning:
o erase iso9660 signature when clearing hybrid ISO disk (mga#27864)
- support https in media URL (mga#27776)