[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Patch for update-grub for Sarge R3



Hi,

        The /sbin/update-grub script is often used in the postinst
 hook of kernel images, indeed, the man page for update-grub(8)
 explains how to hook the script in.  Even in Sarge, all user
 interaction is meant to be done via debconf; and debconf does not
 like maintainer scripts sendng stuff to STDOUT.

        In Sarge this was not an issue, since kernel image scripts
 were buggy, since they did not use debconf.  In Etch, the kernel
 image bug has been fixed, exposing the Sarge update-grub stdout
 writing bug.  Happily, update-grub also has been fixed in Etch.

        The issue is upgrading from Sarge to Etch; if one tries to
 install a Etch kernel image while still having a Sarge grub; we get a
 debconf error and an aborted install/upgrade.

        One way to mitigate the problem is to propagate a fixed
 update-grub script into a Sarge point release; here is a minimal
 patch that should make a sarge update-grub script be STDOUT safe.

        manoj

--- sbin/update-grub.old	2006-04-19 09:36:32.000000000 -0500
+++ sbin/update-grub	2006-04-19 09:51:43.000000000 -0500
@@ -568,28 +568,28 @@
 }
 
 
-echo -n "Testing for an existing GRUB menu.list file... "
+echo -n "Testing for an existing GRUB menu.list file... " >&2
 
 # Test if our menu file exists
 if [ -f "$menu_file" ] ; then
 	menu="$menu_file"
 	rm -f $newtemplate
 	unset newtemplate
-	echo "found: $menu_file ."
+	echo "found: $menu_file ." >&2
 	cp -f "$menu_file" "$menu_file~"
 else
 	# if not ask user if they want us to create one
 	menu="$menu_file"
-	echo
-	echo
-	echo -n "Could not find $menu_file file. "
+	echo >&2
+	echo >&2
+	echo -n "Could not find $menu_file file. " >&2
 	if [ "-y" = "$command_line_arguments" ] ; then
-		echo 
-		echo "Generating $menu_file"
+		echo  >&2
+		echo "Generating $menu_file" >&2
 		answer=y
 	else
-		echo -n "Would you like $menu_file generated for you? "
-		echo -n "(y/N) "
+		echo -n "Would you like $menu_file generated for you? " >&2
+		echo -n "(y/N) " >&2
 		read answer
 	fi
 
@@ -698,23 +698,23 @@
 echo "## ## End Default Options ##" >> $buffer
 echo >> $buffer
 
-echo -n "Searching for splash image... "
+echo -n "Searching for splash image... " >&2
 current_splash=`grep '^splashimage=' ${grub_dir}/menu.lst || true`
 splashimage_path="splashimage=${grub_root_device}${grub_dir##${boot_device:+/boot}}/splash.xpm.gz"
 if [ -f "${grub_dir}/splash.xpm.gz" ]  && [ "$current_splash" == "" ]; then
-       echo "found: /boot/grub/splash.xpm.gz"
+       echo "found: /boot/grub/splash.xpm.gz" >&2
        echo "$splashimage_path" >> $buffer
        echo >> $buffer
 elif [ -f "${grub_dir}/splash.xpm.gz" ]  && [ "$current_splash" == "$splashimage_path" ]; then
-       echo "found: /boot/grub/splash.xpm.gz"
+       echo "found: /boot/grub/splash.xpm.gz" >&2
        echo "$splashimage_path" >> $buffer
        echo >> $buffer
 elif [ "$current_splash" != "" ] && [ "$current_splash" != "$splashimage_path" ]; then
-       echo "found but preserving previous setting: $(grep '^splashimage=' /boot/grub/menu.lst)"
+       echo "found but preserving previous setting: $(grep '^splashimage=' /boot/grub/menu.lst)" >&2
        echo "$current_splash" >> $buffer
        echo >> $buffer
 else
-       echo "none found, skipping..."
+       echo "none found, skipping..." >&2
 fi
 
 sortedKernels=""
@@ -768,7 +768,7 @@
 		initrd=$kernel_dir/$initrdName
 	fi
 
-	echo "Found kernel: $kernel"
+	echo "Found kernel: $kernel" >&2
 
 	if [ "$kernelName" = "vmlinuz" ]; then
 		if [ -L "/boot/$kernelName" ]; then
@@ -820,7 +820,7 @@
 			currentOpt=
 			initrd=
 
-			echo "Found kernel: $kernel"
+			echo "Found kernel: $kernel" >&2
 
 			write_kernel_entry "$kernelVersion" "" "" "$grub_root_device" \
 			"$kernel" "$currentOpt" "" "$initrd" "false"
@@ -830,7 +830,7 @@
 
 echo $end >> $buffer
 
-echo -n "Updating $menu ... "
+echo -n "Updating $menu ... " >&2
 # Insert the new options into the menu
 if ! grep -q "^$start" $menu ; then
 	cat $buffer >> $menu
@@ -845,5 +845,5 @@
 	cat $menu.new > $menu
 	rm -f $buffer $menu.new
 fi
-echo "done"
-echo
+echo "done" >&2
+echo >&2
-- 
Confessions may be good for the soul, but they are bad for the
reputation. Lord Thomas Dewar
Manoj Srivastava   <srivasta@debian.org>  <http://www.debian.org/%7Esrivasta/>
1024D/BF24424C print 4966 F272 D093 B493 410B  924B 21BA DABB BF24 424C

Reply to: