From 931b82be93b6c068a91a59f4c6b7ebb9bdfa158a Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Fri, 2 Mar 2018 17:55:03 +0000 Subject: Add support for 32-bit EFI. --- lib/MGA/DrakISO/BuildBoot.pm | 33 ++++++++++++++++++--------------- lib/MGA/DrakISO/BuildISO.pm | 2 +- 2 files changed, 19 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/MGA/DrakISO/BuildBoot.pm b/lib/MGA/DrakISO/BuildBoot.pm index c499b1d..2233c2a 100644 --- a/lib/MGA/DrakISO/BuildBoot.pm +++ b/lib/MGA/DrakISO/BuildBoot.pm @@ -100,10 +100,12 @@ sub prepare_live_system_boot { sub prepare_iso_bootloader { my ($build) = @_; + my $arch = $build->{settings}{arch}; + # If the user has supplied a list of files to copy from the repository, # do that now. We may need some of those files to correctly auto-detect # the default kernel and initrd. - my $repo_prefix = $build->{settings}{repository} . '/' . $build->{settings}{arch} . '/'; + my $repo_prefix = $build->{settings}{repository} . '/' . $arch . '/'; my $copy_prefix = $build->get_build_dir . '/'; foreach (group_by2(@{$build->{copy_from_repo}})) { my ($src, $dst) = @$_; @@ -211,7 +213,7 @@ sub prepare_iso_bootloader { } my $title = $build->{media}{bootloader_title} // $label =~ s/-/ /gr; - my $mode = $build->{settings}{arch} eq 'x86_64' ? '64-bit' : '32-bit'; + my $mode = $arch eq 'x86_64' ? '64-bit' : '32-bit'; # If we have a theme, replace the menu title with the name of the ISO # (extracted from the disk label). @@ -220,9 +222,8 @@ sub prepare_iso_bootloader { run_('sed', '-i', qq(s/title-text:.*/title-text: "$title ($mode)"/), $base_theme_txt); } - # If we are building a 32-bit ISO, we are done, as we don't support - # 32-bit UEFI boot. - return if $build->{settings}{arch} ne 'x86_64'; + # If we are building a legacy-boot only ISO, we are done. + return if $build->{media}{legacy_boot_only}; # Create another build directory. This will contain all the files we need # to exist in the /EFI directory on the ISO. @@ -232,12 +233,14 @@ sub prepare_iso_bootloader { # If the user has supplied a grub2 image for UEFI boot, copy that, # otherwise build one. - my $bootx64_efi = $build->get_absolute_path($build->{media}{bootx64_efi}); - if (defined $bootx64_efi) { - -e $bootx64_efi or die "ERROR: cannot find EFI boot image $bootx64_efi\n"; - cp_f($bootx64_efi, $efi_boot_dir . '/bootx64.efi'); + my $boot_efi = $build->get_absolute_path($build->{media}{boot_efi}); + if (defined $boot_efi) { + -e $boot_efi or die "ERROR: cannot find EFI boot image $boot_efi\n"; + cp_f($boot_efi, $efi_boot_dir . '/'); + } elsif ($arch eq 'x86_64') { + build_grub2_boot_efi($efi_boot_dir . '/bootx64.efi', 'x86_64-efi'); } else { - build_grub2_bootx64_efi($efi_boot_dir . '/bootx64.efi'); + build_grub2_boot_efi($efi_boot_dir . '/bootia32.efi', 'i386-efi'); } # Build a grub2 configuration file for UEFI boot. This just chains to the @@ -250,7 +253,7 @@ sub prepare_iso_bootloader { if (-e $base_theme_txt) { my $uefi_theme_txt = $grub2_dir . "/themes/$theme_name/theme-uefi.txt"; cp_f($base_theme_txt, $uefi_theme_txt); - run_('sed', '-i', qq(s/title-text:.*/title-text: "$title (UEFI)"/), $uefi_theme_txt); + run_('sed', '-i', qq(s/title-text:.*/title-text: "$title ($mode UEFI)"/), $uefi_theme_txt); } # Create another build directory for temporarily storing the ESP image. @@ -266,7 +269,7 @@ sub prepare_iso_bootloader { # Now we've built the ESP image, we can delete the grub2 image. We need # to leave the grub2.cfg file, as DVD boot sets the initial grub2 root # location to the iso9960 partition, not the ESP. - rm_rf($efi_boot_dir . '/bootx64.efi'); + rm_rf(glob($efi_boot_dir . '/*.efi')); } sub build_grub2_eltorito_img { @@ -284,8 +287,8 @@ sub build_grub2_eltorito_img { ); } -sub build_grub2_bootx64_efi { - my ($output) = @_; +sub build_grub2_boot_efi { + my ($output, $format) = @_; my @modules = qw(iso9660 fat part_msdos all_video font png gfxterm gfxmenu keylayouts at_keyboard usb_keyboard configfile echo gettext @@ -294,7 +297,7 @@ sub build_grub2_bootx64_efi { run_('grub2-mkimage', '--output', $output, '--prefix', '/EFI/BOOT', - '--format', 'x86_64-efi', + '--format', $format, @modules ); } diff --git a/lib/MGA/DrakISO/BuildISO.pm b/lib/MGA/DrakISO/BuildISO.pm index ff77679..941050c 100644 --- a/lib/MGA/DrakISO/BuildISO.pm +++ b/lib/MGA/DrakISO/BuildISO.pm @@ -136,7 +136,7 @@ sub build_iso_image { '-boot-load-size', 4, '-boot-info-table', '--grub2-boot-info', - if_($arch eq 'x86_64', + if_(!$build->{media}{legacy_boot_only}, # for DVD UEFI boot '--efi-boot', '--interval:appended_partition_2:all::', # for USB UEFI boot -- cgit v1.2.1