[Lunar-commits] r14849 - moonbase/trunk/utils/grub/plugin.d
Auke Kok
sofar at lunar-linux.org
Thu May 19 21:44:55 UTC 2005
Author: sofar
Date: 2005-05-19 21:44:54 +0000 (Thu, 19 May 2005)
New Revision: 14849
Modified:
moonbase/trunk/utils/grub/plugin.d/bootloader-grub.plugin
Log:
and Voila, fully working correct and proper, nice, clean, well written, handy, GRUB bootloader support code for new kernel images.
Modified: moonbase/trunk/utils/grub/plugin.d/bootloader-grub.plugin
===================================================================
--- moonbase/trunk/utils/grub/plugin.d/bootloader-grub.plugin 2005-05-19 21:07:01 UTC (rev 14848)
+++ moonbase/trunk/utils/grub/plugin.d/bootloader-grub.plugin 2005-05-19 21:44:54 UTC (rev 14849)
@@ -12,7 +12,22 @@
#############################################################
-map_device_to_grub() {
+unmap_device()
+{
+ local DEVICE
+ for DEVICE in $(ls -1d /dev/[hs]d* 2> /dev/null); do
+ if [ "$(readlink -f $DEVICE)" == "$(readlink -f $1)" ]; then
+ echo $DEVICE
+ return 0
+ fi
+ done
+ echo $1
+ return 0
+}
+
+
+map_devices_to_grub()
+{
local LINE DISC DEVICE TARGET REALTARGET
debug_msg "map_device_to_grub ($@)"
# TODO - make sure partitions count continuously
@@ -35,10 +50,24 @@
(( PART++ ))
echo "hd$((DISC-1)),$((PART-1)):$TARGET:$REALTARGET:"
fi
- done | grep ":$(readlink -f $1):" | cut -d: -f1
+ done
}
+map_device_to_grub()
+{
+ map_devices_to_grub | grep ":$(readlink -f $1):" | cut -d: -f1
+}
+
+
+map_grub_to_device()
+{
+ local DEV
+ DEV=$(echo "$1" | sed 's/[()]//g')
+ unmap_device $((map_devices_to_grub | grep "^$DEV:" | cut -d: -f2) || echo "$1")
+}
+
+
plugin_kernel_updatebootloader_grub()
{(
# preferred? - master switch for experienced users
@@ -80,10 +109,10 @@
if (( IMAGE_COUNT == 0 )) ; then
if ! grep -q "$1" /boot/grub/menu.lst ; then
- printf "title %s\nkernel %s\nroot %s\n\n" $2 $GRUB_BOOT/$1 $GRUB_ROOT "$GRUB_IMAGE_ENTRY" >> /boot/grub/menu.lst.new
+ printf "title %s\nkernel %s\nroot %s\n\n" "$2" "$GRUB_BOOT/$1 root=$(map_grub_to_device $GRUB_ROOT) ro devfs-nomount" "$GRUB_ROOT" "$GRUB_IMAGE_ENTRY" >> /boot/grub/menu.lst.new
fi
if [ -f /boot/"$1.old" ] && ! grep -q "$1.old" /boot/grub/menu.lst ; then
- printf "title %s\nkernel %s\nroot %s\n\n" $2.old $GRUB_BOOT/$1.old $GRUB_ROOT "$GRUB_IMAGE_ENTRY" >> /boot/grub/menu.lst.new
+ printf "title %s\nkernel %s\nroot %s\n\n" "$2.old" "$GRUB_BOOT/$1.old root=$(map_grub_to_device $GRUB_ROOT) ro devfs-nomount" "$GRUB_ROOT" "$GRUB_IMAGE_ENTRY" >> /boot/grub/menu.lst.new
fi
fi
(( IMAGE_COUNT++ ))
@@ -96,10 +125,10 @@
if (( IMAGE_COUNT == 0 )) ; then
if ! grep -q "$1" /boot/grub/menu.lst ; then
- printf "title %s\nkernel %s\nroot %s\n\n" $2 $GRUB_BOOT/$1 $GRUB_ROOT "$GRUB_IMAGE_ENTRY" >> /boot/grub/menu.lst.new
+ printf "title %s\nkernel %s\nroot %s\n\n" "$2" "$GRUB_BOOT/$1 root=$(map_grub_to_device $GRUB_ROOT) ro devfs-nomount" "$GRUB_ROOT" "$GRUB_IMAGE_ENTRY" >> /boot/grub/menu.lst.new
fi
if [ -f /boot/"$1.old" ] && ! grep -q "$1.old" /boot/grub/menu.lst ; then
- printf "title %s\nkernel %s\nroot %s\n\n" $2.old $GRUB_BOOT/$1.old $GRUB_ROOT "$GRUB_IMAGE_ENTRY" >> /boot/grub/menu.lst.new
+ printf "title %s\nkernel %s\nroot %s\n\n" "$2.old" "$GRUB_BOOT/$1.old root=$(map_grub_to_device $GRUB_ROOT) ro devfs-nomount" "$GRUB_ROOT" "$GRUB_IMAGE_ENTRY" >> /boot/grub/menu.lst.new
fi
fi
More information about the Lunar-commits
mailing list