#!/bin/sh -e
#
# Test if console keyboard is correct.

# This test will never succeed, because the console-data package will
# first load the keyboard definition into the kernel, and then run
# dumpkeys and save the content into /etc/console/boottime.kmap.gz.
# The generated file will never look like the file in
# /usr/share/keymaps.

exit 0

if test -r /etc/debian-edu/config ; then
    . /etc/debian-edu/config
fi

curmap=/etc/console/boottime.kmap.gz

if test ! -f $curmap ; then
    echo "error: $0: No console keymap in '$curmap'."
    exit 1
fi

map_locale_to_keyboard() {
##
# mapname should be the path under /usr/share/keymaps to the right keymap
##
    case "$1" in
	ca*|es*)
	    mapname="i386/qwerty/es"
	    ;;
	da*)
	    mapname="i386/qwerty/dk-latin1"
	    ;;
	de*)
	    mapname="i386/qwertz/de-latin1-nodeadkeys"
	    ;;
	fr_FR*)
	    mapname="i386/azerty/fr-latin1"
	    ;;
	fi*)
	    mapname="i386/qwerty/fi-latin1"
	    ;;
#	it*)
#	    mapname="i386/qwerty/it"
#	    ;;
#	lv*)
#	    mapname="i386/qwerty/lv-latin7"
#	    ;;
	nb*|no*|nn*|se*)
	    mapname="i386/qwerty/no-latin1"
	    ;;
	nds_DE)
	    mapname="i386/qwertz/de-latin1-nodeadkeys"
	    ;;
	nl_BE*|fr_BE*)
	    mapname="i386/azerty/be-latin1"
	    ;;
	nl_NL*)
	    mapname="i386/qwerty/nl"
	    ;;
	    
	pl_PL*)
	    mapname="i386/qwerty/pl"
	    ;;
	sv*)
	    mapname="i386/qwerty/se-latin1"
	    ;;
	*)
	    # Accept the existing value if the default language is unspecified
	    keymap="$curmap"
	    ;;
    esac
}

map_locale_to_keyboard "$LOCALE"

if test -z "$keymap" ; then
    keymap="/usr/share/keymaps/$mapname.kmap.gz"
fi

if cmp "$curmap" "$keymap" > /dev/null 2>&1 ; then
    echo "success: $0: Current console keymap is identical to '$keymap'."
else
    echo "error: $0: Current console keymap do not match '$keymap'."
fi
