Initial commit for re-adding support for --bootloader=grub

cleanup-cruft
Andrew Gaffney 16 years ago
parent 3a4667a3d0
commit 8dcac4a20d

@ -2,6 +2,10 @@
# Copyright 1999-2008 Gentoo Foundation; 2008 Chris Gianelloni, Andrew Gaffney
# Distributed under the GPL v2
15 Dec 2008; Andrew Gaffney <agaffney@gentoo.org> +gen_bootloader.sh,
gen_cmdline.sh, gen_determineargs.sh, genkernel:
Initial commit for re-adding support for --bootloader=grub
14 Dec 2008; Andrew Gaffney <agaffney@gentoo.org> netboot/linuxrc.x:
Change -f checks to -e for /dev nodes Check that dropbear exists before
starting it

@ -0,0 +1,84 @@
set_bootloader() {
case "${BOOTLOADER}" in
grub)
set_bootloader_grub
;;
*)
print_warning "Bootloader ${BOOTLOADER} is not currently supported"
;;
esac
}
set_bootloader_read_fstab() {
local ROOTFS=$(awk 'BEGIN{RS="((#[^\n]*)?\n)"}( $2 == "/" ) { print $1; exit }' /etc/fstab)
local BOOTFS=$(awk 'BEGIN{RS="((#[^\n]*)?\n)"}( $2 == "'${BOOTDIR}'") { print $1; exit }' /etc/fstab)
# If ${BOOTDIR} is not defined in /etc/fstab, it must be the same as /
[ -z "${BOOTFS}" ] && BOOTFS=${ROOTFS}
echo "${ROOTFS} ${BOOTFS}"
}
set_bootloader_grub_read_device_map() {
# Read GRUB device map
[ ! -d ${TEMP} ] && mkdir ${TEMP}
echo "quit" | grub --batch --device-map=${TEMP}/grub.map &>/dev/null
echo "${TEMP}/grub.map"
}
set_bootloader_grub() {
local GRUB_CONF="${BOOTDIR}/grub/grub.conf"
print_info 1 "Adding kernel to ${GRUB_CONF}..."
if [ ! -e ${GRUB_CONF} ]
then
local GRUB_BOOTFS
if [ -n "${BOOTFS}" ]
then
GRUB_BOOTFS=$BOOTFS
else
GRUB_BOOTFS=$(set_bootloader_read_fstab | cut -d' ' -f2)
fi
# Get the GRUB mapping for our device
local GRUB_BOOT_DISK1=$(echo ${GRUB_BOOTFS} | sed -e 's#\(/dev/.\+\)[[:digit:]]\+#\1#')
local GRUB_BOOT_DISK=$(awk '{if ($2 == "'${GRUB_BOOT_DISK1}'") {gsub(/(\(|\))/, "", $1); print $1;}}' ${TEMP}/grub.map)
local GRUB_BOOT_PARTITION=$(($(echo ${GRUB_BOOTFS} | sed -e 's#/dev/.\+\([[:digit:]]?*\)#\1#') - 1))
if [ -n "${GRUB_BOOT_DISK}" -a -n "${GRUB_BOOT_PARTITION}" ]
then
# Create grub configuration directory and file if it doesn't exist.
[ ! -d `dirname ${GRUB_CONF}` ] && mkdir -p `dirname ${GRUB_CONF}`
touch ${GRUB_CONF}
echo 'default 0' >> ${GRUB_CONF}
echo 'timeout 5' >> ${GRUB_CONF}
echo "root (${GRUB_BOOT_DISK},${GRUB_BOOT_PARTITION})" >> ${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}
if [ "${BUILD_INITRD}" -eq '0' ]
then
echo -e "\tkernel /kernel-${KNAME}-${ARCH}-${KV} root=${GRUB_ROOTFS}" >> ${GRUB_CONF}
else
echo -e "\tkernel /kernel-${KNAME}-${ARCH}-${KV} root=/dev/ram0 init=/linuxrc real_root=${GRUB_ROOTFS}" >> ${GRUB_CONF}
if [ "${PAT}" -gt '4' ]
then
echo -e "\tinitrd /initramfs-${KNAME}-${ARCH}-${KV}" >> ${GRUB_CONF}
fi
fi
echo >> ${GRUB_CONF}
else
print_error 1 "Error! ${BOOTDIR}/grub/grub.conf does not exist and the correct settings can not be automatically detected."
print_error 1 "Please manually create your ${BOOTDIR}/grub/grub.conf file."
fi
else
# The grub.conf already exists, so let's try to duplicate the default entry
fi
}

@ -84,15 +84,16 @@ longusage() {
echo " --mdadm Copy /etc/mdadm.conf to initramfs"
echo " --dmraid Include DMRAID support"
echo " --slowusb Enables extra pauses for slow USB CD boots"
echo " --bootloader=grub Add new kernel to GRUB configuration"
echo " --linuxrc=<file> Specifies a user created linuxrc"
echo " --disklabel Include disk label and uuid support in your"
echo " ramdisk"
echo " --luks Include LUKS support"
echo " --> 'emerge cryptsetup-luks' with USE=-dynamic"
echo " --no-busybox Do not include busybox in the initramfs."
echo " --unionfs Include support for unionfs"
echo " --netboot Create a self-contained env in the initramfs"
echo " --real-root=<foo> Specify a default for real_root="
echo " --no-busybox Do not include busybox in the initramfs."
echo " --unionfs Include support for unionfs"
echo " --netboot Create a self-contained env in the initramfs"
echo " --real-root=<foo> Specify a default for real_root="
echo " Internals"
echo " --arch-override=<arch> Force to arch instead of autodetect"
echo " --cachedir=<dir> Override the default cache location"
@ -273,6 +274,10 @@ parse_cmdline() {
CMD_DMRAID=1
print_info 2 "CMD_DMRAID: ${CMD_DMRAID}"
;;
--bootloader=*)
CMD_BOOTLOADER=`parse_opt "$*"`
print_info 2 "CMD_BOOTLOADER: ${CMD_BOOTLOADER}"
;;
--loglevel=*)
CMD_LOGLEVEL=`parse_opt "$*"`
LOGLEVEL="${CMD_LOGLEVEL}"

@ -139,6 +139,16 @@ determine_real_args() {
FUSE_BINCACHE=`arch_replace "${FUSE_BINCACHE}"`
UNIONFS_FUSE_BINCACHE=`arch_replace "${UNIONFS_FUSE_BINCACHE}"`
if [ -n "${CMD_BOOTLOADER}" ]
then
BOOTLOADER="${CMD_BOOTLOADER}"
if [ "${CMD_BOOTLOADER}" != "${CMD_BOOTLOADER/:/}" ]
then
BOOTFS=`echo "${CMD_BOOTLOADER}" | cut -f2- -d:`
BOOTLOADER=`echo "${CMD_BOOTLOADER}" | cut -f1 -d:`
fi
fi
if [ "${NO_KERNEL_SOURCES}" != "1" ]
then
if [ ! -d ${KERNEL_DIR} ]

@ -43,6 +43,7 @@ source ${GK_SHARE}/gen_configkernel.sh || gen_die "Could not read ${GK_SHARE}/ge
source ${GK_SHARE}/gen_initramfs.sh || gen_die "Could not read ${GK_SHARE}/gen_initramfs.sh"
source ${GK_SHARE}/gen_moddeps.sh || gen_die "Could not read ${GK_SHARE}/gen_moddeps.sh"
source ${GK_SHARE}/gen_package.sh || gen_die "Could not read ${GK_SHARE}/gen_package.sh"
source ${GK_SHARE}/gen_bootloader.sh || gen_die "Could not read ${GK_SHARE}/gen_bootloader.sh"
TEMP=${TMPDIR}/$RANDOM.$RANDOM.$RANDOM.$$
@ -328,6 +329,7 @@ fi
if [ "${BUILD_KERNEL}" -eq '1' ]
then
set_bootloader
print_info 1 ''
print_info 1 "Kernel compiled successfully!"
print_info 1 ''

Loading…
Cancel
Save