summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/bootloader.pm37
1 files changed, 21 insertions, 16 deletions
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm
index d4533da39..a9f3077a8 100644
--- a/perl-install/bootloader.pm
+++ b/perl-install/bootloader.pm
@@ -2426,23 +2426,28 @@ sub write_refind {
my $default_kernel = readlink("$::prefix/boot/vmlinuz");
if ($default_kernel) {
- my $efivars = '/sys/firmware/efi/efivars';
- my $already_mounted = cat_('/proc/mounts') =~ /$efivars/;
- run_program::run('mount', '-t', 'efivarfs', 'none', $efivars) if !$already_mounted;
- my $previous_boot = "$efivars/PreviousBoot-36d08fa7-cf0b-42f5-8f14-68df73ed3740";
- run_program::run('chattr', '-i', $previous_boot) if -e $previous_boot;
- if (open(my $efivar, '>:raw', $previous_boot)) {
- require Encode;
- log::l("writing rEFInd PreviousBoot variable");
- print $efivar "\x07\x00\x00\x00";
- print $efivar Encode::encode('UTF16-LE', $default_kernel);
- print $efivar "\x00\x00";
- close($efivar);
- } else {
- log::l("failed to write rEFInd PreviousBoot variable: $@ ($!)");
- }
- run_program::run('umount', $efivars) if !$already_mounted;
+ write_refind_previous_boot_var($default_kernel);
+ }
+}
+
+sub write_refind_previous_boot_var {
+ my ($kernel) = @_;
+ my $efivars = '/sys/firmware/efi/efivars';
+ my $already_mounted = cat_('/proc/mounts') =~ /$efivars/;
+ run_program::run('mount', '-t', 'efivarfs', 'none', $efivars) if !$already_mounted;
+ my $previous_boot = "$efivars/PreviousBoot-36d08fa7-cf0b-42f5-8f14-68df73ed3740";
+ run_program::run('chattr', '-i', $previous_boot) if -e $previous_boot;
+ if (open(my $efivar, '>:raw', $previous_boot)) {
+ require Encode;
+ log::l("writing rEFInd PreviousBoot variable");
+ print $efivar "\x07\x00\x00\x00";
+ print $efivar Encode::encode('UTF16-LE', $kernel);
+ print $efivar "\x00\x00";
+ close($efivar);
+ } else {
+ log::l("failed to write rEFInd PreviousBoot variable: $@ ($!)");
}
+ run_program::run('umount', $efivars) if !$already_mounted;
}
sub install_refind {