summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2022-10-24 21:07:25 +0100
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2022-10-24 21:07:25 +0100
commit325cbdb1eeff9310c305bfb4c29bf7f03556655f (patch)
treee6e923d3e91ee5925227efc9ad78bf41b99d8431
parentb6ebfb5bc19b5c6c51ade25d8f8c83fe926cbf5a (diff)
downloaddrakx-325cbdb1eeff9310c305bfb4c29bf7f03556655f.tar
drakx-325cbdb1eeff9310c305bfb4c29bf7f03556655f.tar.gz
drakx-325cbdb1eeff9310c305bfb4c29bf7f03556655f.tar.bz2
drakx-325cbdb1eeff9310c305bfb4c29bf7f03556655f.tar.xz
drakx-325cbdb1eeff9310c305bfb4c29bf7f03556655f.zip
Factor out code to mount the efivarfs pseudo-filesystem.
-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