#! /bin/sh

set -e

. /usr/share/debconf/confmodule

ARCH=`udpkg --print-architecture`

db_get debian-installer/locale
LOCALE="$RET"

# Set locale to C if it has not yet been set
# This can happen during e.g. s390 installs where localechooser is not run
[ -z "$LOCALE" ] && LOCALE="C"

LANGUAGE=${LOCALE%%_*}

# Install specific packages depending on selected language

if [ "$LOCALE" != "C" ] ; then
	# Other language specific packages
	case "$LANGUAGE" in
	    ar|he|fa)
		# RTL languages (Arabic, Hebrew, Farsi)
		apt-install libfribidi0 || true
		;;
	esac
fi

# Install localization-config except when no localization happens
# Install it anyway for powerpc (to handle subarches)
# Disabled for etch as l-c is not ready
#if [ "$LOCALE" != "C" ] || [ "$ARCH" = "powerpc" ]; then
#        apt-install localization-config || true
#fi


db_get debian-installer/consoledisplay || true
consoletype=$(echo $RET | sed -e 's/=.*$//')
case "$consoletype" in
    kbd)
	consolefont=$(echo $RET | sed -e 's/^kbd=//')
	if apt-install kbd; then
		consolefont=$(echo $consolefont | sed -e 's/(.*//')
		if echo "$consolefont" | grep -q "Terminus"; then
			apt-install console-terminus || true
		fi
	fi
	;;
    cyr)
	apt-install console-cyrillic || true
	;;
    console-setup)
	apt-install console-setup || true
	db_set debian-installer/keymap '' || true
	;;
esac

exit 0
