Add GRUB support cleanup by Richard Morris (#59192) to show an error if we can't...
authorTim Yamin <plasmaroo@gentoo.org>
Thu, 2 Jun 2005 20:04:59 +0000 (20:04 +0000)
committerTim Yamin <plasmaroo@gentoo.org>
Thu, 2 Jun 2005 20:04:59 +0000 (20:04 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@201 67a159dc-881f-0410-a524-ba9dfbe2cb84

gen_bootloader.sh

index 65c122519209d8c59ec7276306b4a9e087ba6648..e685c1477be0de8b51d96735bbb30dcf464568d1 100644 (file)
@@ -23,7 +23,7 @@ set_grub_bootloader() {
        [ "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\/[hs]d\([[:alpha:]]\)[[:digit:]]\+/\1/')
+       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' ;;
@@ -38,32 +38,39 @@ set_grub_bootloader() {
        esac
 
        # Translate partition numbers into grub numbers
-       local GRUB_ROOT_PARTITION=$(echo $GRUB_BOOTFS | sed -e 's/\/dev\/[hs]d[[:alpha:]]\([[:digit:]]\+\)/\1/')
-       local GRUB_ROOT_PARTITION=$(($GRUB_ROOT_PARTITION-1))
+       local GRUB_ROOT_PARTITION=$(echo $GRUB_BOOTFS | sed -e 's/\/dev\/[hsm]d[[:alpha:]]\([[:digit:]]\+\)/\1/')
 
        # 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
-               # grub.conf doesn't exist - create it with standard defaults
-               touch $GRUB_CONF
-               echo 'default 0' >> $GRUB_CONF
-               echo 'timeout 5' >> $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
-               if [ "${BUILD_INITRD}" -eq '0' ]
-               then
-                       echo -e "\tkernel /kernel-$KV root=$GRUB_ROOTFS" >> $GRUB_CONF
+               # 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' ]
+                       # 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
-                       echo -e "\tkernel /kernel-$KV root=/dev/ram0 init=/linuxrc real_root=$GRUB_ROOTFS" >> $GRUB_CONF
-                       echo -e "\tinitrd /initrd-$KV" >> $GRUB_CONF
+                       # grub.conf doesn't exist - create it with standard defaults
+                       touch $GRUB_CONF
+                       echo 'default 0' >> $GRUB_CONF
+                       echo 'timeout 5' >> $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
+                       if [ "${BUILD_INITRD}" -eq '0' ]
+                       then
+                               echo -e "\tkernel /kernel-$KV root=$GRUB_ROOTFS" >> $GRUB_CONF
+                       else
+                               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
                fi
-               echo "" >> $GRUB_CONF
        else
                # grub.conf already exists; so...
                # ... Clone the first boot definition and change the version.