[Lunar-commits] r14991 - moonbase/trunk/utils/grub/plugin.d

Auke Kok sofar at lunar-linux.org
Tue May 24 15:11:23 UTC 2005


Author: sofar
Date: 2005-05-24 15:11:23 +0000 (Tue, 24 May 2005)
New Revision: 14991

Modified:
   moonbase/trunk/utils/grub/plugin.d/bootloader-grub.plugin
Log:
I love restructurizing code so it doesn't list the same code twice.


Modified: moonbase/trunk/utils/grub/plugin.d/bootloader-grub.plugin
===================================================================
--- moonbase/trunk/utils/grub/plugin.d/bootloader-grub.plugin	2005-05-24 15:10:23 UTC (rev 14990)
+++ moonbase/trunk/utils/grub/plugin.d/bootloader-grub.plugin	2005-05-24 15:11:23 UTC (rev 14991)
@@ -99,9 +99,18 @@
 			   "$GRUB_BOOT/$1 root=$(map_grub_to_device $GRUB_ROOT) ro devfs=nomount" \
 			   "$GRUB_ROOT"
 	}
+	
+	add_grub_image()
+	{
+		if ! grep -q "$1" /boot/grub/menu.lst ; then
+			print_grub_image "$1" "$2" >> /boot/grub/menu.lst.new
+		fi
+	 	if [ -f /boot/"$1.old" ] && ! grep -q "$1.old" /boot/grub/menu.lst ; then
+			print_grub_image "$1.old" "$2.old" >> /boot/grub/menu.lst.new
+		fi
+	}
 
 	if ! ( grep -q "$1" /boot/grub/menu.lst && grep -q "$1.old" /boot/grub/menu.lst ) ; then
-		IFS_OLD=$IFS
 		export IFS="
 "
 
@@ -115,12 +124,7 @@
 				echo "" >> /boot/grub/menu.lst.new
 
 				if (( IMAGE_COUNT == 0 )) ; then
-					if ! grep -q "$1" /boot/grub/menu.lst ; then
-						print_grub_image "$1" "$2" >> /boot/grub/menu.lst.new
-					fi
-				 if [ -f /boot/"$1.old" ] && ! grep -q "$1.old" /boot/grub/menu.lst ; then
-						print_grub_image "$1.old" "$2.old" >> /boot/grub/menu.lst.new
-					fi
+					add_grub_image "$1" "$2"
 				fi
 				(( IMAGE_COUNT++ ))
 			fi
@@ -131,16 +135,10 @@
 		done
 
 		if (( IMAGE_COUNT == 0 )) ; then
-			if ! grep -q "$1" /boot/grub/menu.lst ; then
-				print_grub_image "$1" "$2" >> /boot/grub/menu.lst.new
-			fi
-			if [ -f /boot/"$1.old" ] && ! grep -q "$1.old" /boot/grub/menu.lst ; then
-				print_grub_image "$1.old" "$2.old" >> /boot/grub/menu.lst.new
-			fi
+			add_grub_image "$1" "$2"
 		fi
 
 		cp /boot/grub/menu.lst.new /boot/grub/menu.lst
-		export IFS=$IFS_OLD
 	fi
 
 	if query "Edit grub configuration manually ?" n ; then



More information about the Lunar-commits mailing list