# 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:
+ Add check for existing grub.conf entry for kernel
+
15 Dec 2008; Andrew Gaffney <agaffney@gentoo.org> gen_bootloader.sh:
Default to '0' if 'default' line not found at all in existing grub.conf
else
# The grub.conf already exists, so let's try to duplicate the default entry
+ if set_bootloader_grub_check_for_existing_entry "${GRUB_CONF}"; then
+ print_warning 1 "An entry was already found for a kernel/initramfs with this name...skipping update"
+ return 0
+ fi
+
set_bootloader_grub_duplicate_default "${GRUB_CONF}"
fi
sed -r -e "/^[[:space:]]*initrd/s/init(rd|ramfs)-[[:alnum:][:punct:]]+/init\1-${KNAME}-${ARCH}-${KV}/"
}
+set_bootloader_grub_check_for_existing_entry() {
+ local GRUB_CONF=$1
+ if grep -q "^[[:space:]]*kernel[[:space:]=]*.*/kernel-${KNAME}-${ARCH}-${KV}\>" "${GRUB_CONF}" &&
+ grep -q "^[[:space:]]*initrd[[:space:]=]*.*/initramfs-${KNAME}-${ARCH}-${KV}\>" "${GRUB_CONF}"
+ then
+ return 0
+ fi
+ return 1
+}
+
set_bootloader_grub_duplicate_default() {
local GRUB_CONF=$1
local GRUB_CONF_TMP="${GRUB_CONF}.tmp"