From fcf285b974a5c3ed75c37f5b619abab19845f126 Mon Sep 17 00:00:00 2001 From: Andreas Loibl Date: Thu, 29 Sep 2011 16:19:09 +0200 Subject: added hooks to include GRUB2-EFI into binary --- config/binary_grub/grub-efi.cfg | 10 ++++ config/binary_grub/grub.cfg | 2 +- config/binary_local-hooks/grub2-efi | 67 ++++++++++++++++++++++ config/binary_local-hooks/grub2-theme | 6 ++ .../boot/grub/x86_64-efi/grub.cfg | 10 ---- 5 files changed, 84 insertions(+), 11 deletions(-) create mode 100644 config/binary_grub/grub-efi.cfg create mode 100755 config/binary_local-hooks/grub2-efi create mode 100755 config/binary_local-hooks/grub2-theme delete mode 100644 config/binary_local-includes/boot/grub/x86_64-efi/grub.cfg diff --git a/config/binary_grub/grub-efi.cfg b/config/binary_grub/grub-efi.cfg new file mode 100644 index 0000000..bff7cab --- /dev/null +++ b/config/binary_grub/grub-efi.cfg @@ -0,0 +1,10 @@ +insmod part_acorn +insmod part_amiga +insmod part_apple +insmod part_bsd +insmod part_gpt +insmod part_msdos +insmod part_sun +insmod part_sunpc +set efi=1 +source /boot/grub/grub.cfg diff --git a/config/binary_grub/grub.cfg b/config/binary_grub/grub.cfg index be60ad3..3cd4f20 100644 --- a/config/binary_grub/grub.cfg +++ b/config/binary_grub/grub.cfg @@ -81,7 +81,7 @@ if [ $efi != 1 ] ; then } else menuentry 'EFI Shell' { - chainloader /efi/shellx64.efi + chainloader /efi/boot/shellx64.efi } if search -nf /EFI/Microsoft/Boot/BOOTMGR.EFI ; then menuentry 'Microsoft Bootmgr' { diff --git a/config/binary_local-hooks/grub2-efi b/config/binary_local-hooks/grub2-efi new file mode 100755 index 0000000..4984370 --- /dev/null +++ b/config/binary_local-hooks/grub2-efi @@ -0,0 +1,67 @@ +#!/bin/bash + +platform=x86_64 +efi_name=x64 +modules="search iso9660 configfile normal memdisk tar part_msdos fat" + +memdisk_img= +workdir= + +cleanup () { + [ -z "$memdisk_img" ] || rm -f "$memdisk_img" + [ -z "$workdir" ] || rm -rf "$workdir" +} +trap cleanup EXIT HUP INT QUIT TERM + +memdisk_img="$(mktemp efi-image.XXXXXX)" +workdir="$(mktemp -d efi-image.XXXXXX)" + +# Skeleton configuration file which finds the real boot disk. +mkdir -p "$workdir/boot/grub" +cat >"$workdir/boot/grub/grub.cfg" <"binary/boot/grub/$platform/grub.cfg" + +# fix module order ("gzio" should be loaded before "normal", otherwise a "prefix not set" error message will pop up on boot) +sed -i.orig -e '/^normal:/{/gzio/!{s/$/ gzio/}}' chroot/usr/lib/grub/x86_64-efi/moddep.lst + +# Build the core image. +(cd "$workdir"; tar -cf - boot) >"$memdisk_img" +grub-mkimage -v -O "$platform" -m "$memdisk_img" \ + -o "binary/efi/boot/boot$efi_name.efi" -p '(memdisk)/boot/grub' $modules + +# restore original module order +mv chroot/usr/lib/grub/x86_64-efi/moddep.lst{.orig,} + +# Copy over GRUB modules, except for those already built in. +cp -a "chroot/usr/lib/grub/$platform"/*.lst "binary/boot/grub/$platform/" +builtin_modules="$(m="$modules"; while [ "$m" ] && echo $m + do m=$(sed -ne "s/^\($(echo -n $m | sed 's/ /\\|/g')\):\(.*\)$/\2/p" "chroot/usr/lib/grub/$platform"/moddep.lst) + done | fmt -w1 | sort -u)" +for x in "chroot/usr/lib/grub/$platform"/*.mod; do + case $(basename "$x" .mod) in + affs|afs|afs_be|befs|befs_be|minix|nilfs2|sfs|zfs|zfsinfo) + # unnecessary filesystem modules + ;; + example_functional_test|functional_test|hello) + # other cruft + ;; + *) + grep -wq $(basename "$x" .mod) <<<"$builtin_modules" || cp -a "$x" "binary/boot/grub/$platform/" + ;; + esac +done + +# include EFI shell +wget -O efi/boot/shellx64.efi 'http://tianocore.git.sourceforge.net/git/gitweb.cgi?p=tianocore/edk2;a=blob_plain;f=EdkShellBinPkg/FullShell/X64/Shell_Full.efi;hb=HEAD' + diff --git a/config/binary_local-hooks/grub2-theme b/config/binary_local-hooks/grub2-theme new file mode 100755 index 0000000..8fd752a --- /dev/null +++ b/config/binary_local-hooks/grub2-theme @@ -0,0 +1,6 @@ +#!/bin/bash +# copy theme related files to binary +mkdir -p binary/boot/grub +cp chroot/usr/share/grub/unicode.pf2 binary/boot/grub/ +cp chroot/usr/share/images/grub/kanotix-logo.png binary/boot/grub/ + diff --git a/config/binary_local-includes/boot/grub/x86_64-efi/grub.cfg b/config/binary_local-includes/boot/grub/x86_64-efi/grub.cfg deleted file mode 100644 index bff7cab..0000000 --- a/config/binary_local-includes/boot/grub/x86_64-efi/grub.cfg +++ /dev/null @@ -1,10 +0,0 @@ -insmod part_acorn -insmod part_amiga -insmod part_apple -insmod part_bsd -insmod part_gpt -insmod part_msdos -insmod part_sun -insmod part_sunpc -set efi=1 -source /boot/grub/grub.cfg -- cgit v1.0