From: Andrew Gaffney Date: Mon, 15 Dec 2008 16:02:51 +0000 (-0600) Subject: Add check for existing grub.conf entry for kernel X-Git-Tag: v3.4.10.903~19 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=152d259700252714da2474544e27475e7b490172;p=genkernel.git Add check for existing grub.conf entry for kernel --- diff --git a/ChangeLog b/ChangeLog index ddb6839..5513d4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ # Copyright 1999-2008 Gentoo Foundation; 2008 Chris Gianelloni, Andrew Gaffney # Distributed under the GPL v2 + 15 Dec 2008; Andrew Gaffney gen_bootloader.sh: + Add check for existing grub.conf entry for kernel + 15 Dec 2008; Andrew Gaffney gen_bootloader.sh: Default to '0' if 'default' line not found at all in existing grub.conf diff --git a/gen_bootloader.sh b/gen_bootloader.sh index 4976e04..ee13ae6 100644 --- a/gen_bootloader.sh +++ b/gen_bootloader.sh @@ -79,6 +79,11 @@ set_bootloader_grub() { 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 @@ -89,6 +94,16 @@ set_bootloader_grub_duplicate_default_replace_kernel_initrd() { 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"