Add check for existing grub.conf entry for kernel
authorAndrew Gaffney <agaffney@gentoo.org>
Mon, 15 Dec 2008 16:02:51 +0000 (10:02 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Mon, 15 Dec 2008 16:02:51 +0000 (10:02 -0600)
ChangeLog
gen_bootloader.sh

index ddb6839435d8e997abb290f28c7fe6dc1fd8715b..5513d4f9f7527880840cd5aa177b32c79d77d766 100644 (file)
--- 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 <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
 
index 4976e04d19b46e785c7f2a6a60c44d6d4d46da3d..ee13ae6e827754f8c751dc18000fc58f76c67e66 100644 (file)
@@ -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"