#!/usr/bin/perl
# This script configures XFree86 (sarge version 4.3.x)
# The difference of the woody script is in some of the debconf 
# values, otherwise they are similar.

use strict;
use warnings;

# We use preseed() helper subroutine so we have to include
# its definition
require '/usr/lib/localization-config/sarge/lang_X_map.pl';
require '/usr/lib/localization-config/common/xfree86-kbd.pl';
require '/usr/lib/localization-config/common/preseed.pl';
require '/usr/lib/localization-config/common/log.pl';

# Define the package name
my $package = "xserver-xfree86";

# If no locale is given as argument, quit
my $lang = $ARGV[0] or log_die("$0: No language given");

my %keynames = get_keynames();
my %lang_locale_map = get_lang_map();
my %lang_console_map = get_lang_console_map();
my %lang_X_map = get_lang_X_map();
my %subarch_map = get_subarch_map();
                  
# Print the supported locale entries.
if ($lang eq "supported") {
    for my $curlang (sort keys %lang_locale_map) {
        print "$curlang\n";
    }
    exit 0;
}

# Show all available console keymaps
if ($lang eq "showkeymaps") {
    for my $entry (sort keys %lang_console_map) {
        my %sel = get_selected_Xkb_from_console($entry, \%lang_X_map, \%lang_console_map, \%keynames);
        for my $key (sort keys %sel) {
            log_msg("$0:\t".$keynames{$key}.":\t".$sel{$key});
        }
    }
    exit 0;
}

my %sel = select_Xkb($lang, \%lang_X_map, \%lang_console_map, \%keynames);
# Call the preseed() subroutine to set the package debconf values.
preseed($package, \%sel, \%keynames);

exit 0;

1;
