Add check for existing grub.conf entry for kernel

cleanup-cruft
Andrew Gaffney 16 years ago
parent 25fad8fd10
commit 152d259700

@ -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

@ -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"

Loading…
Cancel
Save