summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/bootloader.pm4
-rw-r--r--perl-install/common.pm16
2 files changed, 16 insertions, 4 deletions
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm
index 44376db2b..50b676fc0 100644
--- a/perl-install/bootloader.pm
+++ b/perl-install/bootloader.pm
@@ -2471,9 +2471,7 @@ sub write_refind {
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 ($efivars, $already_mounted) = mount_efivars();
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)) {
diff --git a/perl-install/common.pm b/perl-install/common.pm
index 72ae44d6e..5985c7181 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -10,7 +10,7 @@ use run_program;
use Exporter;
our @ISA = qw(Exporter);
-our @EXPORT = qw($SECTORSIZE N P N_ check_for_xserver files_exist formatTime MB formatXiB get_libdir get_parent_uid is_running is_uefi kernel_uefi_type makedev mageia_release mageia_release_info removeXiBSuffix require_root_capability setVirtual set_alternative set_l10n_sort set_permissions to_utf8 translate uefi_type unmakedev);
+our @EXPORT = qw($SECTORSIZE N P N_ check_for_xserver files_exist formatTime MB formatXiB get_libdir get_parent_uid is_running is_uefi kernel_uefi_type makedev mageia_release mageia_release_info mount_efivars removeXiBSuffix require_root_capability setVirtual set_alternative set_l10n_sort set_permissions to_utf8 translate uefi_type unmakedev);
# perl_checker: RE-EXPORT-ALL
push @EXPORT, @MDK::Common::EXPORT;
@@ -757,6 +757,20 @@ sub uefi_type() {
}
}
+=item mount_efivars()
+
+Ensures the efivarfs pseudo-filesystem is mounted in the default location
+and returns the mount point and whether it was already mounted.
+
+=cut
+
+sub mount_efivars {
+ my $mount_point = '/sys/firmware/efi/efivars';
+ my $already_mounted = cat_("$::prefix/proc/mounts") =~ /$mount_point/;
+ run_program::run('mount', '-t', 'efivarfs', 'none', "$::prefix$mount_point") if !$already_mounted;
+ ("$::prefix$mount_point", $already_mounted);
+}
+
=item cmp_kernel_versions($va, $vb)
Compare two kernel versions