Index: genkernel =================================================================== --- genkernel (revision 2) +++ genkernel (revision 4) @@ -20,6 +20,7 @@ source ${GK_BIN}/gen_initrd.sh || gen_die "Could not read ${GK_BIN}/gen_initrd.sh" source ${GK_BIN}/gen_moddeps.sh || gen_die "Could not read ${GK_BIN}/gen_moddeps.sh" source ${GK_BIN}/gen_package.sh || gen_die "Could not read ${GK_BIN}/gen_package.sh" +source ${GK_BIN}/gen_bootloader.sh || gen_die "Could not read ${GK_BIN}/gen_bootloader.sh" BUILD_KERNEL=0 BUILD_INITRD=0 @@ -203,6 +204,7 @@ if [ "${BUILD_KERNEL}" -eq '1' ] then + set_bootloader print_info 1 '' print_info 1 "Kernel compiled successfully!" print_info 1 '' @@ -232,6 +234,7 @@ print_info 1 'initrd compiled successfully!' fi + print_info 1 '' print_info 1 'Do NOT report kernel bugs as genkernel bugs unless your bug' print_info 1 'is about the default genkernel configuration...' Index: gen_determineargs.sh =================================================================== --- gen_determineargs.sh (revision 2) +++ gen_determineargs.sh (revision 4) @@ -137,4 +137,9 @@ then NOINITRDMODULES="${CMD_NOINITRDMODULES}" fi + + if [ "${CMD_BOOTLOADER}" != '' ] + then + BOOTLOADER="${CMD_BOOTLOADER}" + fi } Index: gen_bootloader.sh =================================================================== --- gen_bootloader.sh (revision 0) +++ gen_bootloader.sh (revision 4) @@ -0,0 +1,82 @@ +#!/bin/bash + +set_bootloader() { + if [ "x$BOOTLOADER" == "xgrub" ] + then + set_grub_bootloader + else + return 0 + fi +} + +set_grub_bootloader() { + + local GRUB_CONF="/boot/grub/grub.conf" + + print_info 1 '' + print_info 1 "Adding kernel to $GRUB_CONF" + + # Extract block device information from /etc/fstab + local GRUB_ROOTFS=$(awk '/[[:space:]]\/[[:space:]]/ { print $1 }' /etc/fstab) + local GRUB_BOOTFS=$(awk '/[[:space:]]\/boot[[:space:]]/ { print $1 }' /etc/fstab) + # if /boot is not defined in fstab, it must be the same as / + if [ "x$GRUB_BOOTFS" == "x" ] + then + GRUB_BOOTFS=$GRUB_ROOTFS + fi + + # Translate block letters into grub numbers + local GRUB_ROOT_DISK=$(echo $GRUB_ROOTFS | sed -e 's/\/dev\/[hs]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 + + # 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)) + + # Create grub configuration directory and file if it doesn't exist. + if [ ! -e `basename $GRUB_CONF` ] + then + mkdir -p `basename $GRUB_CONF` + fi + + 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 + # Add grub configuration to 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 + else + # grub.conf already exists + # copy the first boot definition and change the version + cp $GRUB_CONF $GRUB_CONF.bak + awk 'BEGIN { RS="title=";FS="\n";OFS="\n";ORS=""} + NR == 2 { + sub(/\(.+\)/,"(" ch KV ch ")",$1); + sub(/kernel-[[:alnum:][:punct:]]+/, "kernel-" KV, $3); + sub(/initrd-[[:alnum:][:punct:]]+/, "initrd-" KV, $4); + print RS ch $0 }' + KV=$KV $GRUB_CONF.bak >> $GRUB_CONF + fi +} Index: gen_cmdline.sh =================================================================== --- gen_cmdline.sh (revision 2) +++ gen_cmdline.sh (revision 4) @@ -52,6 +52,7 @@ echo " --bootsplash= Force bootsplash using ." echo " --do-keymap-auto Forces keymap selection at boot." echo " --no-lvm2 Don't add in LVM2 support." + echo " --bootloader= Add new kernel to grub configuration" echo " Internals" echo " --arch-override= Force to arch instead of autodetect" echo " --busybox-config= Busybox configuration file to use" @@ -132,6 +133,10 @@ CMD_NOLVM2=1 print_info 2 'CMD_NOLVM2: 1' ;; + --bootloader*) + CMD_BOOTLOADER=`parse_opt "$*"` + print_info 2 "CMD_BOOTLOADER: $CMD_BOOTLOADER" + ;; --debuglevel*) CMD_DEBUGLEVEL=`parse_opt "$*"` DEBUGLEVEL="${CMD_DEBUGLEVEL}"