1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 DESCRIPTION="Grub2 built as a PV grub per the Xen PV Boot Protocol"
7 HOMEPAGE="https://blog.xenproject.org/2015/01/07/using-grub-2-as-a-bootloader-for-xen-pv-guests/"
15 DEPEND="sys-boot/grub:2=[grub_platforms_xen]
16 app-emulation/xen-tools:="
21 RESTRICT="binchecks strip test"
28 cat > "${S}/grub-bootstrap.cfg" <<- EOF || die
29 normal (memdisk)/grub.cfg
32 cat > "${S}/grub.cfg" <<- EOF || die
33 if search -s -f /boot/xen/pvboot-x86_64.elf ; then
34 echo "Chainloading (${root})/boot/xen/pvboot-x86_64.elf"
35 multiboot "/boot/xen/pvboot-x86_64.elf"
39 if search -s -f /xen/pvboot-x86_64.elf ; then
40 echo "Chainloading (${root})/xen/pvboot-x86_64.elf"
41 multiboot "/xen/pvboot-x86_64.elf"
45 if search -s -f /boot/grub/grub.cfg ; then
46 echo "Reading (${root})/boot/grub/grub.cfg"
47 configfile /boot/grub/grub.cfg
50 if search -s -f /grub/grub.cfg ; then
51 echo "Reading (${root})/grub/grub.cfg"
52 configfile /grub/grub.cfg
56 tar cf memdisk.tar grub.cfg || die "failed to tar"
58 local grub_mkimage=grub-mkimage
59 if type grub2-mkimage &> /dev/null; then
60 grub_mkimage=grub2-mkimage
68 -o grub-x86_64-xen.bin
69 /usr/lib/grub/x86_64-xen/*.mod
73 "${args[@]}" || die "failed to grub-mkimage"
77 exeinto /usr/libexec/xen/bin
78 doexe grub-x86_64-xen.bin