From 77cc147f451be2508163eec9fb1447fd75ca898f Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Thu, 4 Jan 2024 17:17:19 +0100 Subject: (get_grub2_pkg) split it out --- perl-install/bootloader.pm | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index ad7850d40..d1d757c3d 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -2637,6 +2637,20 @@ sub install { run_program::run('umount', $efivars) if is_uefi() && !$already_mounted; } +sub get_grub2_pkg() { + my ($prefix, $pkg); + if (is_uefi()) { + my %convert = (ia32 => 'i386', aa64 => 'arm64', x64 => 'x86_64'); + my %pkgs = (ia32 => 'x86-32', aa64 => 'aarch-64', x64 => 'x86-64'); + $prefix = $convert{uefi_type()} . "-efi"; + $pkg = "grub2-efi(" . $pkgs{uefi_type()} . ")"; + } else { + $prefix = 'i386-pc'; + $pkg = 'grub2'; + } + ($prefix, $pkg); +} + sub ensure_pkg_is_installed { my ($do_pkgs, $bootloader) = @_; @@ -2647,16 +2661,7 @@ sub ensure_pkg_is_installed { ); my $main_method = main_method($bootloader->{method}); if ($main_method eq 'grub2') { - my ($prefix, $pkg); - if (is_uefi()) { - my %convert = (ia32 => 'i386', aa64 => 'arm64', x64 => 'x86_64'); - my %pkgs = (ia32 => 'x86-32', aa64 => 'aarch-64', x64 => 'x86-64'); - $prefix = $convert{uefi_type()} . "-efi"; - $pkg = "grub2-efi(" . $pkgs{uefi_type()} . ")"; - } else { - $prefix = 'i386-pc'; - $pkg = 'grub2'; - } + my ($prefix, $pkg) = get_grub2_pkg(); $do_pkgs->ensure_is_installed($pkg, "/usr/lib/grub/$prefix/ext2.mod", 1) or return 0; } elsif ($main_method eq 'refind') { $do_pkgs->ensure_is_installed('refind', '/sbin/refind-install', 1) or return 0; -- cgit v1.2.1