#!/usr/bin/perl
# The wrapper script for X.Org keyboard configuration (pre-install)
# This is a clone of XFree86 script

use strict;
use warnings;
use Getopt::Long;

# We use methods in common.pl
require '/usr/lib/localization-config/common/common.pl';
require '/usr/lib/localization-config/common/log.pl';

# The path where the scripts are kept
my $LIB = '/usr/lib/localization-config';

# call init() to initialize the APT config system
init();

# Define the version map for xserver-xfree86
my %xorg_vermap = ( '6.8.2-1',     => { RELEASE => 'sarge' }
                  );

# Define the version map for xserver-xfree86
my %xfree86_vermap = ( '4.1.0-1',     => { RELEASE => 'woody' },
                       '4.3.0-1',     => { RELEASE => 'sarge' }
                     );

# Get lang entry
my $lang = $ARGV[0] or log_die("$0: No language given");

my $xorg_package = "xserver-xorg";
my $xfree86_package = "xserver-xfree86";

my $release;
my $script;

if (is_available($xorg_package)) {
	# Get appropriate release for this package
	$release = get_release($xorg_package, %xorg_vermap);
	$script = "xorg-kbd";
} else {
	$release = get_release($xfree86_package, %xfree86_vermap);
	$script = "xfree86-kbd";
}

# Execute the corresponding script
$script = "$LIB/$release/".$script;
log_msg("$0: Running $script $lang");
system ($script, $lang) if -x $script;

1;
