[Lunar-commits] r19459 - moonbase/trunk/utils/grub/plugin.d
Auke Kok
sofar at lunar-linux.org
Sun Mar 26 21:49:31 UTC 2006
Author: sofar
Date: 2006-03-26 21:49:30 +0000 (Sun, 26 Mar 2006)
New Revision: 19459
Modified:
moonbase/trunk/utils/grub/plugin.d/bootloader-grub.plugin
Log:
BUGFIX - together with the unmap_device() call this was broken.
Modified: moonbase/trunk/utils/grub/plugin.d/bootloader-grub.plugin
===================================================================
--- moonbase/trunk/utils/grub/plugin.d/bootloader-grub.plugin 2006-03-26 20:38:12 UTC (rev 19458)
+++ moonbase/trunk/utils/grub/plugin.d/bootloader-grub.plugin 2006-03-26 21:49:30 UTC (rev 19459)
@@ -14,42 +14,46 @@
map_devices_to_grub()
{
- local LINE DISC DEVICE TARGET REALTARGET MINOR
- debug_msg "map_device_to_grub ($@)"
- # TODO - make sure partitions count continuously
- # TODO - check if ide, scsi, md is the correct order
- for LINE in $(
- for N in /dev/{h,s}d{a,b,c,d,e,f,g,h}{,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} ; do
- if [[ -e "$N" ]] && grep -qw "${N/\/dev\//}" /proc/partitions ; then
- echo "$(readlink -f $N | sed -e 's/\/dev\/ide/0/g' \
- -e 's/\/dev\/scsi/1/g' | sort):$N:$(readlink -f $N)"
- fi
- done); do
+ local LINE DISC DEVICE TARGET REALTARGET MINOR
+ debug_msg "map_devices_to_grub ($@)"
+ # TODO - make sure partitions count continuously
+ # TODO - check if ide, scsi, md is the correct order
+ IFS=$' \t\n'
+ for LINE in $(
+ for N in /dev/{h,s}d{a,b,c,d,e,f,g,h}{,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} ; do
+ if [[ -e "$N" ]] && grep -qw "${N/\/dev\//}" /proc/partitions ; then
+ echo "$(readlink -f $N | sed -e 's/\/dev\/ide/0/g' \
+ -e 's/\/dev\/scsi/1/g' | sort):$N:$(readlink -f $N)"
+ fi
+ done); do
read DEVICE TARGET REALTARGET < <(echo ${LINE/:/ })
- MINOR=$(grep -w $(basename $DEVICE) /proc/partitions | awk '{print $2}')
- if (( MINOR % 16 == 0 )) ; then
- (( DISC++ ))
- PART=0
- echo "hd$((DISC-1)):$TARGET:$REALTARGET:"
- else
- (( PART++ ))
- echo "hd$((DISC-1)),$((PART-1)):$TARGET:$REALTARGET:"
- fi
- done
+ MINOR=$(grep -w $(basename $DEVICE) /proc/partitions | awk '{print $2}')
+ if (( MINOR % 16 == 0 )) ; then
+ (( DISC++ ))
+ PART=0
+ echo "hd$((DISC-1)):$TARGET:$REALTARGET:"
+ else
+ (( PART++ ))
+ echo "hd$((DISC-1)),$((PART-1)):$TARGET:$REALTARGET:"
+ fi
+ done
+ IFS=$'\t\n'
}
map_device_to_grub()
{
- map_devices_to_grub | grep ":$(readlink -f $1):" | cut -d: -f1
+ debug_msg "map_device_to_grub ($@)"
+ map_devices_to_grub | grep ":$(readlink -f $1):" | cut -d: -f1
}
map_grub_to_device()
{
+ debug_msg "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")
+ unmap_device $(map_devices_to_grub | grep "^$DEV:" | cut -d: -f2)
}
@@ -61,33 +65,33 @@
fi
debug_msg "plugin_kernel_updatebootloader_grub ($@)"
- # we need to determine $GRUB_ROOT and $GRUB_BOOT, but ONLY when we are
+ # we need to determine $GRUB_ROOT and $GRUB_BOOT, but ONLY when we are
# not being called from the ISO, in which case we use the provided values
# this test only checks GRUB_ROOT, because GRUB_BOOT might be empty
if [ -z "$GRUB_ROOT" ]; then
- # determine if BOOT is a separate partition:
- BOOTPART=$(grep "^/dev/" /etc/mtab | awk '($2 == "/boot"){print $1}')
+ # determine if BOOT is a separate partition:
+ BOOTPART=$(grep "^/dev/" /etc/mtab | awk '($2 == "/boot"){print $1}')
# determine what to tell our kernel is the rootfs partition
- ROOTPART=$(grep "^/dev/" /etc/mtab | awk '($2 == "/"){print $1}')
- if [ -n "$BOOTPART" ]; then
- GRUB_BOOT=""
- else
- GRUB_BOOT="/boot"
- fi
- GRUB_ROOT="($(map_device_to_grub $ROOTPART))"
- debug_msg "grub: Using GRUB_BOOT=\"$GRUB_BOOT\""
- debug_msg "grub: Using GRUB_ROOT=\"$GRUB_ROOT\""
+ ROOTPART=$(grep "^/dev/" /etc/mtab | awk '($2 == "/"){print $1}')
+ if [ -n "$BOOTPART" ]; then
+ GRUB_BOOT=""
+ else
+ GRUB_BOOT="/boot"
+ fi
+ GRUB_ROOT="($(map_device_to_grub $ROOTPART))"
+ debug_msg "grub: Using GRUB_BOOT=\"$GRUB_BOOT\""
+ debug_msg "grub: Using GRUB_ROOT=\"$GRUB_ROOT\""
fi
print_grub_image()
{
debug_msg "title $2"
- debug_msg "kernel $GRUB_BOOT/$1 root=$(map_grub_to_device $GRUB_ROOT) ro"
+ debug_msg "kernel $GRUB_BOOT/$1 root=$(map_grub_to_device "$GRUB_ROOT") ro"
echo "title $2"
if echo $1 | grep -q '2.4' ; then
- echo "kernel $GRUB_BOOT/$1 root=$(map_grub_to_device $GRUB_ROOT) ro devfs=nomount"
+ echo "kernel $GRUB_BOOT/$1 root=$(map_grub_to_device "$GRUB_ROOT") ro devfs=nomount"
else
- echo "kernel $GRUB_BOOT/$1 root=$(map_grub_to_device $GRUB_ROOT) ro"
+ echo "kernel $GRUB_BOOT/$1 root=$(map_grub_to_device "$GRUB_ROOT") ro"
fi
echo ""
}
@@ -103,14 +107,13 @@
if ! has_grub_title "$2" /boot/grub/menu.lst ; then
print_grub_image "$1" "$2" >> /boot/grub/menu.lst.new
fi
- if [ -f /boot/"$1.old" ] && ! has_grub_title "$2.old" /boot/grub/menu.lst ; then
+ if [ -f /boot/"$1.old" ] && ! has_grub_title "$2.old" /boot/grub/menu.lst ; then
print_grub_image "$1.old" "$2.old" >> /boot/grub/menu.lst.new
fi
}
if ! ( has_grub_title "$2" /boot/grub/menu.lst && has_grub_title "$2.old" /boot/grub/menu.lst ) ; then
- export IFS="
-"
+ export IFS=$'\n'
rm -rf /boot/grub/menu.lst.new
cp /boot/grub/menu.lst /boot/grub/menu.lst.old
@@ -143,10 +146,10 @@
edit_file /boot/grub/menu.lst
fi
- message ""
- message "${MESSAGE_COLOR}Warning: Do not forget to install grub to your MBR${DEFAULT_COLOR}"
- message "${MESSAGE_COLOR}if you have not done so before rebooting.${DEFAULT_COLOR}"
message ""
+ message "${MESSAGE_COLOR}Warning: Do not forget to install grub to your MBR${DEFAULT_COLOR}"
+ message "${MESSAGE_COLOR}if you have not done so before rebooting.${DEFAULT_COLOR}"
+ message ""
# right now we want to have it run all bootloaders?
return 2
@@ -154,5 +157,3 @@
plugin_register KERNEL_UPDATEBOOTLOADER plugin_kernel_updatebootloader_grub
-
-
More information about the Lunar-commits
mailing list