# vim: ft=zsh noet
if [[ $1 == info ]]; then
	FSB_INFO_DEPEND=gentoo_genkernel
	FSB_INFO_BASE=%s
	FSB_INFO_DIR=%s-boot
	return
elif [[ $1 != build ]]; then
	die "unimplemented action: $*"
fi
mkdir -p $build_dir/boot/grub $build_dir/boot/grub2 || die mkdir -p
cat >$build_dir/boot/grub2/grub.cfg <<EOF
default=0
timeout=10

menuentry 'Gentoo - genkernel' {
	linux	/boot/kernel dolvm domdadm
	initrd	/boot/initramfs
}

menuentry 'Gentoo - genkernel (previous)' {
	linux	/boot/kernel.old dolvm domdadm
	initrd	/boot/initramfs.old
}
EOF
ln -s ../grub2/grub.cfg $build_dir/boot/grub/grub.cfg || die ln -s
cat >$build_dir/boot/extlinux.conf <<EOF
UI menu.c32
TIMEOUT 150
DEFAULT genkernel.vga

LABEL genkernel.vga
KERNEL /kernel
APPEND initrd=/initramfs dolvm domdadm vga=792

LABEL genkernel
KERNEL /kernel
APPEND initrd=/initramfs dolvm domdadm

LABEL genkernel.old
KERNEL /kernel.old
APPEND initrd=/initramfs.old dolvm domdadm
EOF
cp -Rv $build_dir/usr/share/syslinux $build_dir/boot/ || \
	die "error copying extlinux/syslinux modules"
ln -s ../extlinux.conf $build_dir/boot/syslinux/ || \
	die "error symlinking exlinux modules"
[[ -h $build_dir/boot/boot ]] || ln -s . $build_dir/boot/boot || \
	die "could not make recursive boot symlink"