console-common-0.7.88/ 0000755 0000000 0000000 00000000000 11275610062 011434 5 ustar console-common-0.7.88/install-keymap.sgml 0000644 0000000 0000000 00000010121 11233054003 015234 0 ustar Debian GNU/Linux">
]>
dirson@debian.org
1999-2001
Yann Dirson
April 5, 2001
INSTALL-KEYMAP
8
install-keymap
expand a given keymap and install it as boot-time keymap
install-keymap
keymap-name | NONE | KERNEL
/etc/console/boottime.kmap.gz, which will be
loaded into the kernel at boot-time.
One may also specify /etc/console/boottime.kmap.gz
to be removed, making sure that no custom keymap will replace the
kernel's builtin keymap at next reboot.
An argument of
The purpose of this processing is to solve an annoying
problem, of 2 apparently conflicting issues. The first one is an
important goal of keymap management in Debian, namely ensuring
that whenever the user or admin is expected to use the keyboard,
the keymap selected as boot-time keymap is in use; this means the
keymap has to be loaded before a shell is ever proposed, which
means very early in the booting process, and especially before all
local filesystems are mounted
(/etc/rcS.d/S10checkroot.sh can spawn
sulogin).
The second issue is that for flexibility we allow that
/usr or /usr/share may
live on their own partition(s), and thus
/usr/share/keymaps, where keymap files live,
may not be available for reading at the time we need a keymap
file. And no, we won't put 1Mb of keymaps in the root
partition just for this.
And the problem is, most keymap files are not
self-contained, so it does not help to just copy the selected file
into the root partition. The best known solution so far is to
expand the keymap file so that it becomes self-contained, and put
it in the root partition. That's what this tool does.
FILES
/etc/console/boottime.kmap.gz
Where the boot-time keymap is stored
SEE ALSO
loadkeys (8).
AUTHOR
This program and manual page were written by Yann Dirson
dirson@debian.org for the &debian; system, but as
it should not include any Debian-specific code, it may be used by
others.
console-common-0.7.88/kbd-config.8 0000644 0000000 0000000 00000000767 11233054003 013531 0 ustar .TH KBD\-CONFIG 8
.ad
.fi
.SH NAME
kbd\-config
\-
Configure the console keyboard
.SH SYNOPSIS
.na
.nf
\fBkbd\-config\fR
.SH DESCRIPTION
.ad
.fi
\fBkbd\-config\fR was a command present in Debian Potato and other Linux
systems for configuring the keyboard. It is provided here for backwards
compatability.
\fBkbd\-config\fR is a wrapper script around
\fBdpkg-reconfigure console-data\fR.
.SH SEE ALSO
.na
.nf
dpkg-reconfigure(8)
install-keymap(8)
.SH AUTHOR
Alastair McKinstry, mckinstry@computer.org
console-common-0.7.88/getkmapchoice.pl.in 0000755 0000000 0000000 00000007516 11233054003 015204 0 ustar #!/usr/bin/perl
use Debconf::Client::ConfModule ':all';
use Debconf::Log;
sub my_warn {
# Don't dump warnings into STDERR, as it will choke the return
# of results from debconf to install-keymap. Instead put the
# warnings into debconf's debugging channel.
Debconf::Log::debug developer => "getkmapchoice warning: ".join(" ",@_);
}
sub my_die {
# Don't die horribly, as install-keymap will then crash.
# Instead, dump the warning into debconf's logs,
# and return NONE, which hopefully will Do The Right Thing.
my_warn @_;
print STDERR "NONE";
exit 0;
}
#####COMMON#####
sub readfiles($) {
my ($path) = @_;
opendir (DIR, $path) or my_die "Can't open directory \`$path': $!";
my @files = grep { ! /^\./ && -f "$path/$_" } readdir(DIR);
closedir DIR;
foreach my $file (@files) {
# print STDERR "Loading $defsdir/$file\n";
require "$defsdir/$file";
}
}
($ret, $policy) = get ('console-data/keymap/policy');
if ($policy eq "Don't touch keymap") {
# No keymap
$filename = 'NONE';
} elsif ($policy eq 'Select keymap from full list') {
($ret, $filename) = get ('console-data/keymap/full');
if (! $filename) {
$filename = 'NONE';
}
} elsif ($policy eq 'Keep kernel keymap') {
# No keymap
$filename = 'KERNEL';
} else {
# Get infos about selected keymap
($ret, $family) = get ('console-data/keymap/family');
$cfamily = correctname $family;
my_die "No keyboard family selected: $family" unless $ret == 0;
# This should only occur when no keymap is available
if ($family eq '') {
# Tell other programs (eg. install-keymap) not to do anything
print STDERR "NONE";
exit 0;
}
($ret, $layout) = get ("console-data/keymap/$cfamily/layout");
$clayout = correctname $layout;
if ($ret != 0) {
# Oops. mssing entry. recover if possible,
my_warn "No keyboard layout selected: $layout";
if ( ! $FILE ) {
my_die "No keymap selected" ;
} else {
print STDERR $FILE;
exit 0;
}
}
($ret, $kbdvariant) = get ("console-data/keymap/$cfamily/$clayout/variant");
$ckbdvariant = correctname $kbdvariant;
if ($ret != 0) {
# Oops. mssing entry. recover if possible,
my_warn "No keyboard variant selected: $kbdvariant";
if ( ! $FILE ) {
my_die "No keymap selected" ;
} else {
print STDERR $FILE;
exit 0;
}
}
($ret, $mapvariant) = get ("console-data/keymap/$cfamily/$clayout/$ckbdvariant/keymap");
if ($ret != 0) {
# Oops. mssing entry. recover if possible,
my_warn "No keymap variant selected: $mapvariant";
if ( ! $FILE ) {
my_die "No keymap selected" ;
} else {
print STDERR $FILE;
exit 0;
}
}
# Get list of keymap definitions
$defsdir = "/usr/share/console/lists/keymaps";
$keymaps = {};
readfiles ($defsdir);
# Find the right one
foreach my $kbdarch (@{$keymap_defs->{archsets}->{guess_arch($keymap_defs)}}) {
my $maps = $keymaps->{$kbdarch};
$maps = $maps->{$family};
unless (defined $maps) {
my_warn "Family not found ($family)";
$maps = $keymaps->{$kbdarch};
$maps = $maps->{Unknown};
if (defined $maps) {
my_warn "Using $maps instead";
}
next;
}
# 'Norwegian' had a typo in a previous version thus some people still
# have this string in their debconf database.
$layout =~ s/Norvegian/Norwegian/;
$maps = $maps->{$layout};
unless (defined $maps) {
my_warn "Layout not found ($layout)"; next;
}
$maps = $maps->{$kbdvariant};
unless (defined $maps) {
my_warn "Keyboard variant not found ($kbdvariant)"; next;
}
$filename = $maps->{$mapvariant};
unless (defined $filename) {
my_warn "Keymap variant not found ($mapvariant)"; next;
}
}
}
my_die "No matching map found" unless defined $filename;
# output result
print STDERR "$filename\n";
console-common-0.7.88/kbd-config 0000755 0000000 0000000 00000000206 11233054003 013352 0 ustar #!/bin/sh
echo "Warning: kbd-config is now a wrapper for 'dpkg-reconfigure console-data' "
/usr/sbin/dpkg-reconfigure console-data
console-common-0.7.88/common.pl 0000644 0000000 0000000 00000006434 11233054003 013257 0 ustar # -*- perl -*-
use vars qw( $obsolete_keymaps );
# Subarches
# FIXME: not done
# Issues:
# * ppc issues not fully asserted yet
# * /proc/hardware, which only exists on m68k and ppc, seems to be
# an OPTION while configuring the kernel !
# Any fallback when it's not there ?
# * USB set of keymap should contain what ? mac ? pc ? subset of those ?
# SUBARCH KEYMAP SET DETECTION
# m68k/atari atari "Model: Atari"
# m68k/amiga amiga "Model: Amiga"
# m68k/mac mac "Model: Macintosh"
# m68k/mvme pc "Model: Motorola"
# m68k/bvme pc "Model: BVME[46]000"
# m68k/{sun,apollo,next,q40,hp300} Not supported by Debian
# ppc/apus amiga "machine: Amiga"
# ppc/chrp pc,mac "machine: CHRP"
# ppc/pmac mac "machine: PowerMac|[Pp]ower[Bb]ook*|Power|iMac*|PowerMac1*"
# ppc/prep pc "machine: PReP"
# ppc/{bbox,mbx,ppc64,82xx,8xx} Not yet supported by Debian
# arm/* pc (refered to as 'arm' only)
sub guess_arch {
my ($defs) = @_;
my $arch = `dpkg --print-architecture`;
chomp $arch;
# Overrides for testing:
# $arch = 'powerpc';
# $arch = 'm68k';
if (($arch eq 'powerpc') || ($arch eq 'm68k')) {
my $subarch;
if ($arch eq 'powerpc') {
my $line = `sed -n 's/^machine.*: //p' /proc/cpuinfo`;
chomp $line;
abort ($defs, "No \"machine\" field in /proc/cpuinfo") if $line eq '';
$subarch = lc $line;
} elsif ($arch eq 'm68k') {
my $line = `sed -n 's/^Model.*://p' /proc/hardware`;
chomp $line;
abort ($defs, "No \"Model\" field in /proc/hardware") if $line eq '';
$subarch = lc $line;
}
chomp($subarch);
$subarch =~ s/^\s*//;
$subarch = 'amiga' if $subarch =~ m/amiga/;
$subarch = 'chrp' if $subarch =~ m/chrp/;
$subarch = 'prep' if $subarch =~ m/prep/;
$subarch = 'mac' if $subarch =~ m/macintosh|powermac|powerbook|power|imac|powermac1/;
$subarch = 'atari' if $subarch =~ m/atari/;
$subarch = 'mvme' if $subarch =~ m/motorola/;
$subarch = 'bvme' if $subarch =~ m/bvme/;
$arch = "$arch/$subarch";
}
# Overrides for testing:
# $arch = 'sparc';
# $arch = 'powerpc/mac';
# $arch = 'powerpc/chrp';
# $arch = 'm68k/amiga';
# $arch = 'alpha';
return $arch;
}
sub abort {
my ($defs, $msg) = @_;
print STDERR "Debconf module aborted ($msg) - using old config mechanism.\n";
# fset_default($defs);
exit 0;
}
sub correctname($) {
my ($string) = @_;
$string = lc $string;
$string =~ s/[^a-z0-9+\-\.\/]/_/g;
return $string;
}
# BELOW THIS LINE IS STUFF FOR ALL KEYMAP PROVIDERS
$::keymap_defs = {
'prefix' => 'console-data/keymap/',
'toplevel' => 'family',
'sublevels' => [
'layout',
'variant',
'keymap',
],
'allitems' => $::keymaps,
'obsolete' => $::obsolete_keymaps,
'archsets' => {
'i386' => [ 'pc' ],
# 'hurd-i386' => [ 'pc' ],
'sparc' => [ 'sparc' ],
'alpha' => [ 'pc' ],
'arm' => [ 'pc' ],
'arm/riscpc' => [ 'pc' ],
'mips' => [ 'pc' ],
'm68k/atari' => [ 'atari' ],
'm68k/amiga' => [ 'amiga' ],
'm68k/mac' => [ 'mac' ],
'm68k/mvme' => [ 'pc' ],
'm68k/bvme' => [ 'pc' ],
'powerpc/amiga' => [ 'amiga' ], # apus
'powerpc/chrp' => [ 'pc', 'mac' ],
'powerpc/mac' => [ 'pc' ],
'powerpc/prep' => [ 'pc' ],
'amd64' => [ 'pc' ],
},
};
console-common-0.7.88/README 0000644 0000000 0000000 00000000361 11233054003 012303 0 ustar This is the development (trunk) branch of console-common.
Further development is concentrated around:
- migrating from console-data/console-tools to kbd.
- Integrating support for console-cyrillic, fonty.
Alastair McKinstry
2005-02-13
console-common-0.7.88/postinst-lcd-keymaps 0000644 0000000 0000000 00000001167 11233054003 015445 0 ustar if [ "$1" = "configure" ]
then
# Do nothing if console-common is not installed.
if [ -x /usr/share/console/getkmapchoice.pl ]
then
. /usr/share/debconf/confmodule
# If the entry contains a / it's broken so overwrite it with a default
# value. See see #110873
if db_get console-data/keymap/full && echo "$RET" | grep -q "/"; then
db_set console-data/keymap/full us
fi
echo >&2 "Looking for keymap to install:"
if /usr/share/console/getkmapchoice.pl
then
install-keymap `PERL_BADLANG=0 \
/usr/share/console/getkmapchoice.pl 2>&1 | tail -n 1`
fi
fi
fi
console-common-0.7.88/install-keymap 0000755 0000000 0000000 00000011245 11273111401 014306 0 ustar #!/bin/sh
# Copyright (c) 1999-2001 Yann Dirson
CONFDIR=/etc/console
CONFFILEROOT=boottime
KMAPEXT=kmap
# Set up i18n if possible
TEXTDOMAIN=install-keymap
export TEXTDOMAIN
if which gettext >/dev/null
then
GETTEXT="gettext -e -s"
else
GETTEXT="echo -e"
fi
if [ $# != 1 ]
then
$GETTEXT >&2 "Usage: install-keymap [ keymap_file | NONE | KERNEL ]"
exit 1
fi
if [ "$1" = "--help" ]
then
$GETTEXT "Usage: install-keymap [ keymap_file | NONE | KERNEL ]"
exit 0
fi
if [ "$1" = "--version" ]
then
VERSION=`dpkg -l console-common | tail -n 1 | awk '{print $3}' `
# This string can not be localized, and it is not worth trying to
echo "install-keymap: (console-common) " $VERSION
exit 0
fi
keymap="$1"
if [ "$keymap" = NONE ]
then
exit 0
fi
CONSOLE_TYPE=`fgconsole 2>/dev/null`
if [ "$?" != "0" ]
then
$GETTEXT >&2 "Deferring virtual terminal setup until console accessible."
exit 0
fi
check_if_serial_console()
{
if [ $CONSOLE_TYPE = "serial" ]
then
$GETTEXT >&2 "Warning: cannot install keymap on a serial console.\n deferring until non-serial console present."
exit 0
fi
}
if ! which loadkeys >/dev/null
then
$GETTEXT >&2 "Warning: no console utilities installed yet.\n deferring keymap setting until either console-tools or kbd is installed."
exit 0
fi
do_preserving_keymap()
# execute shell command-line preserving the keymap
{
# save keymap
TMP=`tempfile`
if ! dumpkeys >${TMP}; then
check_if_serial_console
$GETTEXT >&2 "Failed to dump keymap!"
$GETTEXT >&2 "This might be because your console cannot be opened. Perhaps you don't have\na video card, are connected via the serial console or ssh.\nNot loading keymap!"
rm -f ${TMP}
exit 0
fi
if ! (eval "$*" && loadkeys -q ${TMP}); then
check_if_serial_console
$GETTEXT >&2 "Failed to preserve keymap!"
rm -f ${TMP}
exit 0
fi
rm -f ${TMP}
}
# Be extra safe
mkdir -p ${CONFDIR}
NEW=`tempfile --suffix .gz`
CONFFILE=${CONFDIR}/${CONFFILEROOT}.${KMAPEXT}.gz
OLD_CONFFILE=${CONFDIR}/${CONFFILEROOT}.old.${KMAPEXT}.gz
backup()
{
# If symlink, then don't overwrite, just provide new one
if [ -h ${CONFFILE} ]
then
mv $NEW ${CONFFILE}.dpkg
$GETTEXT >&2 "conffile ${CONFFILE} is a symlink : not overwriting"
$GETTEXT >&2 "It is recommended that ${CONFFILE} is not a symlink; instead\nedit /etc/console-tools/remap to include any local changes."
$GETTEXT >&2 "The new keymap has been placed in ${CONFFILE}.dpkg ;\nPlease move it as required."
fi
# Keep a backup if no backup already exists
[ -f ${CONFFILE} -a ! -f ${OLD_CONFFILE} ] &&
mv ${CONFFILE} ${OLD_CONFFILE}
# Also backup this one, although it should probably not exist
[ -f ${CONFFILE}%.gz} -a ! -r ${OLD_CONFFILE%.gz} ] &&
mv ${CONFFILE%.gz} ${OLD_CONFFILE%.gz}
if [ "$keymap" != KERNEL -a -f ${NEW} ]
then
mv $NEW $CONFFILE
fi
# Make sure perms are correct
[ -f ${CONFFILE} ] && chmod -f 644 ${CONFFILE} || true
[ -f ${OLD_CONFFILE} ] && chmod -f 644 ${OLD_CONFFILE} || true
}
if [ "$keymap" = KERNEL ]
then
backup
rm -f ${CONFFILE}
else
if [ "`dpkg --print-architecture`" = "arm" ] &&
grep -i '^Hardware.*: \(Acorn-\|RiscStation-\)' /proc/cpuinfo >/dev/null &&
find /usr/share/keymaps/i386/ -type f -name ${keymap} -o \
-name ${keymap}.gz -o -name ${keymap}.kmap.gz
then
# we're pretty sure now we were asked to load a PC keymap on a RiscPC
$GETTEXT >&2 "Notice: doing keycode translation to use PC keymap on RiscPC"
TRANSLATOR=/usr/share/console/ps2-to-riscpc
else
TRANSLATOR=cat
fi
# Running the translator at this point is the best way to look for problems, but
# running it prior to "loadkeys" (where it would belong really) is mostly not possible
# because of include files and include-like directives.
# It may turn out that we really need to do keymap-file expansion differently because
# of this. Sigh.
do_preserving_keymap "loadkeys -q $keymap ; dumpkeys | $TRANSLATOR | gzip -9n > $NEW"
# if diff is available, use it to install only if needed
if [ -r $CONFFILE ] && which diff >/dev/null
then
if diff -q $CONFFILE $NEW >/dev/null
then
rm $NEW
else
backup
fi
else
backup
fi
if ! loadkeys -q $CONFFILE; then
$GETTEXT >&2 "Failed to load keymap!"
fi
# Store md5sum. debconf code uses this to track keymaps it has installed,
# so it doesn't change ones installeed by user. Its compressed, so we
# don't want to use the usual conffiles mechanism.
. /usr/share/debconf/confmodule
MD=`md5sum $CONFFILE | cut -f1 -d' ' `
db_set console-data/bootmap-md5sum $MD
fi
console-common-0.7.88/config.in 0000755 0000000 0000000 00000034172 11233054003 013232 0 ustar #!/usr/bin/perl -w
use strict;
#
# Package contents
#
$::keymaps = {};
# Any item named 'Standard' will be the default choice among its siblings.
# Any single item ditto.
# If none bears that name, declare a sibling element "default => 'his name'".
# Not perfect: the last package declaring a default will win :}
# Maybe package with no default should depend on package with one ?
# Lintian will have to be smart then !
# Maybe implement ratings instead of 'default' flag ?
#####KEYMAPS#####
# END OF DATAPACKAGE-SPECIFIC PART
# BELOW THIS LINE IS THE GENERIC PART
# This a preliminary debconf script for console-related data.
# (c) 1999-2000, Yann Dirson
# It has the following limitations that should be addressed:
# - only handles keymap configuration (ie, only does part of kbdconfig's job)
# - does not allow testing keymap before accepting it (REGRESSION).
# - does not allow reloading a default keymap (REGRESSION).
use Debconf::Client::ConfModule ':all';
die "Syntax error: no argument" if ($#ARGV < 0);
#####COMMON#####
# Layout of questions is:
#
# console-data/keymap/
# /family
# /azerty/
# /layout
# /french/
# /variant
# /without euro/
# /keymap
# FIXME: maybe use eg. country codes in storage, and translate into
# localized string when needed ?
sub declare_keymaps {
my ($defs) = @_;
foreach my $kbdarch (@{$defs->{archsets}->{guess_arch($defs)}}) {
declare_families ($defs, $defs->{allitems}->{$kbdarch}, $defs->{prefix});
}
}
# Maybe set a default choice if none already set
sub maybe_set_default_choice {
# my ($question, $default) = @_;
# (my $ret, my $seen) = fget ($question, 'seen');
# if ($seen eq 'false') {
# my $x = metaget ($question, 'value') ;
# print STDERR " $question is #$x# ";
# }
#set ($question, $default) if $seen eq 'false';
}
#
# Clear obsolete entries from the database,
# Tidy up this ugly hack somehow
sub clear_cruft {
my ($version) = @_;
my $ret = 0;
my $val = '';
if ($version eq '') {
$version='0';
}
my $x=system("dpkg --compare-versions $version lt 0.7.25");
if ($x eq 0 ) {
unregister ('console-data/keymap/full');
my ($ret, $val) = metaget ('console-data/keymap/azerty/french/variant', 'value');
if ($val eq 'With Euro (latin 0)') {
set ('console-data/keymap/azerty/french/variant','With Euro (latin 9)');
}
subst ('console-data/keymap/azerty/french/variant', 'choices',
'Apple USB, PC keyboard (non-US 102 keys), Same as X11 (latin 1), With Euro (latin 9)');
}
# The speakup keymaps were removed from console-data in sarge
($ret, $val) = get ('console-data/keymap/full');
set ('console-data/keymap/full', 'us') if ($val eq "speakup");
set ('console-data/keymap/full', 'lt') if ($val eq "speakup-lt");
my $lith_keymap = 'console-data/keymap/qwerty/lithuanian/standard/keymap';
($ret, $val) = get ($lith_keymap);
set ($lith_keymap, 'latin4') if ($val eq "Speakup");
subst ($lith_keymap, 'choices', 'latin4, unicode');
my $us_keymap = 'console-data/keymap/qwerty/us_american/standard/keymap';
($ret, $val) = get ($us_keymap);
set ($us_keymap, 'standard') if ($val eq "Speakup");
subst ($us_keymap, 'choices',
'Standard, US International (ISO 8859-1), US International (ISO 8859-15), With latin1');
}
sub find_default {
my ($leveldefs, $question) = @_;
if (defined $leveldefs->{default}) {
my $def = $leveldefs->{default};
# FIXME: not really deleted ?!
delete $leveldefs->{default};
return $def;
} elsif (defined $leveldefs->{Standard}) {
return 'Standard';
# } elsif (scalar(keys %{$leveldefs}) == 1) {
} else {
printf STDERR "No default for $question - picking one\n";
$::warned = 1;
return (keys %{$leveldefs})[0];
}
}
sub declare_families {
my ($defs, $familydefs, $prefix) = @_;
my $familyquestion = $prefix . $defs->{toplevel};
$familyquestion = correctname $familyquestion;
# There is only one family question, never need to register more
my ($ret, $families) = metaget ($familyquestion, 'choices');
my @families = split (/, */, $families);
# take default entry into account
my $default = find_default ($familydefs, $familyquestion);
foreach my $family (keys %{$familydefs}) {
# add family if not declared yet
push (@families, $family) unless grep { $_ eq $family } @families;
declare_layouts ($defs,
$familydefs->{$family},
$prefix . $family . '/');
}
# Update list of available families
subst ($familyquestion, 'choices', join (", ", sort @families));
maybe_set_default_choice ($familyquestion, $default);
}
sub declare_layouts {
my ($defs, $layoutdefs, $prefix) = @_;
my $layoutquestion = $prefix . $defs->{sublevels}->[0];
$layoutquestion = correctname $layoutquestion;
# create if needed
my ($ret) = get ($layoutquestion);
register ($defs->{prefix} . 'template/' . $defs->{sublevels}->[0],
$layoutquestion) if $ret == 10;
($ret, my $layouts) = metaget ($layoutquestion, 'choices');
my @layouts = split (/, */, $layouts);
# take default entry into account
my $default = find_default ($layoutdefs, $layoutquestion);
foreach my $layout (keys %{$layoutdefs}) {
# add layout if not declared yet
push (@layouts, $layout) unless grep { $_ eq $layout } @layouts;
declare_kbdvariants ($defs,
$layoutdefs->{$layout},
$prefix . $layout . '/');
}
# Update list of available layouts
subst ($layoutquestion, 'choices', join (", ", sort @layouts));
# Maybe set default choice
maybe_set_default_choice ($layoutquestion, $default);
}
sub declare_kbdvariants {
my ($defs, $kbdvariantdefs, $prefix) = @_;
my $kbdvariantquestion = $prefix . $defs->{sublevels}->[1];
$kbdvariantquestion = correctname $kbdvariantquestion;
# create if needed
my ($ret) = get ($kbdvariantquestion);
register ($defs->{prefix} . 'template/' . $defs->{sublevels}->[1],
$kbdvariantquestion) if $ret == 10;
($ret, my $kbdvariants) = metaget ($kbdvariantquestion, 'choices');
my @kbdvariants = split (/, */, $kbdvariants);
# take default entry into account
my $default = find_default ($kbdvariantdefs, $kbdvariantquestion);
foreach my $kbdvariant (keys %{$kbdvariantdefs}) {
# add kbdvariant if not declared yet
push (@kbdvariants, $kbdvariant) unless grep { $_ eq $kbdvariant } @kbdvariants;
declare_mapvariants ($defs,
$kbdvariantdefs->{$kbdvariant},
$prefix . $kbdvariant . '/');
}
# Update list of available kbdvariants
subst ($kbdvariantquestion, 'choices', join (", ", sort @kbdvariants));
# Maybe set default choice
maybe_set_default_choice ($kbdvariantquestion, $default);
}
sub declare_mapvariants {
my ($defs, $mapvariantdefs, $prefix) = @_;
my $mapvariantquestion = $prefix . $defs->{sublevels}->[2];
$mapvariantquestion = correctname $mapvariantquestion;
# create if needed
my ($ret) = get ($mapvariantquestion);
register ($defs->{prefix} . 'template/' . $defs->{sublevels}->[2],
$mapvariantquestion) if $ret == 10;
# take default entry into account
my $default = find_default ($mapvariantdefs, $mapvariantquestion);
($ret, my $mapvariants) = metaget ($mapvariantquestion, 'choices');
my @mapvariants = split (/, */, $mapvariants);
foreach my $mapvariant (keys %{$mapvariantdefs}) {
# add mapvariant if not declared yet
push (@mapvariants, $mapvariant) unless grep { $_ eq $mapvariant } @mapvariants;
}
# Update list of available mapvariants
subst ($mapvariantquestion, 'choices', join (", ", sort @mapvariants));
maybe_set_default_choice ($mapvariantquestion, $default);
}
# handle transitions in the state machine
sub transition {
my ($defs, $origstate, $priority, $prev, $next) = @_;
my $newstate;
my $ret;
my @retval;
# compute question according to state
my $prefix = $defs->{prefix};
my $question = $prefix . $defs->{toplevel};
for (my $level = 0; $level < $origstate; $level ++) {
my ($ret, $choice) = get ($question);
$prefix = $prefix . $choice . '/';
$question = $prefix . $defs->{sublevels}->[$level];
$question = correctname $question;
}
($ret) = input ($priority, $question);
@retval = go;
if ($retval[0] eq 30) {
$newstate = $prev;
} else {
$newstate = $next;
}
return $newstate;
}
# The real config engine
sub configure {
my ($defs) = @_;
my $ret;
my @retval;
my $state = 0;
# This is a simple state machine for all config items
while ($state != 99) {
#
# Change the keymap ?
#
($state == 0) && do {
# This one has a default, we can trust it has a value
($ret) = input ('high', 'console-data/keymap/policy');
if ($ret == 30) { # if the question is not going to be asked...
maybe_set_default_choice ('console-data/keymap/policy', "Don't touch keymaps");
}
@retval = go;
if ($retval[0] eq 30) {
set ('console-data/keymap/policy', "Don't touch keymap");
exit 30;
}
my $policy = get ('console-data/keymap/policy');
# Ugly workaround for Bug 107700
$policy = 'Select keymap from arch list' if
$policy eq "console-data/keymap/policy doesn't exist";
if ($policy eq 'Select keymap from arch list') {
$state = 1;
next;
} elsif ($policy eq "Don't touch keymap") {
# if the user has a bootime keymap in an old location, warn
if (! -r '/etc/console/boottime.kmap.gz'
and ( -r '/etc/kbd/default.kmap' or -r '/etc/kbd/default.kmap.gz' or
-r '/etc/console-tools/default.kmap' or -r '/etc/console-tools/default.kmap.gz')) {
input ('critical', 'console-data/keymap/ignored');
@retval = go;
if ($retval[0] eq "backup") {
($ret, my $seen) = fget ('console-data/keymap/policy', 'seen');
if ($seen eq 'false') {
# Hitting "back" here has no meaning mostly, but try to behave as sanely as I
# can think of.
exit 30;
} else {
next;
}
}
}
$state = 99;
} elsif ($policy eq 'Keep kernel keymap') {
$state = 99;
} elsif ($policy eq 'Select keymap from full list') {
my $ret;
($ret) = input ('high', 'console-data/keymap/full');
if ($ret == 30) {
$state = 99;
next;
}
@retval = go;
if ($retval[0] eq 'backup') {
$state = 0;
} else {
$state = 99;
my($full);
($ret, $full) = get ('console-data/keymap/full');
if ($full) {
set ('console-data/keymap/full', $::all_maps{$full});
}
}
} else {
die "get(console-data/keymap/policy) said $policy"
}
};
#
# Keymap changes
#
($state == 1) && do {
my $kstate = 0;
if (guess_arch($::keymap_defs) eq 'powerpc/mac') {
my($proc_file) = "/proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes";
if (-e $proc_file) {
open(KEYCODES, $proc_file);
my($input) = ;
chomp($input);
close(KEYCODES);
if ($input eq "0") {
input ('high', 'console-data/keymap/powerpcadb');
@retval = go;
if ($retval[0] eq 'backup') {
$kstate = -1;
} else {
my($answer);
($ret, $answer) = get ('console-data/keymap/powerpcadb');
if ($answer eq 'no') {
set ('console-data/keymap/policy', "Don't touch keymap");
exit;
}
}
if ($kstate != -1) {
open(KEYCODES, "> $proc_file") || die "Cannot open $proc_file for writing!\n";
print KEYCODES "1";
close(KEYCODES);
}
}
}
}
# This is a simple embedded state machine for keymap
while (($kstate != 99) and ($kstate != -1)) {
($kstate == 0) && do { # get_family
$kstate = transition ($defs, 0, 'high', -1, 1);
next;
};
($kstate == 1) && do { # get_layout
$kstate = transition ($defs, 1, 'high', 0, 2);
next;
};
($kstate == 2) && do { # get_kbdvariant
$kstate = transition ($defs, 2, 'medium', 1, 3);
next;
};
($kstate == 3) && do { # get_mapvariant
$kstate = transition ($defs, 3, 'low', 2, 99);
next;
};
}
if ($kstate == -1) {
$state = 0;
} else {
$state = 99;
}
next;
};
#
# The default font, and SFM fallbacks
#
#
# The default ACM ?
#
}
}
sub deconfigure {
my ($defs) = @_;
# FIXME: should deregister our entries' choices
# purge;
# FIXME: should run configuration of console-common afterwards (if needed ?)
}
# GO !
capb ('backup');
# FIXME: this should go in declare_keymaps(), but if I put it there, it
# doesn't seem to work. dunno why
sub walk;
sub walk
{
my $h = shift;
my @id = @_;
for my $k (sort keys %$h)
{
next if $k eq 'default';
if (ref $h->{$k} eq 'HASH')
{
walk $h->{$k}, @id, $k;
next;
}
my($id) = join(' / ', @id, $k);
$::all_maps{$id} = $h->{$k};
}
}
walk $::keymaps;
subst ('console-data/keymap/full', 'choices', join (", ", sort keys %::all_maps));
if ($ARGV[0] eq 'configure') {
$::warned = 0;
# do not attempt declaration of empty keymap-list
declare_keymaps ($::keymap_defs) if %{$::keymaps};
if ($::warned) {
printf STDERR <