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

Bug#250789: Fixing this bug (termwrap resets console)



Hello,

Fixing this bug was delayed in the past due to upcoming sarge release.
Now when development in trunk is open again I (and not only I) think
that it is time to fix this bug at least in trunk.

Real problem with current termwrap implementation is that it tries to do
some things, that it should not. Currently it is used for setting up
locales, console font & acm, running wrappers if needed and resetting
console font.

Most of this things done by other parts of installer. Languagechooser
creates config files for console-tools or console-cyrillic,
languagechooser's prebaseconfig generates locales. So after first reboot
console is in working state for languages that supported by linux
console and all needed locales are generated. These languages have 
'kbd' or 'cyr' records in languagelist file from languagechooser and
debconf entry debian-installer/consoledisplay.

So only one thing remains to be done by termwrap: it should run wrapper
for languages that are not supported by linux console. Attached patch
removes unneeded termwrap functionality. I propose to apply it to trunk.

-- 
Eugeniy Meshcheryakov

Kyiv National Taras Shevchenko University
Information and Computing Centre
http://icc.univ.kiev.ua
Index: termwrap
===================================================================
--- termwrap	(revision 1529)
+++ termwrap	(working copy)
@@ -68,29 +68,6 @@
 	fi
 }
 
-try_load_charset() {
-	ENCODING=$1
-	ACM=$2
-	FONT=$3
-	
-	# Load character map into the console
-	# ACM name is from /usr/share/consoletrans/$ACM.acm.gz
-	case $TERMINAL in
-	    console)
-		info "Switching console charset mapping to $ENCODING"
-		for vc in `seq 0 6` 
-		do
-			consolechars --tty=/dev/tty$vc -f $FONT
-			charset --tty=/dev/tty$vc G0 $ACM
-		done
-		;;
-	    *)
-		error "Unable to switch charset mapping to $ENCODING with terminal '$TERMINAL'"
-		unset_lang_language
-		;;
-	esac
-}
-
 try_load_fb() {
 	# Load framebuffer module (debian-installer/framebuffer value is null(not true!) or false.)
 	if [ "$(get_db debian-installer/framebuffer)" != "false" ]; then
@@ -110,91 +87,6 @@
 }
 
 ######################################################################
-##	Generate the locale data files if missing
-######################################################################
-
-# Keep the locale info in the _INST variables until they are verified.
-if [ "$LANG" ]; then
-	LANG_INST=$LANG
-	unset LANG
-else
-	LANG_INST=$(get_db debian-installer/locale)
-fi
-if [ "$LANGUAGE" ]; then
-	LANGUAGE_INST=$LANGUAGE
-	unset LANGUAGE
-fi
-
-if [ "$LANG_INST" ]; then
-	localeconf=/etc/locale.gen
-	tmpfile=`/bin/tempfile`
-
-	# Use this to detect if the 'locales' package is installed
-	localegen=`which locale-gen`
-
-	validlocale $LANG_INST 2> /dev/null > $tmpfile || true
-	read locale charset < $tmpfile || true
-	rm -f $tmpfile
-	unset tmpfile
-
-	if ! validlocale $LANG_INST > /dev/null 2>&1; then
-		# Hm, should we install the 'locales' package if it is missing?
-		if [ "$localegen" ] && [ -x $localegen ]; then
-			if grep -q "^$locale " /usr/share/i18n/SUPPORTED; then
-				if ! grep -q "^$locale $charset$" $localeconf 2>/dev/null; then
-					echo "$locale $charset" >> $localeconf
-					$localegen | sed 's/^/termwrap: locale-gen: /' || true
-				fi
-			else
-				# Try without euro since d-i currently gets
-				# this wrong for some locales.
-				locale=$(echo "$locale" | sed 's/@euro$//')
-				if grep -q "^$locale " /usr/share/i18n/SUPPORTED; then
-					LANG_INST=$locale
-					if ! grep -q "^$locale $charset$" $localeconf 2>/dev/null; then
-						echo "$locale $charset" >> $localeconf
-						$localegen | sed 's/^/termwrap: locale-gen: /' || true
-					fi
-				fi
-			fi
-		else
-			warning "Package 'locales' not installed.  Unable to generate locale '$LANG'"
-		fi
-
-		# Make sure the locale is valid
-		if validlocale $LANG_INST > /dev/null 2>&1 ; then
-			if [ "$LANGUAGE_INST" ]; then
-				LANGUAGE=$LANGUAGE_INST
-				export LANGUAGE
-				unset LANGUAGE_INST
-			fi
-			LANG=$LANG_INST
-			LC_COLLATE=C
-			export LANG LC_COLLATE
-			unset LANG_INST
-		else
-			unset LANG_INST
-			unset LANGUAGE_INST
-		fi
-	else
-		if [ "$LANGUAGE_INST" ]; then
-			LANGUAGE=$LANGUAGE_INST
-			export LANGUAGE
-			unset LANGUAGE_INST
-		fi
-		LANG=$LANG_INST
-		LC_COLLATE=C
-		export LANG LC_COLLATE
-		unset LANG_INST
-	fi
-
-	unset locale
-	unset charset
-	unset localeconf
-	unset localegen
-fi
-
-######################################################################
 ##	Recognize terminal type.
 ######################################################################
 case `/usr/bin/tty` in
@@ -270,107 +162,51 @@
 	unset LANG
 	unset LOCALE
 	unset ENCODING
+	;;
+esac
 
-	# Linux console sucks, always load ISO-8859-1 charset mapping
-	try_load_charset "C" iso01 lat0-sun16
+CONSOLETYPE=$(get_db debian-installer/consoledisplay)
+
+case "$CONSOLETYPE" in
+kbd|cyr)
+	# Nothing to do
 	;;
-ISO-8859-1)
-	# Linux console sucks, always load ISO-8859-1 charset mapping
-	if [ "$LANG" != "pt_BR" ] ; then
-		try_load_charset "$ENCODING" iso01 lat0-sun16
-	else
-		try_load_charset "$ENCODING" iso01 lat1-16
-	fi
-	;;
-ISO-8859-2)
-	# Load ISO-8859-2 charset mapping into console
-	try_load_charset "$ENCODING" iso02 lat2-sun16
-	;;
-ISO-8859-7)
-	# Load ISO-8859-7 charset mapping into console
-	try_load_charset "$ENCODING" iso07 iso07.f16
-        ;;
-ISO-8859-9)
-	# Load ISO-8859-9 charset mapping into console
-	try_load_charset "$ENCODING" iso09 ter-916f
-	;;
-ISO-8859-13)
-	# Load ISO-8859-13 charset mapping into console
-	try_load_charset "$ENCODING" iso13 LatArCyrHeb-16
-	;;
-ISO-8859-15)
-	# Load ISO-8859-15 charset mapping into console
-	try_load_charset "$ENCODING" iso15 lat0-sun16
-	;;
-KOI8-R)
-	# Load KOI8-R charset mapping into console
-	if [ -x /usr/bin/cyr ] && [ "$TERMINAL" = console ]; then
-		/usr/bin/cyr -s uni -f 16 -e koi8-r ru_ms ctrl_shift_toggle
-	else
-		try_load_charset "$ENCODING" koi8-r ruscii_8x16
-	fi
-	;;
-KOI8-U)
-	# Load KOU8-U charset mapping into console
-	if [ -x /usr/bin/cyr ]; then
-		/usr/bin/cyr -s uni -f 16 -e koi8-u ua_ms ctrl_shift_toggle
-	else
-		try_load_charset "$ENCODING" koi8u koi8u_8x16
-	fi
-	;;
-CP1251)
-	# Load CP1251 charset mapping into console
-	if [ -x /usr/bin/cyr ] && [ "$TERMINAL" = console ]; then
-		/usr/bin/cyr -s uni -f 16 -e cp1251 bg_bds alt_shift_toggle
-	else
-		try_load_charset "$ENCODING" cp1251 ruscii_8x16
-	fi
-	;;
-eucJP|EUC-JP)
-	# Japanese
-	case $TERMINAL in
-	x)
-		WRAPPER="/usr/X11R6/bin/krxvt"
-		WRAPPER_OPTION="-e"
+*)
+	# Console is not set up by first stage
+	case $ENCODING in
+	eucJP|EUC-JP)
+		# Japanese
+		case $TERMINAL in
+		x)
+			WRAPPER="/usr/X11R6/bin/krxvt"
+			WRAPPER_OPTION="-e"
+			;;
+		console)
+			if [ "$SUBARCH" != pc9800 ] && [ "$TERMINAL" = console ]; then
+				# Any platform except PC9800 require jfbterm
+				# to display japanese fonts on console.
+				try_load_fb
+				WRAPPER="/usr/bin/jfbterm"
+				WRAPPER_OPTION="-q -c other,EUC-JP,iconv,UTF-8 -e"
+			fi
+			;;
+		# On pseudo and serial, we can't tell
+		# if the terminal can display japanese fonts...
+		esac
 		;;
-	console)
-		if [ "$SUBARCH" != pc9800 ] && [ "$TERMINAL" = console ]; then
-			# Any platform except PC9800 require jfbterm
-			# to display japanese fonts on console.
+	*)
+		# Fallback jfbterm
+		# Mainly Korean, Chinese
+		case $TERMINAL in
+		console)
 			try_load_fb
 			WRAPPER="/usr/bin/jfbterm"
-			WRAPPER_OPTION="-q -c other,EUC-JP,iconv,UTF-8 -e"
-		fi
+			WRAPPER_OPTION="-q -c other,$ENCODING,iconv,UTF-8 -e"
+			;;
+		esac
 		;;
-	# On pseudo and serial, we can't tell
-	# if the terminal can display japanese fonts...
 	esac
 	;;
-UTF-8)
-	# Enable UTF-8 in console
-	case $TERMINAL in
-	console)
-		# In the case of Greek console support works,
-		# so we can ignore loading jfbterm
-		if [ $LANG != "el_GR.UTF-8" ]; then
-			try_load_fb
-			WRAPPER="/usr/bin/jfbterm"
-			WRAPPER_OPTION="-q -e"
-		fi
-		;;
-	esac
-	;;
-*)
-	# Fallback jfbterm
-	# Mainly Korean, Chinese
-	case $TERMINAL in
-	console)
-		try_load_fb
-		WRAPPER="/usr/bin/jfbterm"
-		WRAPPER_OPTION="-q -c other,$ENCODING,iconv,UTF-8 -e"
-		;;
-	esac
-	;;
 esac
 
 if [ "$1" = "-nnt" ]; then
@@ -385,62 +221,8 @@
 	$WRAPPER $WRAPPER_OPTION /bin/true && exec $WRAPPER $WRAPPER_OPTION $@
 	
 	# Fallback to C
-	case $ENCODING in
-	ISO-8859-1|ISO-8859-2|ISO-8859-9|ISO-8859-13|ISO-8859-15|KOI8-R|KOI8-U|CP1251)
-		# Nothing to do
-		;;
-	*)
-		# Unset LANG
-		unset_lang_language
-		;;
-	esac
+	unset_lang_language
 fi
 
 $@
 
-# The console font loaded before termwrap started.  No idea how to
-# detect it, so we assume it was ISO-8859-1.
-ORIG_ENCODING="ISO-8859-1"
-ORIG_ACM="iso01"
-ORIG_FONT="lat0-sun16"
-
-case $ENCODING in
-ISO-8859-1)
-	# Nothing to do, using default config
-	;;
-ISO-8859-2)
-	# Unload ISO-8859-2 charset mapping, by loading ISO-8859-1 instead
-	try_load_charset $ORIG_ENCODING $ORIG_ACM $ORIG_FONT
-	;;
-ISO-8859-7)
-	# Unload ISO-8859-7 charset mapping, by loading ISO-8859-1 instead
-	try_load_charset $ORIG_ENCODING $ORIG_ACM $ORIG_FONT
-	;;
-ISO-8859-9)
-	# Unload ISO-8859-9 charset mapping, by loading ISO-8859-1 instead
-	try_load_charset $ORIG_ENCODING $ORIG_ACM $ORIG_FONT
-        ;;
-ISO-8859-13)
-	# Unload ISO-8859-13 charset mapping, by loading ISO-8859-1 instead
-	try_load_charset $ORIG_ENCODING $ORIG_ACM $ORIG_FONT
-	;;
-ISO-8859-15)
-	# Unload ISO-8859-15 charset mapping, by loading ISO-8859-1 instead
-	try_load_charset $ORIG_ENCODING $ORIG_ACM $ORIG_FONT
-	;;
-KOI8-R|KOI8-U)
-	# Unload KOI8-R or KOI8-U charset mapping, by loading ISO-8859-1 instead
-	try_load_charset $ORIG_ENCODING $ORIG_ACM $ORIG_FONT
-	;;
-UTF-8)
-	# Disable UTF-8 in console
-	#if [ "$TERM" = console ] ; then
-	#	echo -ne "\033%@"
-	#else
-	#	: # Nothing to do
-	#fi
-	;;
-*)
-	# Nothing to do
-	;;
-esac

Attachment: signature.asc
Description: Digital signature


Reply to: