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

Bug#224641: Tested and working patch!



OK this patch (grub-installer-1.07-postinst.patch5) is tested and works!

Sorry for the many (broken) revisions!

Alex Owen
--- postinst.orig-rao	2004-11-27 09:32:18.000000000 +0000
+++ postinst	2004-11-27 13:02:48.000000000 +0000
@@ -28,11 +28,30 @@
 	if echo "${defconsole}" | grep -q console=ttyS; then
 		local PORT="$(echo "${defconsole}" | sed -e 's%^console=ttyS%%' -e 's%,.*%%')"
 		local SPEED="$(echo "${defconsole}" | sed -e 's%^console=ttyS[0-9]\+,%%' -e 's% .*%%')"
-		local SERIAL="${PORT},${SPEED}"
+		local SERIAL="ttyS${PORT},${SPEED}"
 		echo "console=$SERIAL"
 	fi
 }
 
+grub_serial_console() {
+	#$1=output of get_serial_console
+	local unit=$(echo $1 | sed -e 's%^console=ttyS%%' -e 's%,.*%%')
+	local speed=$(echo $1 | sed -e 's%^console=ttyS[0-9]\+,%%' -e 's%[^(0-9)].*%%')
+	local parity=$(echo $1 | sed -e 's%^console=ttyS[0-9]\+,[0-9]\+%%' -e 's%[78].*%%')
+	case "$parity" in 
+		"n") local parity="no" ;;
+		"e") local parity="even" ;;
+		"o") local parity="odd" ;;
+		*)   local parity="" ;;
+	esac
+	local word=$(echo $1 | sed -e 's%^console=ttyS[0-9]\+,[0-9]\+[oen]%%' -e 's%r%%')
+	local flow=$(echo $1 | sed -e 's%^console=ttyS[0-9]\+,[0-9]\+[oen][78]%%')
+
+	echo serial --unit=$unit --speed=$speed --word=$word --parity=$parity --stop=1
+	echo terminal serial	
+	}
+
+
 serial="$(get_serial_console)"
 
 # This is copied from update-grub. We've requested that it be moved
@@ -390,6 +409,22 @@
 	update_grub # again, to add new options to all the Debian kernel entries
 fi
 
+if [ -n "$serial" ] ; then
+	#if this is a serial console ensure #kopts is correct...
+	#despite posn of "console=" relative to "--" in /proc/cmdline
+	if ! ( echo "$user_params" | grep -q console=ttyS ) ; then
+	    # Modify menu.lst to include serial console.
+	    sed "s!^\(# kopt=.*\)!\1 $serial!" \
+		< /target/boot/grub/menu.lst > /target/boot/grub/menu.lst.new
+	    mv /target/boot/grub/menu.lst.new /target/boot/grub/menu.lst
+	    update_grub # again, to add new options to all the Debian kernel entries
+	fi
+	# Modify menu.lst so _grub_ uses serial console.
+	grub_serial_console $serial | cat - /target/boot/grub/menu.lst > /target/boot/grub/menu.lst.new
+	mv /target/boot/grub/menu.lst.new /target/boot/grub/menu.lst
+fi 
+
+
 # Generation menu.lst addition for other OSes.
 tmpfile=/tmp/menu.lst.extras
 OLDIFS="$IFS"

Reply to: