#! /bin/sh
set -e

# grub-mkconfig helper script.
# Copyright (C) 2006,2007,2008,2009,2010  Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.

prefix="/usr"
exec_prefix="/usr"
datarootdir="/usr/share"
grub_lang=`echo $LANG | cut -d . -f 1`

export TEXTDOMAIN=grub
export TEXTDOMAINDIR="${datarootdir}/locale"

. "$pkgdatadir/grub-mkconfig_lib"
cat << EOF
insmod part_msdos
insmod part_gpt
insmod ext2
insmod all_video
insmod efi_gop
insmod efi_uga
insmod fat
insmod search_fs_file
EOF
for k in `find /mnt -maxdepth 2 -name kernel -type f|sort -V|cut -f 3 -d /|grep \[0-9\]`;do
if echo $k|grep -q cdrom;then
continue
fi
gettext_printf "Found android Version $k \n" >&2
cat <<EOF
menuentry "Start Android X86 Version $k" {
search --file --no-floppy --set=root /.android-x86
linux /$k/kernel root=/dev/ram0 androidboot.selinux=permissive loglevel=0 quiet
initrd /$k/initrd.img
}
EOF
done
cat <<EOF
menuentry "Start Android x86 Recovery Mode"{
search --file --no-floppy --set=root /boot/grub/grub.cfg
linux /boot/vmlinuz-linux root=/dev/disk/by-label/root rw
initrd /boot/initramfs-linux.img
boot
}
menuentry "Start Android x86 Recovery Mode Without Accessibility"{
search --file --no-floppy --set=root /boot/grub/grub.cfg
linux /boot/vmlinuz-linux root=/dev/disk/by-label/root rw nospeech
initrd /boot/initramfs-linux.img
boot
}
EOF
