Commit 1f066d54 authored by Anton Midyukov's avatar Anton Midyukov

efi: add workaround for p10 branch to fix booting from a flash drive

parent 5ab5e016
...@@ -35,6 +35,9 @@ use/efi/signed: use/efi ...@@ -35,6 +35,9 @@ use/efi/signed: use/efi
@$(call add,COMMON_PACKAGES,shim-signed) @$(call add,COMMON_PACKAGES,shim-signed)
@$(call add,COMMON_PACKAGES,mokutil pesign) @$(call add,COMMON_PACKAGES,mokutil pesign)
@$(call add,RESCUE_PACKAGES,openssl) @$(call add,RESCUE_PACKAGES,openssl)
ifeq (p10,$(BRANCH))
@$(call add,STAGE1_PACKAGES,shim-signed-installer-kludge grub-efi alt-uefi-certs dosfstools mtools)
endif
use/efi/lilo: use/efi use/bootloader/lilo use/efi/lilo: use/efi use/bootloader/lilo
@$(call set,EFI_BOOTLOADER,elilo) @$(call set,EFI_BOOTLOADER,elilo)
......
#!/bin/sh -efu
# This is a workaround to fix booting from a flash drive on some UEFIs.
# Create .efiboot.img in STAGE1 with old shim, wich without problem.
# This code from mkimage/tools/mki-copy-efiboot-chrooted.
shim_dir=/usr/lib/shim-installer-kludge
grub64=/usr/lib64/efi/grubx64.efi
grub32=/usr/lib64/efi/grubia32.efi
img=.efiboot.img
[ -d "$shim_dir" ] || exit 0
[ -s "$grub64" ] || exit 1
[ -s "$grub32" ] || exit 1
cd /.image
mkdir -p EFI/BOOT
# copy shim
cp -pLf $shim_dir/shimx64.efi EFI/BOOT/bootx64.efi
cp -pLf $shim_dir/shimia32.efi EFI/BOOT/bootia32.efi
cp -pLf $shim_dir/mmx64.efi EFI/BOOT/
cp -pLf $shim_dir/mmia32.efi EFI/BOOT/
# copy grub
cp -pLf $grub64 EFI/BOOT/
cp -pLf $grub32 EFI/BOOT/
# copy cert
mkdir -p EFI/enroll
cp /etc/pki/uefi/altlinux.cer EFI/enroll/
# add_grub_cfg
{
cat <<- GRUB_EOF
search --file --set=root /.disk/info
set prefix=(\$root)/boot/grub
source \$prefix/grub.cfg
GRUB_EOF
} > "EFI/BOOT/grub.cfg"
# write efiboot img
imgsize="$(( $(du -lsB32k EFI | cut -f1) + 10 ))"
dd if=/dev/zero of="$img" bs=32k count="$imgsize"
# dosfstools-4.0 has dropped those ancient symlinks, *sigh*
mkfs=
for bin in mkfs.fat mkfs.vfat; do
if $bin --help >/dev/null 2>&1; then
mkfs="$bin"
break
fi
done
[ -n "$mkfs" ] || exit 1
$mkfs -n "El Torito" $img
# mtools insists that total number of sectors
# is a multiple of sectors per track (the infamous 63),
# and dosfstools-4.0 doesn't follow that anymore
echo "mtools_skip_check=1" >~/.mtoolsrc
mcopy -i "$img" -s "EFI" ::
mv "$img" EFI/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment