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
cleanup-cruft
Tim Yamin 20 years ago
parent ec3b45b145
commit 2ff7073609

@ -23,7 +23,7 @@ set_grub_bootloader() {
[ "x$GRUB_BOOTFS" == 'x' ] && GRUB_BOOTFS=$GRUB_ROOTFS [ "x$GRUB_BOOTFS" == 'x' ] && GRUB_BOOTFS=$GRUB_ROOTFS
# Translate block letters into grub numbers # 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 case $GRUB_ROOT_DISK in
a ) a )
GRUB_ROOT_DISK='0' ;; GRUB_ROOT_DISK='0' ;;
@ -38,32 +38,39 @@ set_grub_bootloader() {
esac esac
# Translate partition numbers into grub numbers # 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=$(echo $GRUB_BOOTFS | sed -e 's/\/dev\/[hsm]d[[:alpha:]]\([[:digit:]]\+\)/\1/')
local GRUB_ROOT_PARTITION=$(($GRUB_ROOT_PARTITION-1))
# Create grub configuration directory and file if it doesn't exist. # Create grub configuration directory and file if it doesn't exist.
[ ! -e `basename $GRUB_CONF` ] && mkdir -p `basename $GRUB_CONF` [ ! -e `basename $GRUB_CONF` ] && mkdir -p `basename $GRUB_CONF`
if [ ! -e $GRUB_CONF ] if [ ! -e $GRUB_CONF ]
then then
# grub.conf doesn't exist - create it with standard defaults # Check that $GRUB_ROOT_PARTITION is a single character
touch $GRUB_CONF local GRUB_ROOT_PARTITION_TEST=$(printf $GRUB_ROOT_PARTITION | wc -c)
echo 'default 0' >> $GRUB_CONF if [ "${GRUB_ROOT_PARTITION_TEST}" -ne '1' ]
echo 'timeout 5' >> $GRUB_CONF # GRUB_ROOT_PARTITION is not a number; we can't work this out so... error
echo "" >> $GRUB_CONF 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.'
# 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 else
echo -e "\tkernel /kernel-$KV root=/dev/ram0 init=/linuxrc real_root=$GRUB_ROOTFS" >> $GRUB_CONF # grub.conf doesn't exist - create it with standard defaults
echo -e "\tinitrd /initrd-$KV" >> $GRUB_CONF 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 fi
echo "" >> $GRUB_CONF
else else
# grub.conf already exists; so... # grub.conf already exists; so...
# ... Clone the first boot definition and change the version. # ... Clone the first boot definition and change the version.

Loading…
Cancel
Save