diff options
author | Tim Yamin <plasmaroo@gentoo.org> | 2005-07-10 00:27:47 +0000 |
---|---|---|
committer | Tim Yamin <plasmaroo@gentoo.org> | 2005-07-10 00:27:47 +0000 |
commit | 6c74fd4d9790bff7b9243892710581f7a1d0a829 (patch) | |
tree | 5e7446ede0a6a8960bd6997f716d7333e8d06296 /gen_bootloader.sh | |
parent | >> 3.2.0. Add spock's gensplash fixes, fix initrd startup 'find: ...' errors. (diff) | |
download | genkernel-6c74fd4d9790bff7b9243892710581f7a1d0a829.tar.gz genkernel-6c74fd4d9790bff7b9243892710581f7a1d0a829.tar.bz2 genkernel-6c74fd4d9790bff7b9243892710581f7a1d0a829.zip |
Fix #93178, #98436, #98501
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@242 67a159dc-881f-0410-a524-ba9dfbe2cb84
Diffstat (limited to 'gen_bootloader.sh')
-rw-r--r-- | gen_bootloader.sh | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/gen_bootloader.sh b/gen_bootloader.sh index de8ada6..74b6621 100644 --- a/gen_bootloader.sh +++ b/gen_bootloader.sh @@ -22,34 +22,40 @@ set_grub_bootloader() { # If /boot is not defined in /etc/fstab, it must be the same as / [ "x$GRUB_BOOTFS" == 'x' ] && GRUB_BOOTFS=$GRUB_ROOTFS - # Translate block letters into grub numbers - local GRUB_ROOT_DISK=$(echo $GRUB_ROOTFS | sed -e 's/\/dev\/[hsm]d\([[:alpha:]]\)[[:digit:]]\+/\1/') - case $GRUB_ROOT_DISK in - a ) - GRUB_ROOT_DISK='0' ;; - b ) - GRUB_ROOT_DISK='1' ;; - c ) - GRUB_ROOT_DISK='2' ;; - d ) - GRUB_ROOT_DISK='3' ;; - e ) - GRUB_ROOT_DISK='4' ;; - esac + # Read GRUB device map + echo ${tmp} + if [ ! -d ${tmp} ] + then + mkdir ${tmp} + fi + + grub --batch --device-map=${tmp}/grub.map <<EOF >/dev/null +quit +EOF - # Translate partition numbers into grub numbers - local GRUB_ROOT_PARTITION=$(echo $GRUB_BOOTFS | sed -e 's/\/dev\/[hsm]d[[:alpha:]]\([[:digit:]]\+\)/\1/') + # Get the GRUB mapping for our device + local GRUB_BOOT_DISK1=$(echo $GRUB_BOOTFS | sed -e 's#\(/dev/.\+\)[[:digit:]]\+#\1#') + echo ${GRUB_BOOT_DISK1} + local GRUB_BOOT_DISK=$(awk '{if ($2 == "'$GRUB_BOOT_DISK1'") {gsub(/(\(|\))/, "", $1); print $1;}}' ${tmp}/grub.map) + local GRUB_BOOT_PARTITION=$(echo $GRUB_BOOTFS | sed -e 's#/dev/.\+\([[:digit:]]\+\)#\1#') + if [ ! -d ${tmp} ] + then + rm -r ${tmp} + fi + echo ${GRUB_ROOTFS} + + echo ${GRUB_BOOTFS} + echo ${GRUB_BOOT_DISK} + echo ${GRUB_BOOT_PARTITION} + # Create grub configuration directory and file if it doesn't exist. [ ! -e `basename $GRUB_CONF` ] && mkdir -p `basename $GRUB_CONF` if [ ! -e $GRUB_CONF ] then - # Check that $GRUB_ROOT_PARTITION is a single character - local GRUB_ROOT_PARTITION_TEST=$(printf $GRUB_ROOT_PARTITION | wc -c) - if [ "${GRUB_ROOT_PARTITION_TEST}" -ne '1' ] + if [ "${GRUB_BOOT_DISK}" = '' -o "${GRUB_BOOT_PARTITION}" = '' ] then - # GRUB_ROOT_PARTITION is not a number; we can't work this out so... error print_error 1 'Error! /boot/grub/grub.conf does not exist and the correct settings can\'t be automatically detected.' print_error 1 'Please manually create your /boot/grub/grub.conf file.' else @@ -57,12 +63,12 @@ set_grub_bootloader() { touch $GRUB_CONF echo 'default 0' >> $GRUB_CONF echo 'timeout 5' >> $GRUB_CONF - echo "" >> $GRUB_CONF + echo >> $GRUB_CONF # Add grub configuration to grub.conf echo "# Genkernel generated entry, see GRUB documentation for details" >> $GRUB_CONF echo "title=Gentoo Linux ($KV)" >> $GRUB_CONF - echo -e "\troot (hd$GRUB_ROOT_DISK,$GRUB_ROOT_PARTITION)" >> $GRUB_CONF + echo -e "\troot ($GRUB_BOOT_DISK,$GRUB_BOOT_PARTITION)" >> $GRUB_CONF if [ "${BUILD_INITRD}" -eq '0' ] then echo -e "\tkernel /kernel-$KV root=$GRUB_ROOTFS" >> $GRUB_CONF @@ -70,7 +76,7 @@ set_grub_bootloader() { echo -e "\tkernel /kernel-$KV root=/dev/ram0 init=/linuxrc real_root=$GRUB_ROOTFS" >> $GRUB_CONF echo -e "\tinitrd /initrd-$KV" >> $GRUB_CONF fi - echo "" >> $GRUB_CONF + echo >> $GRUB_CONF fi else # grub.conf already exists; so... |