From 2ff7073609b6b98af47d79798d1dc9bcd8c0bd39 Mon Sep 17 00:00:00 2001 From: Tim Yamin Date: Thu, 2 Jun 2005 20:04:59 +0000 Subject: [PATCH] Add GRUB support cleanup by Richard Morris (#59192) to show an error if we can't work out device nodes and tell the user to manually generate grub.conf. git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@201 67a159dc-881f-0410-a524-ba9dfbe2cb84 --- gen_bootloader.sh | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/gen_bootloader.sh b/gen_bootloader.sh index 65c1225..e685c14 100644 --- a/gen_bootloader.sh +++ b/gen_bootloader.sh @@ -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. -- 2.26.2