2 case "${BOOTLOADER}" in
7 print_warning "Bootloader ${BOOTLOADER} is not currently supported"
12 set_bootloader_read_fstab() {
13 local ROOTFS=$(awk 'BEGIN{RS="((#[^\n]*)?\n)"}( $2 == "/" ) { print $1; exit }' /etc/fstab)
14 local BOOTFS=$(awk 'BEGIN{RS="((#[^\n]*)?\n)"}( $2 == "'${BOOTDIR}'") { print $1; exit }' /etc/fstab)
16 # If ${BOOTDIR} is not defined in /etc/fstab, it must be the same as /
17 [ -z "${BOOTFS}" ] && BOOTFS=${ROOTFS}
19 echo "${ROOTFS} ${BOOTFS}"
22 set_bootloader_grub_read_device_map() {
23 # Read GRUB device map
24 [ ! -d ${TEMP} ] && mkdir ${TEMP}
25 echo "quit" | grub --batch --device-map=${TEMP}/grub.map &>/dev/null
26 echo "${TEMP}/grub.map"
29 set_bootloader_grub() {
30 local GRUB_CONF="${BOOTDIR}/grub/grub.conf"
32 print_info 1 "Adding kernel to ${GRUB_CONF}..."
34 if [ ! -e ${GRUB_CONF} ]
41 GRUB_BOOTFS=$(set_bootloader_read_fstab | cut -d' ' -f2)
44 # Get the GRUB mapping for our device
45 local GRUB_BOOT_DISK1=$(echo ${GRUB_BOOTFS} | sed -e 's#\(/dev/.\+\)[[:digit:]]\+#\1#')
46 local GRUB_BOOT_DISK=$(awk '{if ($2 == "'${GRUB_BOOT_DISK1}'") {gsub(/(\(|\))/, "", $1); print $1;}}' ${TEMP}/grub.map)
47 local GRUB_BOOT_PARTITION=$(($(echo ${GRUB_BOOTFS} | sed -e 's#/dev/.\+\([[:digit:]]?*\)#\1#') - 1))
49 if [ -n "${GRUB_BOOT_DISK}" -a -n "${GRUB_BOOT_PARTITION}" ]
52 # Create grub configuration directory and file if it doesn't exist.
53 [ ! -d `dirname ${GRUB_CONF}` ] && mkdir -p `dirname ${GRUB_CONF}`
56 echo 'default 0' >> ${GRUB_CONF}
57 echo 'timeout 5' >> ${GRUB_CONF}
58 echo "root (${GRUB_BOOT_DISK},${GRUB_BOOT_PARTITION})" >> ${GRUB_CONF}
61 # Add grub configuration to grub.conf
62 echo "# Genkernel generated entry, see GRUB documentation for details" >> ${GRUB_CONF}
63 echo "title=Gentoo Linux ($KV)" >> ${GRUB_CONF}
64 if [ "${BUILD_INITRD}" -eq '0' ]
66 echo -e "\tkernel /kernel-${KNAME}-${ARCH}-${KV} root=${GRUB_ROOTFS}" >> ${GRUB_CONF}
68 echo -e "\tkernel /kernel-${KNAME}-${ARCH}-${KV} root=/dev/ram0 init=/linuxrc real_root=${GRUB_ROOTFS}" >> ${GRUB_CONF}
69 if [ "${PAT}" -gt '4' ]
71 echo -e "\tinitrd /initramfs-${KNAME}-${ARCH}-${KV}" >> ${GRUB_CONF}
76 print_error 1 "Error! ${BOOTDIR}/grub/grub.conf does not exist and the correct settings can not be automatically detected."
77 print_error 1 "Please manually create your ${BOOTDIR}/grub/grub.conf file."
81 # The grub.conf already exists, so let's try to duplicate the default entry