From 428304c9f8de260372e4a80b8f712d72a4c08984 Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Tue, 18 Jan 2022 09:56:43 +0100 Subject: [PATCH] fix grub.cfg for all architectures --- usr/bin/archboot-aarch64-iso.sh | 14 +++----------- usr/bin/archboot-x86_64-iso.sh | 15 ++++----------- usr/share/archboot/grub/grub.cfg | 27 ++++++++++++++++----------- 3 files changed, 23 insertions(+), 33 deletions(-) diff --git a/usr/bin/archboot-aarch64-iso.sh b/usr/bin/archboot-aarch64-iso.sh index ff19029b2..674a407fc 100755 --- a/usr/bin/archboot-aarch64-iso.sh +++ b/usr/bin/archboot-aarch64-iso.sh @@ -6,6 +6,7 @@ _SHIM_URL="https://kojipkgs.fedoraproject.org/packages/shim/15.4/5/aarch64" _SHIM_VERSION="shim-aa64-15.4-5.aarch64.rpm" _PRESET_DIR="/etc/archboot/presets" _TARBALL_HELPER="/usr/bin/archboot-tarball-helper.sh" +_GRUB_CONFIG="/usr/share/archboot/grub/grub.cfg" # covered by usage _GENERATE="" _TARBALL="" @@ -162,17 +163,11 @@ _prepare_uefi_image() { mcopy -i "${VFAT_IMAGE}" -s "${_AARCH64}"/EFI ::/ } - # build grubXXX with all modules: http://bugs.archlinux.org/task/71382 # If you don't use shim use --disable-shim-lock _prepare_uefi_AA64_GRUB_USB_files() { ### Hint: https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/grub.macros#_407 - grub-mkstandalone -d /usr/lib/grub/arm64-efi -O arm64-efi --sbat=/usr/share/grub/sbat.csv --modules="all_video boot btrfs cat configfile cryptodisk echo efi_gop efifwsetup efinet ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http iso9660 loadenv loopback linux lvm lsefi lsefimmap luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs zstd chain tpm" --fonts="unicode" --locales="" --themes="" -o "${_AARCH64}/EFI/BOOT/grubaa64.efi" -} - -_prepare_GRUB_config_file() { - [[ -d "${_AARCH64}/boot/grub" ]] || mkdir -p "${_AARCH64}/boot/grub" - cp /usr/share/archboot/grub/grub.cfg "${_AARCH64}/boot/grub/grub.cfg" + grub-mkstandalone -d /usr/lib/grub/arm64-efi -O arm64-efi --sbat=/usr/share/grub/sbat.csv --modules="all_video boot btrfs cat configfile cryptodisk echo efi_gop efifwsetup efinet ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http iso9660 loadenv loopback linux lvm lsefi lsefimmap luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs zstd chain tpm" --fonts="unicode" --locales="" --themes="" -o "${_AARCH64}/EFI/BOOT/grubaa64.efi" "boot/grub/grub.cfg=${_GRUB_CONFIG}" } echo "Starting ISO creation ..." @@ -188,14 +183,11 @@ _prepare_efitools_uefi >/dev/null 2>&1 echo "Prepare AA64 Grub ..." _prepare_uefi_AA64_GRUB_USB_files >/dev/null 2>&1 -echo "Prepare BIOS Grub ..." -_prepare_GRUB_config_file >/dev/null 2>&1 - echo "Prepare UEFI image ..." _prepare_uefi_image >/dev/null 2>&1 ## Generate the BIOS+ISOHYBRID+UEFI CD image using xorriso (extra/libisoburn package) in mkisofs emulation mode -grub-mkrescue --compress=xz --fonts="unicode" --locales="" --themes="" -o "${_IMAGENAME}.iso" "${_AARCH64}"/ &> "${_IMAGENAME}.log" +grub-mkrescue --compress=xz --fonts="unicode" --locales="" --themes="" -o "${_IMAGENAME}.iso" "${_AARCH64}"/ "boot/grub/grub.cfg=${_GRUB_CONFIG}" &> "${_IMAGENAME}.log" ## create sha256sums.txt echo "Generating sha256sum ..." diff --git a/usr/bin/archboot-x86_64-iso.sh b/usr/bin/archboot-x86_64-iso.sh index c75c60574..62a196845 100755 --- a/usr/bin/archboot-x86_64-iso.sh +++ b/usr/bin/archboot-x86_64-iso.sh @@ -7,6 +7,7 @@ _TARBALL_HELPER="/usr/bin/archboot-tarball-helper.sh" _SHIM_URL="https://kojipkgs.fedoraproject.org/packages/shim/15.4/5/x86_64" _SHIM_VERSION="shim-x64-15.4-5.x86_64.rpm" _SHIM32_VERSION="shim-ia32-15.4-5.x86_64.rpm" +_GRUB_CONFIG="/usr/share/archboot/grub/grub.cfg" # covered by usage _GENERATE="" _TARBALL="" @@ -188,17 +189,12 @@ _download_uefi_shell_tianocore() { # If you don't use shim use --disable-shim-lock _prepare_uefi_X64_GRUB_USB_files() { ### Hint: https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/grub.macros#_407 - grub-mkstandalone -d /usr/lib/grub/x86_64-efi -O x86_64-efi --sbat=/usr/share/grub/sbat.csv --modules="all_video boot btrfs cat configfile cryptodisk echo efi_gop efi_uga efifwsetup efinet ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http iso9660 loadenv loopback linux lvm lsefi lsefimmap luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs zstd backtrace chain tpm usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug keylayouts at_keyboard" --fonts="unicode" --locales="" --themes="" -o "${_X86_64}/EFI/BOOT/grubx64.efi" + grub-mkstandalone -d /usr/lib/grub/x86_64-efi -O x86_64-efi --sbat=/usr/share/grub/sbat.csv --modules="all_video boot btrfs cat configfile cryptodisk echo efi_gop efi_uga efifwsetup efinet ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http iso9660 loadenv loopback linux lvm lsefi lsefimmap luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs zstd backtrace chain tpm usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug keylayouts at_keyboard" --fonts="unicode" --locales="" --themes="" -o "${_X86_64}/EFI/BOOT/grubx64.efi" "boot/grub/grub.cfg=${_GRUB_CONFIG}" } _prepare_uefi_IA32_GRUB_USB_files() { ### Hint: https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/grub.macros#_407 - grub-mkstandalone -d /usr/lib/grub/i386-efi -O i386-efi --sbat=/usr/share/grub/sbat.csv --modules="all_video boot btrfs cat configfile cryptodisk echo efi_gop efi_uga efifwsetup efinet ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http iso9660 loadenv loopback linux lvm lsefi lsefimmap luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs zstd backtrace chain tpm usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug keylayouts at_keyboard" --fonts="unicode" --locales="" --themes="" -o "${_X86_64}/EFI/BOOT/grubia32.efi" -} - -_prepare_GRUB_config_file() { - [[ -d "${_X86_64}/boot/grub" ]] || mkdir -p "${_X86_64}/boot/grub" - cp /usr/share/archboot/grub/grub.cfg "${_X86_64}/boot/grub/grub.cfg" + grub-mkstandalone -d /usr/lib/grub/i386-efi -O i386-efi --sbat=/usr/share/grub/sbat.csv --modules="all_video boot btrfs cat configfile cryptodisk echo efi_gop efi_uga efifwsetup efinet ext2 f2fs fat font gcry_rijndael gcry_rsa gcry_serpent gcry_sha256 gcry_twofish gcry_whirlpool gfxmenu gfxterm gzio halt hfsplus http iso9660 loadenv loopback linux lvm lsefi lsefimmap luks luks2 mdraid09 mdraid1x minicmd net normal part_apple part_msdos part_gpt password_pbkdf2 pgp png reboot regexp search search_fs_uuid search_fs_file search_label serial sleep syslinuxcfg test tftp video xfs zstd backtrace chain tpm usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug keylayouts at_keyboard" --fonts="unicode" --locales="" --themes="" -o "${_X86_64}/EFI/BOOT/grubia32.efi" "boot/grub/grub.cfg=${_GRUB_CONFIG}" } echo "Starting ISO creation ..." @@ -220,15 +216,12 @@ _prepare_uefi_X64_GRUB_USB_files >/dev/null 2>&1 echo "Prepare IA32 Grub ..." _prepare_uefi_IA32_GRUB_USB_files >/dev/null 2>&1 -echo "Prepare BIOS Grub ..." -_prepare_GRUB_config_file >/dev/null 2>&1 - echo "Prepare UEFI image ..." _prepare_uefi_image >/dev/null 2>&1 ## Generate the BIOS+ISOHYBRID+UEFI CD image using xorriso (extra/libisoburn package) in mkisofs emulation mode echo "Generating X86_64 hybrid ISO ..." -grub-mkrescue --compress="xz" --fonts="unicode" --locales="" --themes="" -o "${_IMAGENAME}.iso" "${_X86_64}"/ &> "${_IMAGENAME}.log" +grub-mkrescue --compress="xz" --fonts="unicode" --locales="" --themes="" -o "${_IMAGENAME}.iso" "${_X86_64}"/ "boot/grub/grub.cfg=${_GRUB_CONFIG}" &> "${_IMAGENAME}.log" ## create sha256sums.txt echo "Generating sha256sum ..." diff --git a/usr/share/archboot/grub/grub.cfg b/usr/share/archboot/grub/grub.cfg index 2ff41b349..9cdc76b29 100644 --- a/usr/share/archboot/grub/grub.cfg +++ b/usr/share/archboot/grub/grub.cfg @@ -4,7 +4,10 @@ insmod fat if [ ${grub_platform} == "efi" ]; then insmod efi_gop - if [ ${grub_cpu} == "x86_64" || ${grub_cpu} == "i386"]; then + if [ ${grub_cpu} == "x86_64" ]; then + insmod efi_uga + fi + if [ ${grub_cpu} == "i386" ]; then insmod efi_uga fi fi @@ -16,7 +19,6 @@ insmod font if loadfont "${prefix}/fonts/unicode.pf2" ; then insmod gfxterm - set gfxmode="1366x768x32;1280x800x32;1024x768x32;auto" terminal_input console terminal_output gfxterm fi @@ -76,7 +78,7 @@ if [ ${grub_platform} == "pc" ]; then fi if [ ${grub_platform} == "efi" ]; then - if [ ${grub_cpu} == "x86_64" || ${grub_cpu} == "arm64" ]; then + if [ ${grub_cpu} == "x86_64" ]; then menuentry "Secure Boot KeyTool" { search --no-floppy --set=root --file /EFI/tools/KeyTool.efi chainloader /EFI/tools/KeyTool.efi @@ -87,6 +89,17 @@ if [ ${grub_platform} == "efi" ]; then chainloader /EFI/tools/HashTool.efi } fi + if [ ${grub_cpu} == "arm64" ]; then + menuentry "Secure Boot KeyTool" { + search --no-floppy --set=root --file /EFI/tools/KeyTool.efi + chainloader /EFI/tools/KeyTool.efi + } + + menuentry "Secure Boot HashTool" { + search --no-floppy --set=root --file /EFI/tools/HashTool.efi + chainloader /EFI/tools/HashTool.efi + } + fi if [ ${grub_cpu} == "i386" ]; then menuentry "UEFI Shell IA32 v2" { search --no-floppy --set=root --file /EFI/tools/shellia32_v2.efi @@ -114,14 +127,6 @@ if [ ${grub_platform} == "efi" ]; then } fi -if [ "${grub_platform}" == "efi" ]; then - menuentry "Microsoft Windows" { - insmod chain - search --no-floppy --fs-uuid --set=root $hints_string $fs_uuid - chainloader /EFI/Microsoft/Boot/bootmgfw.efi - } -fi - menuentry "System restart" { echo "System rebooting..." reboot