#!/bin/sh
set -e
. /usr/share/debconf/confmodule
db_capb backup
CONFIGFILE=/etc/default/keyboard
OLDCONFIGFILE=/etc/default/console-setup
debconf_toggle=''
debconf_switch=''
debconf_altgr=''
debconf_compose=''
debconf_layout=''
debconf_variant=''
XKBMODEL=''
XKBLAYOUT=''
XKBVARIANT=''
XKBOPTIONS=''
if [ -f /usr/share/console-setup/keyboard-configuration.config ]; then
is_debian_installer=yes
is_not_debian_installer=''
else
is_debian_installer=''
is_not_debian_installer=yes
fi
which () {
local IFS
IFS=:
for i in $PATH; do
if [ -f "$i/$1" -a -x "$i/$1" ]; then
echo "$i/$1"
return 0
fi
done
return 1
}
db_default () {
db_get keyboard-configuration/store_defaults_in_debconf_db
if [ "$RET" = true ]; then
db_set $1 "$2"
fi
}
regex_escape () {
sed \
-e 's/[.]/%period%/g' \
-e 's/\[/%lbracket%/g' \
-e 's/\]/%rbracket%/g' \
-e 's/\^/%caret%/g' \
-e 's/\$/%dollar%/g' \
-e 's/\\/%bslash%/g' \
-e 's/[/]/%slash%/g' \
-e 's/[?]/%question%/g' \
-e 's/[+]/%plus%/g'
}
regex_pattern_escape () {
sed \
-e 's/[.]/%period%/g' \
-e 's/\[/%lbracket%/g' \
-e 's/\]/%rbracket%/g' \
-e 's/\^/%caret%/g' \
-e 's/\$/%dollar%/g' \
-e 's/\\/%bslash%/g' \
-e 's/[/]/%slash%/g' \
-e 's/[?]/%question%/g' \
-e 's/[+]/%plus%/g' \
-e 's/[*]/\\*/g'
}
regex_unescape () {
sed \
-e 's/%period%/./g' \
-e 's/%lbracket%/[/g' \
-e 's/%rbracket%/]/g' \
-e 's/%caret%/^/g' \
-e 's/%dollar%/$/g' \
-e 's/%bslash%/\\/g' \
-e 's/%slash%/\//g' \
-e 's/%question%/?/g' \
-e 's/%plus%/+/g'
}
all_kbdnames () {
cat <<'EOF' 
C*layout*custom*K
C*variant*custom**K
C*layout*al*K
C*variant*al**K
C*variant*al*plisi*K
C*variant*al*veqilharxhi*K
C*layout*et*K
C*variant*et**K
C*layout*ara*K
C*variant*ara**K
C*variant*ara*azerty*K
C*variant*ara*azerty_digits*K
C*variant*ara*buckwalter*K
C*variant*ara*digits*K
C*variant*ara*mac*K
C*variant*ara*mac-phonetic*K
C*variant*ara*olpc*K
C*layout*eg*K
C*variant*eg**K
C*layout*iq*K
C*variant*iq**K
C*variant*iq*ku_ara*K
C*variant*iq*ku_f*K
C*variant*iq*ku_alt*K
C*variant*iq*ku*K
C*layout*ma*K
C*variant*ma**K
C*variant*ma*tifinagh-alt*K
C*variant*ma*tifinagh-extended-phonetic*K
C*variant*ma*tifinagh-extended*K
C*variant*ma*tifinagh-phonetic*K
C*variant*ma*tifinagh-alt-phonetic*K
C*variant*ma*tifinagh*K
C*variant*ma*french*K
C*variant*ma*rif*K
C*layout*sy*K
C*variant*sy**K
C*variant*sy*ku_f*K
C*variant*sy*ku_alt*K
C*variant*sy*ku*K
C*variant*sy*syc*K
C*variant*sy*syc_phonetic*K
C*layout*am*K
C*variant*am**K
C*variant*am*eastern-alt*K
C*variant*am*phonetic-alt*K
C*variant*am*eastern*K
C*variant*am*phonetic*K
C*variant*am*western*K
C*layout*az*K
C*variant*az**K
C*variant*az*cyrillic*K
C*layout*ml*K
C*variant*ml**K
C*variant*ml*us-mac*K
C*variant*ml*us-intl*K
C*variant*ml*fr-oss*K
C*layout*bd*K
C*variant*bd**K
C*variant*bd*probhat*K
C*layout*by*K
C*variant*by**K
C*variant*by*latin*K
C*variant*by*intl*K
C*variant*by*legacy*K
C*variant*by*phonetic*K
C*variant*by*ru*K
C*layout*be*K
C*variant*be**K
C*variant*be*iso-alternate*K
C*variant*be*oss_latin9*K
C*variant*be*wang*K
C*variant*be*oss*K
C*variant*be*nodeadkeys*K
C*layout*dz*K
C*variant*dz**K
C*variant*dz*ar*K
C*variant*dz*ber*K
C*variant*dz*azerty-deadkeys*K
C*variant*dz*qwerty-gb-deadkeys*K
C*variant*dz*qwerty-us-deadkeys*K
C*layout*ba*K
C*variant*ba**K
C*variant*ba*us*K
C*variant*ba*unicodeus*K
C*variant*ba*unicode*K
C*variant*ba*alternatequotes*K
C*layout*brai*K
C*variant*brai**K
C*variant*brai*left_hand*K
C*variant*brai*left_hand_invert*K
C*variant*brai*right_hand*K
C*variant*brai*right_hand_invert*K
C*layout*bg*K
C*variant*bg**K
C*variant*bg*bekl*K
C*variant*bg*bas_phonetic*K
C*variant*bg*phonetic*K
C*layout*mm*K
C*variant*mm**K
C*variant*mm*zawgyi*K
C*variant*mm*mnw*K
C*variant*mm*mnw-a1*K
C*variant*mm*shn*K
C*variant*mm*zgt*K
C*layout*cn*K
C*variant*cn**K
C*variant*cn*altgr-pinyin*K
C*variant*cn*mon_trad*K
C*variant*cn*mon_trad_galik*K
C*variant*cn*mon_manchu_galik*K
C*variant*cn*mon_trad_manchu*K
C*variant*cn*mon_todo_galik*K
C*variant*cn*mon_trad_todo*K
C*variant*cn*mon_trad_xibe*K
C*variant*cn*tib*K
C*variant*cn*tib_asciinum*K
C*variant*cn*ug*K
C*layout*hr*K
C*variant*hr**K
C*variant*hr*us*K
C*variant*hr*unicodeus*K
C*variant*hr*unicode*K
C*variant*hr*alternatequotes*K
C*layout*cz*K
C*variant*cz**K
C*variant*cz*qwerty*K
C*variant*cz*qwerty-mac*K
C*variant*cz*winkeys-qwerty*K
C*variant*cz*qwerty_bksl*K
C*variant*cz*winkeys*K
C*variant*cz*ucw*K
C*variant*cz*dvorak-ucw*K
C*variant*cz*bksl*K
C*variant*cz*rus*K
C*layout*dk*K
C*variant*dk**K
C*variant*dk*dvorak*K
C*variant*dk*mac*K
C*variant*dk*mac_nodeadkeys*K
C*variant*dk*winkeys*K
C*variant*dk*nodeadkeys*K
C*layout*af*K
C*variant*af**K
C*variant*af*fa-olpc*K
C*variant*af*ps*K
C*variant*af*ps-olpc*K
C*variant*af*uz*K
C*variant*af*uz-olpc*K
C*layout*mv*K
C*variant*mv**K
C*layout*nl*K
C*variant*nl**K
C*variant*nl*mac*K
C*variant*nl*us*K
C*variant*nl*std*K
C*layout*bt*K
C*variant*bt**K
C*layout*au*K
C*variant*au**K
C*layout*cm*K
C*variant*cm**K
C*variant*cm*azerty*K
C*variant*cm*dvorak*K
C*variant*cm*qwerty*K
C*variant*cm*french*K
C*variant*cm*mmuock*K
C*layout*gh*K
C*variant*gh**K
C*variant*gh*akan*K
C*variant*gh*avn*K
C*variant*gh*gillbt*K
C*variant*gh*generic*K
C*variant*gh*ewe*K
C*variant*gh*fula*K
C*variant*gh*ga*K
C*variant*gh*hausa*K
C*layout*nz*K
C*variant*nz**K
C*variant*nz*mao*K
C*layout*ng*K
C*variant*ng**K
C*variant*ng*hausa*K
C*variant*ng*igbo*K
C*variant*ng*yoruba*K
C*layout*za*K
C*variant*za**K
C*layout*gb*K
C*variant*gb**K
C*variant*gb*colemak*K
C*variant*gb*colemak_dh*K
C*variant*gb*dvorak*K
C*variant*gb*dvorakukp*K
C*variant*gb*mac*K
C*variant*gb*mac_intl*K
C*variant*gb*extd*K
C*variant*gb*intl*K
C*variant*gb*pl*K
C*variant*gb*gla*K
C*layout*us*K
C*variant*us**K
C*variant*us*chr*K
C*variant*us*colemak*K
C*variant*us*colemak_dh_iso*K
C*variant*us*colemak_dh_ortho*K
C*variant*us*colemak_dh_wide_iso*K
C*variant*us*colemak_dh_wide*K
C*variant*us*colemak_dh*K
C*variant*us*dvorak*K
C*variant*us*dvorak-mac*K
C*variant*us*dvorak-mac-iso*K
C*variant*us*dvorak-alt-intl*K
C*variant*us*dvorak-intl*K
C*variant*us*dvorak-l*K
C*variant*us*dvorak-r*K
C*variant*us*mac*K
C*variant*us*mac-iso*K
C*variant*us*norman*K
C*variant*us*symbolic*K
C*variant*us*alt-intl*K
C*variant*us*euro*K
C*variant*us*intl*K
C*variant*us*workman*K
C*variant*us*workman-intl*K
C*variant*us*dvorak-classic*K
C*variant*us*altgr-intl*K
C*variant*us*dvp*K
C*variant*us*olpc2*K
C*variant*us*haw*K
C*variant*us*rus*K
C*variant*us*hbs*K
C*layout*epo*K
C*variant*epo**K
C*variant*epo*legacy*K
C*layout*ee*K
C*variant*ee**K
C*variant*ee*dvorak*K
C*variant*ee*us*K
C*variant*ee*nodeadkeys*K
C*layout*fo*K
C*variant*fo**K
C*variant*fo*nodeadkeys*K
C*layout*ph*K
C*variant*ph**K
C*variant*ph*capewell-dvorak-bay*K
C*variant*ph*capewell-dvorak*K
C*variant*ph*capewell-qwerf2k6-bay*K
C*variant*ph*capewell-qwerf2k6*K
C*variant*ph*colemak-bay*K
C*variant*ph*colemak*K
C*variant*ph*dvorak-bay*K
C*variant*ph*dvorak*K
C*variant*ph*qwerty-bay*K
C*layout*fi*K
C*variant*fi**K
C*variant*fi*mac*K
C*variant*fi*winkeys*K
C*variant*fi*classic*K
C*variant*fi*nodeadkeys*K
C*variant*fi*smi*K
C*layout*fr*K
C*variant*fr**K
C*variant*fr*bre*K
C*variant*fr*azerty*K
C*variant*fr*afnor*K
C*variant*fr*bepo*K
C*variant*fr*bepo_afnor*K
C*variant*fr*bepo_latin9*K
C*variant*fr*dvorak*K
C*variant*fr*ergol*K
C*variant*fr*ergol_iso*K
C*variant*fr*mac*K
C*variant*fr*us*K
C*variant*fr*oss*K
C*variant*fr*oss_latin9*K
C*variant*fr*oss_nodeadkeys*K
C*variant*fr*latin9*K
C*variant*fr*latin9_nodeadkeys*K
C*variant*fr*nodeadkeys*K
C*variant*fr*geo*K
C*variant*fr*oci*K
C*layout*ca*K
C*variant*ca**K
C*variant*ca*multix*K
C*variant*ca*eng*K
C*variant*ca*fr-dvorak*K
C*variant*ca*fr-legacy*K
C*variant*ca*ike*K
C*layout*cd*K
C*variant*cd**K
C*layout*tg*K
C*variant*tg**K
C*layout*ge*K
C*variant*ge**K
C*variant*ge*mess*K
C*variant*ge*ergonomic*K
C*variant*ge*os*K
C*variant*ge*ru*K
C*layout*de*K
C*variant*de**K
C*variant*de*dvorak*K
C*variant*de*e1*K
C*variant*de*e2*K
C*variant*de*mac*K
C*variant*de*mac_nodeadkeys*K
C*variant*de*neo*K
C*variant*de*qwerty*K
C*variant*de*T3*K
C*variant*de*us*K
C*variant*de*deadacute*K
C*variant*de*deadgraveacute*K
C*variant*de*deadtilde*K
C*variant*de*nodeadkeys*K
C*variant*de*dsb*K
C*variant*de*dsb_qwertz*K
C*variant*de*ro*K
C*variant*de*ro_nodeadkeys*K
C*variant*de*ru*K
C*variant*de*tr*K
C*layout*at*K
C*variant*at**K
C*variant*at*mac*K
C*variant*at*nodeadkeys*K
C*layout*ch*K
C*variant*ch**K
C*variant*ch*fr*K
C*variant*ch*fr_mac*K
C*variant*ch*fr_nodeadkeys*K
C*variant*ch*de_mac*K
C*variant*ch*legacy*K
C*variant*ch*de_nodeadkeys*K
C*layout*gr*K
C*variant*gr**K
C*variant*gr*nodeadkeys*K
C*variant*gr*polytonic*K
C*variant*gr*simple*K
C*layout*il*K
C*variant*il**K
C*variant*il*biblical*K
C*variant*il*si2*K
C*variant*il*lyx*K
C*variant*il*phonetic*K
C*layout*hu*K
C*variant*hu**K
C*variant*hu*qwerty*K
C*variant*hu*101_qwerty_comma_dead*K
C*variant*hu*101_qwerty_comma_nodead*K
C*variant*hu*101_qwerty_dot_dead*K
C*variant*hu*101_qwerty_dot_nodead*K
C*variant*hu*102_qwerty_comma_dead*K
C*variant*hu*102_qwerty_comma_nodead*K
C*variant*hu*102_qwerty_dot_dead*K
C*variant*hu*102_qwerty_dot_nodead*K
C*variant*hu*101_qwertz_comma_dead*K
C*variant*hu*101_qwertz_comma_nodead*K
C*variant*hu*101_qwertz_dot_dead*K
C*variant*hu*101_qwertz_dot_nodead*K
C*variant*hu*102_qwertz_comma_dead*K
C*variant*hu*102_qwertz_comma_nodead*K
C*variant*hu*102_qwertz_dot_dead*K
C*variant*hu*102_qwertz_dot_nodead*K
C*variant*hu*nodeadkeys*K
C*variant*hu*standard*K
C*layout*is*K
C*variant*is**K
C*variant*is*dvorak*K
C*variant*is*mac*K
C*variant*is*mac_legacy*K
C*layout*in*K
C*variant*in**K
C*variant*in*asm-kagapa*K
C*variant*in*ben*K
C*variant*in*ben_inscript*K
C*variant*in*ben_baishakhi*K
C*variant*in*ben_bornona*K
C*variant*in*ben_gitanjali*K
C*variant*in*ben-kagapa*K
C*variant*in*ben_probhat*K
C*variant*in*eng*K
C*variant*in*guj*K
C*variant*in*guj-kagapa*K
C*variant*in*bolnagri*K
C*variant*in*hin-kagapa*K
C*variant*in*hin-wx*K
C*variant*in*iipa*K
C*variant*in*kan*K
C*variant*in*kan-kagapa*K
C*variant*in*mal*K
C*variant*in*mal_lalitha*K
C*variant*in*mal_poorna*K
C*variant*in*mal_enhanced*K
C*variant*in*mni*K
C*variant*in*mar-kagapa*K
C*variant*in*marathi*K
C*variant*in*ori*K
C*variant*in*ori-bolnagri*K
C*variant*in*ori-wx*K
C*variant*in*jhelum*K
C*variant*in*guru*K
C*variant*in*san-kagapa*K
C*variant*in*sat*K
C*variant*in*tam*K
C*variant*in*tam_tamilnumbers*K
C*variant*in*tamilnet_tamilnumbers*K
C*variant*in*tamilnet*K
C*variant*in*tamilnet_TAB*K
C*variant*in*tamilnet_TSCII*K
C*variant*in*tel*K
C*variant*in*tel-kagapa*K
C*variant*in*tel-sarala*K
C*variant*in*urd-winkeys*K
C*variant*in*urd-phonetic3*K
C*variant*in*urd-phonetic*K
C*layout*id*K
C*variant*id**K
C*variant*id*melayu-phoneticx*K
C*variant*id*melayu-phonetic*K
C*variant*id*pegon-phonetic*K
C*variant*id*javanese*K
C*layout*ie*K
C*variant*ie**K
C*variant*ie*CloGaelach*K
C*variant*ie*UnicodeExpert*K
C*variant*ie*ogam*K
C*variant*ie*ogam_is434*K
C*layout*it*K
C*variant*it**K
C*variant*it*fur*K
C*variant*it*geo*K
C*variant*it*ibm*K
C*variant*it*mac*K
C*variant*it*us*K
C*variant*it*winkeys*K
C*variant*it*nodeadkeys*K
C*variant*it*scn*K
C*layout*jp*K
C*variant*jp**K
C*variant*jp*dvorak*K
C*variant*jp*kana*K
C*variant*jp*mac*K
C*variant*jp*OADG109A*K
C*layout*kz*K
C*variant*kz**K
C*variant*kz*latin*K
C*variant*kz*ext*K
C*variant*kz*kazrus*K
C*variant*kz*ruskaz*K
C*layout*kh*K
C*variant*kh**K
C*layout*kr*K
C*variant*kr**K
C*variant*kr*kr104*K
C*layout*kg*K
C*variant*kg**K
C*variant*kg*phonetic*K
C*layout*la*K
C*variant*la**K
C*variant*la*stea*K
C*layout*lv*K
C*variant*lv**K
C*variant*lv*fkey*K
C*variant*lv*modern-cyr*K
C*variant*lv*modern*K
C*variant*lv*adapted*K
C*variant*lv*apostrophe*K
C*variant*lv*ergonomic*K
C*variant*lv*tilde*K
C*layout*lt*K
C*variant*lt**K
C*variant*lt*ibm*K
C*variant*lt*lekp*K
C*variant*lt*lekpa*K
C*variant*lt*ratise*K
C*variant*lt*us*K
C*variant*lt*std*K
C*variant*lt*sgs*K
C*layout*mk*K
C*variant*mk**K
C*variant*mk*nodeadkeys*K
C*layout*my*K
C*variant*my**K
C*variant*my*phonetic*K
C*layout*mt*K
C*variant*mt**K
C*variant*mt*alt-gb*K
C*variant*mt*us*K
C*variant*mt*alt-us*K
C*layout*md*K
C*variant*md**K
C*variant*md*gag*K
C*layout*mn*K
C*variant*mn**K
C*layout*me*K
C*variant*me**K
C*variant*me*cyrillic*K
C*variant*me*cyrillicyz*K
C*variant*me*cyrillicalternatequotes*K
C*variant*me*latinyz*K
C*variant*me*latinunicode*K
C*variant*me*latinunicodeyz*K
C*variant*me*latinalternatequotes*K
C*layout*gn*K
C*variant*gn**K
C*layout*np*K
C*variant*np**K
C*layout*no*K
C*variant*no**K
C*variant*no*smi*K
C*variant*no*smi_nodeadkeys*K
C*variant*no*colemak*K
C*variant*no*colemak_dh_wide*K
C*variant*no*colemak_dh*K
C*variant*no*dvorak*K
C*variant*no*mac*K
C*variant*no*mac_nodeadkeys*K
C*variant*no*winkeys*K
C*variant*no*nodeadkeys*K
C*layout*ir*K
C*variant*ir**K
C*variant*ir*azb*K
C*variant*ir*ku_ara*K
C*variant*ir*ku_f*K
C*variant*ir*ku_alt*K
C*variant*ir*ku*K
C*variant*ir*winkeys*K
C*variant*ir*pes_keypad*K
C*layout*pl*K
C*variant*pl**K
C*variant*pl*csb*K
C*variant*pl*dvorak*K
C*variant*pl*dvorak_altquotes*K
C*variant*pl*dvorak_quotes*K
C*variant*pl*qwertz*K
C*variant*pl*legacy*K
C*variant*pl*dvp*K
C*variant*pl*ru_phonetic_dvorak*K
C*variant*pl*szl*K
C*layout*pt*K
C*variant*pt**K
C*variant*pt*nativo-epo*K
C*variant*pt*mac*K
C*variant*pt*mac_nodeadkeys*K
C*variant*pt*nativo-us*K
C*variant*pt*nativo*K
C*variant*pt*nodeadkeys*K
C*layout*br*K
C*variant*br**K
C*variant*br*nativo-epo*K
C*variant*br*dvorak*K
C*variant*br*thinkpad*K
C*variant*br*nativo-us*K
C*variant*br*nativo*K
C*variant*br*nodeadkeys*K
C*variant*br*rus*K
C*layout*ro*K
C*variant*ro**K
C*variant*ro*winkeys*K
C*variant*ro*std*K
C*layout*ru*K
C*variant*ru**K
C*variant*ru*ab*K
C*variant*ru*bak*K
C*variant*ru*cv*K
C*variant*ru*cv_latin*K
C*variant*ru*xal*K
C*variant*ru*kom*K
C*variant*ru*chm*K
C*variant*ru*os_winkeys*K
C*variant*ru*os_legacy*K
C*variant*ru*dos*K
C*variant*ru*mac*K
C*variant*ru*ruchey_en*K
C*variant*ru*ruchey_ru*K
C*variant*ru*legacy*K
C*variant*ru*phonetic*K
C*variant*ru*phonetic_azerty*K
C*variant*ru*phonetic_dvorak*K
C*variant*ru*phonetic_winkeys*K
C*variant*ru*phonetic_YAZHERTY*K
C*variant*ru*typewriter*K
C*variant*ru*typewriter-legacy*K
C*variant*ru*srp*K
C*variant*ru*tt*K
C*variant*ru*udm*K
C*variant*ru*sah*K
C*layout*rs*K
C*variant*rs**K
C*variant*rs*rue*K
C*variant*rs*yz*K
C*variant*rs*alternatequotes*K
C*variant*rs*latin*K
C*variant*rs*latinyz*K
C*variant*rs*latinunicode*K
C*variant*rs*latinunicodeyz*K
C*variant*rs*latinalternatequotes*K
C*layout*lk*K
C*variant*lk**K
C*variant*lk*us*K
C*variant*lk*tam_unicode*K
C*variant*lk*tam_TAB*K
C*layout*sk*K
C*variant*sk**K
C*variant*sk*qwerty*K
C*variant*sk*qwerty_bksl*K
C*variant*sk*bksl*K
C*layout*si*K
C*variant*si**K
C*variant*si*us*K
C*variant*si*alternatequotes*K
C*layout*es*K
C*variant*es**K
C*variant*es*ast*K
C*variant*es*cat*K
C*variant*es*dvorak*K
C*variant*es*winkeys*K
C*variant*es*deadtilde*K
C*variant*es*nodeadkeys*K
C*layout*latam*K
C*variant*latam**K
C*variant*latam*colemak*K
C*variant*latam*dvorak*K
C*variant*latam*deadtilde*K
C*variant*latam*nodeadkeys*K
C*layout*ke*K
C*variant*ke**K
C*variant*ke*kik*K
C*layout*tz*K
C*variant*tz**K
C*layout*se*K
C*variant*se**K
C*variant*se*smi*K
C*variant*se*rus*K
C*variant*se*colemak*K
C*variant*se*dvorak*K
C*variant*se*us_dvorak*K
C*variant*se*mac*K
C*variant*se*svdvorak*K
C*variant*se*us*K
C*variant*se*nodeadkeys*K
C*variant*se*swl*K
C*layout*tw*K
C*variant*tw**K
C*variant*tw*saisiyat*K
C*variant*tw*indigenous*K
C*layout*tj*K
C*variant*tj**K
C*variant*tj*legacy*K
C*layout*th*K
C*variant*th**K
C*variant*th*mnc*K
C*variant*th*pat*K
C*variant*th*tis*K
C*layout*bw*K
C*variant*bw**K
C*layout*tr*K
C*variant*tr**K
C*variant*tr*ku_f*K
C*variant*tr*ku_alt*K
C*variant*tr*ku*K
C*variant*tr*alt*K
C*variant*tr*e*K
C*variant*tr*f*K
C*variant*tr*intl*K
C*layout*tm*K
C*variant*tm**K
C*variant*tm*alt*K
C*layout*ua*K
C*variant*ua**K
C*variant*ua*crh_alt*K
C*variant*ua*crh_f*K
C*variant*ua*crh*K
C*variant*ua*winkeysenhanced*K
C*variant*ua*winkeys*K
C*variant*ua*homophonic*K
C*variant*ua*legacy*K
C*variant*ua*macOS*K
C*variant*ua*phonetic*K
C*variant*ua*typewriter*K
C*layout*pk*K
C*variant*pk**K
C*variant*pk*ara*K
C*variant*pk*snd*K
C*variant*pk*pak_urdu_phonetic*K
C*variant*pk*urd-crulp*K
C*variant*pk*urd-nla*K
C*layout*uz*K
C*variant*uz**K
C*variant*uz*latin*K
C*layout*vn*K
C*variant*vn**K
C*variant*vn*fr*K
C*variant*vn*us*K
C*layout*sn*K
C*variant*sn**K
EOF
[ ! -f /usr/share/console-setup/kbdnames.gz ] || zcat /usr/share/console-setup/kbdnames.gz 
}
keyboard_present () {
local kern kbdpattern class subclass protocol
kern=`uname -r`
case "$kern" in
2.0*|2.1*|2.2*|2.3*|2.4*|2.5*)
return 0; 
;;
esac
[ -d /sys/bus/usb/devices ] || return 0
for d in /sys/bus/usb/devices/*:*; do
[ -e "$d" ] || continue
class=$(cat "$d/bInterfaceClass") # 03 = Human Interface Device
subclass=$(cat "$d/bInterfaceSubClass") # 01 = Boot Interface Subclass
protocol=$(cat "$d/bInterfaceProtocol") # 01 = Keyboard
case "$class:$subclass:$protocol" in
03:01:01)
return 0
;;
esac
done
[ -f /proc/bus/input/devices ] || return 0
kbdpattern="AT Set \|AT Translated Set\|AT Raw Set"
kbdpattern="$kbdpattern\|Atari Keyboard"
kbdpattern="$kbdpattern\|Amiga Keyboard"
kbdpattern="$kbdpattern\|HIL keyboard"
kbdpattern="$kbdpattern\|ADB keyboard"
kbdpattern="$kbdpattern\|Sun Type"
kbdpattern="$kbdpattern\|Apple MTP keyboard"
kbdpattern="$kbdpattern\|Apple SPI Keyboard"
kbdpattern="$kbdpattern\|bluetooth.*keyboard"
if grep -i "$kbdpattern" /proc/bus/input/devices >/dev/null; then
return 0
fi
return 1
}
ask_debconf () {
local template priority prefix default_code default_description choices add
template="$1"
priority="$2"
prefix="$(echo "$3"|regex_pattern_escape)"
default_code="$(echo "$4"|regex_pattern_escape)"
add="$(echo "$5"|regex_escape)"
add="
$add"
choices1=`echo "$kbdnames" | grep "^$prefix\*" | 
sed -e "s/^$prefix\*[^\*]*\*//" -e 's/,/\\\\,/g' | sort`
choices2=`echo "$add" | grep "^$prefix\*" | 
sed -e "s/^$prefix\*[^\*]*\*//" -e 's/,/\\\\,/g'`
choices=`echo "$choices1
$choices2" | sed -e 's/$/,/'`
choices=`echo $choices | sed 's/, *$//' | regex_unescape`
choices=`echo $choices | sed 's/,$//'`
if echo "$choices" | grep '[^\\\\],' >/dev/null; then
db_subst $template CHOICES "$choices"
default_description=`echo "$kbdnames$add" |  
grep "^$prefix\*${default_code}\*" |
sed -e "s/^$prefix\*${default_code}\*//" |
regex_unescape`
if [ -z "$default_description" ]; then
default_description=`echo "$kbdnames$add" |  
grep "^$prefix\*\*" |
sed -e "s/^$prefix\*\*//" |
regex_unescape `
fi
if [ -n "$default_description" ]; then
db_default $template "$default_description"
elif [ -n "$default_code" ]; then
priority=critical
fi
db_input $priority $template || true
db_go || return 255
db_get $template
else
[ $STATE -gt $old_state ] || return 255
RET=$(echo "$choices"|sed 's/ *$//')
fi
RET=`echo "$RET" | regex_pattern_escape`
RET=`echo "$kbdnames$add" | grep "^$prefix\*[^\*]*\*" |
sed 's/  */ /g' |
grep "\*$RET\$" |
sed -e "s/^$prefix\*\([^\*]*\)\*.*/\1/" |
regex_unescape`
return 0
}
guess_arch () {
local arch subarch line
if which archdetect 2>/dev/null >/dev/null; then
archdetect
return 0
fi
arch=`dpkg --print-architecture`
if [ "$arch" = 'powerpc' -o "$arch" = 'm68k' ]; then
if [ "$arch" = powerpc ]; then
line=`sed -n 's/^platform.*: *//p' /proc/cpuinfo`
if [ "$line" = PS3 ] || [ "$line" = Cell ]; then
subarch=`echo $line|tr A-Z a-z`
else
line=`sed -n 's/^machine.*: *//p' /proc/cpuinfo`
if [ "$line" = '' ]; then
echo unknown
return 0
fi
subarch=`echo $line|tr A-Z a-z`
fi
elif [ "$arch" = m68k ]; then
line=`sed -n 's/^Model.*: *//p' /proc/hardware`
if [ "$line" = '' ]; then
echo unknown
return 0
fi
subarch=`echo $line|tr A-Z a-z`
fi
case "$subarch" in
*amiga*)
subarch=amiga
;;
*chrp*)
subarch=chrp
;;
*prep*)
subarch=prep
;;
*macintosh*|*powermac*|*powerbook*|*power*|*imac*|*powermac1*)
subarch=mac
;;
*atari*)
subarch=atari
;;
*motorola*)
subarch=mvme
;;
*bvme*)
subarch=bvme
;;
*)
subarch=`echo $subarch|sed  's/^\s*//'`
;;
esac
arch="$arch/$subarch"
fi
echo $arch
return 0
}
if which locale 2>/dev/null >/dev/null; then
eval `locale`
fi
if [ "$LC_CTYPE"  -a "$LC_CTYPE" != C ]; then
locale=$LC_CTYPE
elif db_get debian-installer/locale && [ "$RET" ]; then
locale="$RET"
else
locale=C
fi
if [ "$LC_MESSAGES"  -a "$LC_MESSAGES" != C ]; then
messages=$LC_MESSAGES
elif db_get debian-installer/locale && [ "$RET" ]; then
messages="$RET"
else
messages=C
fi
messages_lang=$(echo $messages | sed 's/_.*//')
messages_country=$(echo $messages | sed 's/.*_//;s/\..*//;s/@.*//')
messages_modif=
echo $messages | grep -v -q @ || messages_modif=$(echo $messages | sed 's/.*@//')
lang_kbdnames () {
all_kbdnames | \
regex_escape | \
grep "^$1[*]" | \
sed "s/^$1[*]//"
}
kbdnames=$(lang_kbdnames ${messages_lang}_${messages_country}__${messages_modif})
[ -n "$kbdnames" ] || kbdnames=$(lang_kbdnames ${messages_lang}_${messages_country}__${messages_modif})
[ -n "$kbdnames" ] || kbdnames=$(lang_kbdnames ${messages_lang}_${messages_country})
[ -n "$kbdnames" ] || kbdnames=$(lang_kbdnames ${messages_lang})
[ -n "$kbdnames" ] || kbdnames=$(lang_kbdnames C)
if [ "$is_not_debian_installer" ]; then
if \
! which iconv >/dev/null \
|| ! kbdnames="$(echo "$kbdnames" |
iconv -f UTF-8 -t $(locale charmap)//TRANSLIT)"
then
kbdnames=$(lang_kbdnames C)
fi
fi
arch=`guess_arch`
case "$arch" in
alpha*)
XKBMODEL=pc105
model_priority=medium
;;
amd64*)
XKBMODEL=pc105
model_priority=medium
;;
arm*)
XKBMODEL=pc105
model_priority=medium
;;
i386*)
XKBMODEL=pc105
model_priority=medium
;;
hppa*)
XKBMODEL=pc105
model_priority=medium
;;
ia64*)
XKBMODEL=pc105
model_priority=medium
;;
m68k/amiga)
XKBMODEL=amiga
model_priority=medium
;;
m68k/atari)
XKBMODEL=ataritt
model_priority=medium
;;
m68k/mac)
XKBMODEL=macintosh
model_priority=medium
;;
m68k/sun*)
XKBMODEL=pc105 # UNKNOWN: sun4, sun5 or pc105
model_priority=critical
;;
m68k/*vme*)
XKBMODEL=pc105
model_priority=medium
;;
mips*)
XKBMODEL=pc105
model_priority=medium
;;
powerpc/amiga)
XKBMODEL=amiga
model_priority=medium
;;
powerpc/apus)
XKBMODEL=amiga
model_priority=medium
;;
powerpc/chrp*)
XKBMODEL=pc105 # UNKNOWN: pc105, macintosh or maybe amiga
model_priority=critical
;;
powerpc/mac)
XKBMODEL=pc105
model_priority=medium
;;
powerpc/pasemi)
XKBMODEL=pc105
model_priority=medium
;;
powerpc/powermac*)
XKBMODEL=pc105
model_priority=medium
;;
powerpc/prep)
XKBMODEL=pc105
model_priority=medium
;;
powerpc/ps3|powerpc/cell)
XKBMODEL=pc105
model_priority=medium
;;
sparc*)
XKBMODEL=pc105 # sun4 or sun5 on older kernels
model_priority=medium
;;
s390*)
XKBMODEL=pc105
model_priority=medium
;;
*)
XKBMODEL=pc105 # UNKNOWN
model_priority=critical
;;
esac    
layout_priority=critical
case "$locale" in
*_AL*)
XKBLAYOUT=al  # Albania
;;
*_AZ*)
XKBLAYOUT=az  # Azerbaijan
;;
*_BD*)
XKBLAYOUT=us,bd  # Bangladesh
;;
*_BE*)
XKBLAYOUT=be  # Belgium
;;
*_BG*)
XKBLAYOUT=us,bg  # Bulgaria
layout_priority=critical
;;
*_BR*)
XKBLAYOUT=br  # Brazil
;;
*_BT*)
XKBLAYOUT=us,bt  # Bhutan
;;
*_BY*)
XKBLAYOUT=us,by  # Belarus
;;
fr_CA*)
XKBLAYOUT=ca  # Canada
;;
*_CA*)
XKBLAYOUT=us  # U.S. English
;;
de_CH*)
XKBLAYOUT=ch  # Switzerland
;;
fr_CH*)
XKBLAYOUT=ch  # Switzerland
XKBVARIANT=fr # French
;;
*_CH*)
XKBLAYOUT=ch  # Switzerland
layout_priority=critical
;;
*_CZ*)
XKBLAYOUT=cz  # Czechia
layout_priority=critical
;;
*_DK*)
XKBLAYOUT=dk  # Denmark
;;
*_EE*)
XKBLAYOUT=ee  # Estonia
;;
ast_ES*)
XKBLAYOUT=es  # Spain
XKBVARIANT=ast # Asturian
;;
bo_*)
XKBLAYOUT=us,cn  # China
XKBVARIANT=,tib # Tibetan
;;
ca_ES*)
XKBLAYOUT=es  # Spain
XKBVARIANT=cat # Catalan
;;
*_ES*)
XKBLAYOUT=es  # Spain
;;
*_ET*)
XKBLAYOUT=us,et  # Ethiopia
;;
se_FI*)
XKBLAYOUT=fi  # Finland
XKBVARIANT=smi # Northern Saami
;;
*_FI*)
XKBLAYOUT=fi  # Finland
;;
*_FR*)
XKBLAYOUT=fr  # French
XKBVARIANT=latin9
;;
*_GB*)
XKBLAYOUT=gb  # United Kingdom
;;
*_GG*)
XKBLAYOUT=gb  # United Kingdom
;;
*_HU*)
XKBLAYOUT=hu  # Hungary
;;
*_IE*)
XKBLAYOUT=ie  # Ireland
;;
*_IL*)
XKBLAYOUT=us,il  # Israel
layout_priority=critical
;;
*_IM*)
XKBLAYOUT=gb  # United Kingdom
;;
*_IR*)
XKBLAYOUT=us,ir  # Iran
;;
*_IS*)
XKBLAYOUT=is  # Iceland
;;
*_IT*)
XKBLAYOUT=it  # Italy
;;
*_JE*)
XKBLAYOUT=gb  # United Kingdom
;;
*_JP*)
XKBLAYOUT=jp  # Japan
;;
*_LT*)
XKBLAYOUT=lt  # Lithuania
layout_priority=critical
;;
*_LV*)
XKBLAYOUT=lv  # Latvia
;;
*_KG*)
XKBLAYOUT=us,kg  # Kyrgyzstan
;;
*_KH*)
XKBLAYOUT=us,kh  # Cambodia
;;
*_KR*)
XKBLAYOUT=kr      # South Korea
XKBVARIANT=kr104  # pc104 compatible mode, safe choice
;;
*_KZ*)
XKBLAYOUT=us,kz  # Kazakhstan
;;
*_LK*)
XKBLAYOUT=us,lk  # Sri Lanka
;;
*_MA*)
XKBLAYOUT=us,ma  # Morocco
;;
*_MK*)
XKBLAYOUT=us,mk  # Macedonia
;;
*_NL*)
XKBLAYOUT=us  # Netherlands
;;
*_MM*)
XKBLAYOUT=us,mm  # Myanmar
;;
*_MN*)
XKBLAYOUT=us,mn  # Mongolia
;;
*_MT*)
XKBLAYOUT=mt  # Malta
layout_priority=critical
;;
se_NO*)
XKBLAYOUT=no  # Norway
XKBVARIANT=smi # Northern Saami
;;
*_NO*)
XKBLAYOUT=no  # Norway (se_NO is not in this case)
;;
*_NP*)
XKBLAYOUT=us,np  # Nepal
;;
*_PH*)
XKBLAYOUT=ph  # Philipines
;;
*_PL*)
XKBLAYOUT=pl  # Poland
;;
*_PT*)
XKBLAYOUT=pt  # Portugal
;;
*_RO*)
XKBLAYOUT=ro  # Romania
;;
*_RU*)
XKBLAYOUT=us,ru  # Russia
layout_priority=critical
;;
se_SE*)
XKBLAYOUT=se  # Sweden
XKBVARIANT=smi # Northern Saami
;;
*_SK*)
XKBLAYOUT=sk  # Slovakia
;;
*_SI*)
XKBLAYOUT=si  # Slovenia
;;
tg_*)
XKBLAYOUT=us,tj  # Tajik
;;
*_TJ*)
XKBLAYOUT=us,tj  # Tajikistan
;;
*_TH*)
XKBLAYOUT=us,th  # Thailand
layout_priority=critical
;;
*_TR*)
XKBLAYOUT=tr  # Turkish
layout_priority=critical
;;
zh_TW*)
XKBLAYOUT=tw  # Taiwanese
XKBVARIANT=indigenous
;;
*_UA*)
XKBLAYOUT=us,ua  # Ukraine
;;
en_US*)
XKBLAYOUT=us  # U.S. English
;;
*_VN*)
XKBLAYOUT=vn  # Vietnam
;;
*_ZA*)
XKBLAYOUT=za  # South Africa
;;
*_AR*|*_BO*|*_CL*|*_CO*|*_CR*|*_DO*|*_EC*|*_GT*|*_HN*|*_MX*|*_NI*|*_PA*|*_PE*|es_PR*|*_PY*|*_SV*|es_US*|*_UY*|*_VE*)
XKBLAYOUT=latam # Latin American
;;
ar_*)
XKBLAYOUT=us,ara # Arabic
;;
bn_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,ben # Bengali
;;
bs_*)
XKBLAYOUT=ba  # Bosnia and Herzegovina
;;
de_LI*)
XKBLAYOUT=ch  # Liechtenstein
;;
de_*)
XKBLAYOUT=de  # Germany
;;
el_*)
XKBLAYOUT=us,gr  # Greece
;;
eo|eo.*|eo_*|eo\@*)
XKBLAYOUT=epo  # Esperanto
layout_priority=critical
;;
fr_*)
XKBLAYOUT=fr  # France
XKBVARIANT=latin9
layout_priority=critical
;;
gu_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,guj # Gujarati
;;
hi_*)
XKBLAYOUT=us,in  # India
;;
hr_*)
XKBLAYOUT=hr  # Croatia
;;
hy_*)
XKBLAYOUT=us,am  # Armenia
;;
ka_*)
XKBLAYOUT=us,ge  # Georgia
layout_priority=critical
;;
kab_*)
XKBLAYOUT=dz  # Algeria (Latin)
;;
kn_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,kan # Kannada
;;
ku_*)
XKBLAYOUT=tr  # Turkish
XKBVARIANT=ku # Kurdish
layout_priority=critical
;;
lo_*)
XKBLAYOUT=us,la  # Laos
;;
mr_*)
XKBLAYOUT=us,in  # India
;;
ml_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,mal # Malayalam
;;
my_*)
XKBLAYOUT=us,mm  # Burmese
;;
ne_*)
XKBLAYOUT=us,np  # Nepali
;;
os_*)
XKBLAYOUT=ru  # Russia
XKBVARIANT=os  # Ossetian
;;
pa_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,guru # Gurmukhi
;;
si_*)
XKBLAYOUT=us,si  # Sri Lanka
XKBVARIANT=,sin_phonetic # Sinhala
;;
sr_*)
XKBLAYOUT=rs,rs  # Serbia and Montenegro
XKBVARIANT=latin,
layout_priority=critical
;;
sv_*)
XKBLAYOUT=se  # Sweden
;;
ta_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,tam # Tamil
;;
te_*)
XKBLAYOUT=us,in  # India
XKBVARIANT=,tel # Telugu
;;
tg_*)
XKBLAYOUT=us,tj  # Tajikistan
;;
the_*)
XKBLAYOUT=us,np  # Nepali keymap for Tharu
;;
tl_*)
XKBLAYOUT=ph  # Philipines
;;
ug_*)
XKBLAYOUT=us,cn  # China
XKBVARIANT=,ug # Uyghur
;;
zh_*)
XKBLAYOUT=cn  # Chinese
;;
*)
XKBLAYOUT=us
;;
esac
if db_get keyboard-configuration/xkb-keymap && [ "$RET" ]; then
keymap="$RET"
layout="${keymap%\(*}"
variant="${keymap#$layout}"
variant="${variant%\)}"
variant="${variant#\(}"
XKBLAYOUT="$layout"
XKBVARIANT="$variant"
fi
if db_get keyboard-configuration/modelcode && [ "$RET" ]; then
XKBMODEL="$RET"
fi
if db_get keyboard-configuration/layoutcode && [ "$RET" ]; then
XKBLAYOUT="$RET"
fi
if db_get keyboard-configuration/variantcode && [ "$RET" ]; then
XKBVARIANT="$RET"
fi
if db_get keyboard-configuration/optionscode && [ "$RET" ]; then
XKBOPTIONS="$RET"
fi
if db_get debian-installer/keymap && [ "$RET" ]; then
di_keymap="${RET##mac-usb-}"
di_keymap="${di_keymap%%-latin1}"
old_xkbvariant="$XKBVARIANT"
XKBVARIANT=''
old_layout_priority=$layout_priority
layout_priority=medium
case "$di_keymap" in
be2) XKBLAYOUT="be";;
bg) XKBLAYOUT="us,bg";;
br) XKBLAYOUT="us"; XKBVARIANT="intl";;
br-abnt2) XKBLAYOUT="br"; XKBVARIANT="abnt2";;
by) XKBLAYOUT="us,by";;
cf) XKBLAYOUT="ca"; XKBVARIANT="fr";;
croat) XKBLAYOUT="hr";;
cz-lat2) XKBLAYOUT="cz";;
de-latin1-nodeadkeys) XKBLAYOUT="de"; XKBVARIANT="nodeadkeys";;
de) XKBLAYOUT="de";;
dvorak) XKBLAYOUT="us"; XKBVARIANT="dvorak";;
dk) XKBLAYOUT="dk";;
es) XKBLAYOUT="es";;
et) XKBLAYOUT="ee";;
'fi') XKBLAYOUT="fi";;
fr-latin9) XKBLAYOUT="fr"; XKBVARIANT="latin9";;
fr_CH) XKBLAYOUT="ch"; XKBVARIANT="fr";;
fr) XKBLAYOUT="fr";;
hebrew) XKBLAYOUT="us,il";;
hu) XKBLAYOUT="hu";;
gb) XKBLAYOUT="gb";;
is) XKBLAYOUT="is";;
it) XKBLAYOUT="it";;
jp106) XKBLAYOUT="jp"; XKBVARIANT="106";;
kr|kr106) XKBLAYOUT="kr"; XKBVARIANT='';;
kr104) XKBLAYOUT="kr"; XKBVARIANT="kr104";;
la) XKBLAYOUT="latam";;
lt) XKBLAYOUT="lt";; 
lv-latin4) XKBLAYOUT="lv";;
mac-us-std) XKBLAYOUT="us";;
mac-de2-ext) XKBLAYOUT="de"; XKBVARIANT="nodeadkeys";;
mac-fr2-ext) XKBLAYOUT="fr";;
mac-fr3) XKBLAYOUT="fr";;
mac-es) XKBLAYOUT="es";;
ky) XKBLAYOUT="us,kg";;
mk) XKBLAYOUT="us,mk";;
nl) XKBLAYOUT="nl";;
no) XKBLAYOUT="no";;
pl) XKBLAYOUT="pl";;
pt) XKBLAYOUT="pt";;
ro) XKBLAYOUT="ro";;
ru) XKBLAYOUT="us,ru";;
se) XKBLAYOUT="se";;
sg) XKBLAYOUT="ch"; XKBVARIANT="de";;
sk-qwerty) XKBLAYOUT="sk"; XKBVARIANT="qwerty";;
slovene) XKBLAYOUT="si";;
sr-cy) XKBLAYOUT="rs,rs"; XKBVARIANT="latin," ;;
trf|trfu) XKBLAYOUT="tr"; XKBVARIANT="f";;
trq|trqu) XKBLAYOUT="tr";;
ua) XKBLAYOUT="us,ua";;
uk) XKBLAYOUT="gb";;
us) XKBLAYOUT="us";;
*) 
XKBVARIANT="$old_xkbvariant"
layout_priority=$old_layout_priority
;;
esac
fi
if \
[ -f /etc/X11/xorg.conf -a ! -e $CONFIGFILE ] \
&& which awk 2>/dev/null >/dev/null
then
awk_expr='
{
sub("#.*","")
line = $0;
$0 = tolower($0);
xkb = "";
}
/^[ \t]*section[ \t]+"inputdevice"/,/^[ \t]*endsection/ {
if ($1 == "option") {
if ($2 == "\"xkbmodel\"") {
xkb = "XKBMODEL";
} else if ($2 == "\"xkblayout\"") {
xkb = "XKBLAYOUT";
print "layout_priority=medium";
} else if ($2 == "\"xkbvariant\"") {
xkb = "XKBVARIANT";
} else if ($2 == "\"xkboptions\"") {
xkb = "XKBOPTIONS"; 
}
$0 = line;
$1 = "";
$2 = "";
}
}
xkb != "" && /^[ \t]*\"[^"]+\"[ \t]*$/ {
sub("^[ \t]*\"", "");
sub("\".*", "");
gsub("[ \t]", "");
if ($1 !~ /[()]/) {
print xkb "=\"" $0 "\"";
} else {
if (xkb == "XKBLAYOUT" && $1 ~ /^[^()]+\([^()]+\)$/) {
l=$1;                      # us(intl),cz(qwerty)
gsub(/\([^()]*\)/,"",l);   # us,cz
v=$1;                      # us(intl),cz(qwerty)     us,bg
gsub(/\)/,"",v);           # us(intl,cz(qwerty       us,bg
gsub(/^[^(,]*,/,",",v);    # us(intl,cz(qwerty       ,bg
gsub(/^[^(,]*$/,"",v);     # us(intl,cz(qwerty       ,bg
gsub(/^[^(,]*\(/,"",v);    # intl,cz(qwerty          ,bg
gsub(/,[^(,]*,/,",,",v);   # intl,cz(qwerty          ,bg
gsub(/,[^(,]*$/,",",v);    # intl,cz(qwerty          ,
gsub(/,[^(,]*\(/,",",v);   # intl,qwerty             ,
print "XKBLAYOUT=" l;
print "XKBVARIANT=" v;
}
}
}
'
eval $(awk "$awk_expr" < /etc/X11/xorg.conf)
fi
if [ -e $OLDCONFIGFILE ]; then
. $OLDCONFIGFILE || true
fi
if [ -e $CONFIGFILE ]; then
. $CONFIGFILE || true
fi
XKBMODEL=$(echo $XKBMODEL | sed 's/ *//g')
XKBLAYOUT=$(echo $XKBLAYOUT | sed 's/ *//g')
XKBVARIANT=$(echo $XKBVARIANT | sed 's/ *//g')
if [ -z "$XKBMODEL" ]; then
model_priority=critical
XKBMODEL=pc105
db_fset keyboard-configuration/model seen false
fi
if [ -z "$XKBLAYOUT" ]; then
layout_priority=critical
XKBLAYOUT=us
db_fset keyboard-configuration/layout seen false
db_fset keyboard-configuration/variant seen false
fi
if ! keyboard_present; then
db_set keyboard-configuration/modelcode "$XKBMODEL"
db_set keyboard-configuration/layoutcode "$XKBLAYOUT"
db_set keyboard-configuration/variantcode "$XKBVARIANT"
if [ -z "$XKBOPTIONS" -a ! -f $CONFIGFILE ]; then
case "$XKBLAYOUT" in
*,*) XKBOPTIONS="grp:alt_shift_toggle,grp_led:scroll";;
us) XKBOPTIONS="";;
*) XKBOPTIONS="lv3:ralt_switch";;
esac
fi
db_set keyboard-configuration/optionscode "$XKBOPTIONS"
exit 0
fi
debconf_model="$XKBMODEL"
if [ "$XKBLAYOUT" ]; then
case "$XKBLAYOUT" in
lt,us)
debconf_layout="${XKBLAYOUT%,*}"
debconf_variant="${XKBVARIANT%,*}"
unsupported_layout=no
;;
rs,rs|us,rs|jp,jp|us,jp)
debconf_layout="${XKBLAYOUT#*,}"
debconf_variant="${XKBVARIANT#*,}"
unsupported_layout=no
;;
us,am|us,af|us,ara|us,ben|us,bd|us,bg|us,bt|us,by|us,cn|us,et|us,ge|us,gh|us,gr|us,guj|us,guru|us,il|us,in|us,ir|us,iku|us,iq|us,ir|us,kan|us,kh|us,kz|us,la|us,lao|us,lk|us,lt|us,kg|us,ma|us,mal|us,mk|us,mm|us,mn|us,mv|us,np|us,ori|us,pk|us,ru|us,scc|us,sy|us,syr|us,tel|us,th|us,tj|us,tam|us,tib|us,ua|us,ug|us,uz)
if [ "${XKBVARIANT%,*}" = '' ]; then
debconf_layout="${XKBLAYOUT#*,}"
debconf_variant="${XKBVARIANT#*,}"
unsupported_layout=no
else
unsupported_layout=yes
fi
;;	    
*,*)
unsupported_layout=yes
;;
*)
debconf_layout="$XKBLAYOUT"
debconf_variant="$XKBVARIANT"
unsupported_layout=no
;;
esac
fi
if \
! echo "$kbdnames" \
| grep "variant[*]$debconf_layout[*]$debconf_variant[*]" >/dev/null
then
unsupported_layout=yes
debconf_variant=''
if \
! echo "$kbdnames" \
| grep "layout[*]$debconf_layout[*]" >/dev/null
then
debconf_layout=us
fi
fi
debconf_toggle='Left Alt+Left Shift'
debconf_switch='No temporary switch'
debconf_altgr='The default for the keyboard layout'
debconf_compose='No compose key'
debconf_ctrl_alt_bksp=false
if [ "$XKBOPTIONS" ]; then
debconf_toggle='No toggling'
debconf_switch='No temporary switch'
debconf_altgr='The default for the keyboard layout'
debconf_compose='No compose key'
for option in `echo $XKBOPTIONS | sed 's/,/ /g'`; do
case "$option" in
compose:caps)
debconf_compose='Caps Lock';;
compose:lwin)
debconf_compose='Left Logo key';;
compose:menu)
debconf_compose='Menu key';;
compose:ralt)
debconf_compose='Right Alt (AltGr)';;
compose:rctrl)
debconf_compose='Right Control';;
compose:rwin)
debconf_compose='Right Logo key';;
grp:alt_caps_toggle)
debconf_toggle='Alt+Caps Lock';;
grp:alt_shift_toggle)
debconf_toggle='Alt+Shift';;
grp:lalt_lshift_toggle)
debconf_toggle='Left Alt+Left Shift';;
grp:caps_toggle)
debconf_toggle='Caps Lock';;
grp:ctrl_alt_toggle)
debconf_toggle='Control+Alt';;
grp:ctrl_shift_toggle)
debconf_toggle='Control+Shift';;
grp:lalt_toggle)
debconf_toggle='Left Alt';;
grp:lctrl_lshift_toggle)
debconf_toggle='Left Control+Left Shift';;
grp:lctrl_toggle)
debconf_toggle='Left Control';;
grp:lshift_toggle)
debconf_toggle='Left Shift';;
grp:lswitch)
debconf_switch='Left Alt';;
grp:lwin_switch)
debconf_switch='Left Logo key';;
grp:lwin_toggle)
debconf_toggle='Left Logo key';;
grp:menu_toggle)
debconf_toggle='Menu key';;
grp:rctrl_toggle)
debconf_toggle='Right Control';;
grp:rshift_toggle)
debconf_toggle='Right Shift';;
grp:rwin_switch)
debconf_switch='Right Logo key';;
grp:rwin_toggle)
debconf_toggle='Right Logo key';;
grp:sclk_toggle)
debconf_toggle='Scroll Lock key';;
grp:switch)
debconf_switch='Right Alt (AltGr)';;
grp:toggle)
debconf_toggle='Right Alt (AltGr)';;
grp:win_switch)
debconf_switch='Both Logo keys';;
lv3:ralt_alt)
debconf_altgr='No AltGr key';;
lv3:alt_switch)
debconf_altgr='Both Alt keys';;
lv3:enter_switch)
debconf_altgr='Keypad Enter key';;
lv3:lalt_switch)
debconf_altgr='Left Alt';;
lv3:lwin_switch)
debconf_altgr='Left Logo key';;
lv3:menu_switch)
debconf_altgr='Menu key';;
lv3:ralt_switch)
debconf_altgr='Right Alt (AltGr)';;
lv3:rwin_switch)
debconf_altgr='Right Logo key';;
lv3:switch)
debconf_altgr='Right Control';;
lv3:win_switch)
debconf_altgr='Both Logo keys';;
terminate:ctrl_alt_bksp)
debconf_ctrl_alt_bksp=true;;
grp_led:scroll)
;;
*)
unsupported_options=yes
;;
esac
done
fi
db_default keyboard-configuration/toggle "$debconf_toggle"
db_default keyboard-configuration/switch "$debconf_switch"
db_default keyboard-configuration/altgr "$debconf_altgr"
db_default keyboard-configuration/compose "$debconf_compose"
db_default keyboard-configuration/ctrl_alt_bksp "$debconf_ctrl_alt_bksp"
if [ -n "$debconf_variant" ]; then
debconf_keymap="$debconf_layout($debconf_variant)"
else
debconf_keymap="$debconf_layout"
fi
db_default keyboard-configuration/xkb-keymap "$debconf_keymap"
STATE=1
old_state=0
while :; do
starting_state=$STATE
case "$STATE" in
1)
if [ "$is_debian_installer" ]; then
db_set keyboard-configuration/modelcode "$debconf_model"
db_fset keyboard-configuration/model seen true
STATE=$(( $STATE + $STATE - $old_state ))
else
if \
ask_debconf keyboard-configuration/model $model_priority \
model "$debconf_model"
then
debconf_model="$RET"
db_set keyboard-configuration/modelcode "$RET"
STATE=$(($STATE + 1))
else
STATE=$(($STATE - 1))
fi
fi
;;
2)
if \
[ "$unsupported_layout" = yes -a "$is_not_debian_installer" ]
then
if [ -f $CONFIGFILE ]; then
template=keyboard-configuration/unsupported_config_layout
else
template=keyboard-configuration/unsupported_layout
case "$XKBVARIANT" in
,|,,|,,,|'')
db_subst $template XKBLAYOUTVARIANT "$XKBLAYOUT"
;;
*)
db_subst $template XKBLAYOUTVARIANT \
"$XKBLAYOUT/$XKBVARIANT"
;;
esac
fi
db_subst $template XKBLAYOUT "$XKBLAYOUT"
db_subst $template XKBVARIANT "$XKBVARIANT"
db_input medium $template || true
if db_go; then
STATE=$(($STATE + 1))
else
db_reset $template || true
db_fset $template seen false
STATE=$(($STATE - 1))
fi
db_get $template
if [ "$RET" != true ]; then
unsupported_layout=no
fi
else
db_reset keyboard-configuration/unsupported_config_layout || true
db_fset keyboard-configuration/unsupported_config_layout seen false
db_reset keyboard-configuration/unsupported_layout || true
db_fset keyboard-configuration/unsupported_layout seen false
STATE=$(( $STATE + $STATE - $old_state ))
fi
;;
3)
if [ "$is_debian_installer" ]; then
db_input critical keyboard-configuration/xkb-keymap || true
if db_go; then
db_fset keyboard-configuration/layout seen true
db_fset keyboard-configuration/variant seen true
db_get keyboard-configuration/xkb-keymap
keymap="$RET"
debconf_layout="${keymap%\(*}"
debconf_variant="${keymap#$debconf_layout}"
debconf_variant="${debconf_variant%\)}"
debconf_variant="${debconf_variant#\(}"
STATE=$(($STATE + 1))
else
STATE=$(($STATE - 1))
fi
elif [ "$unsupported_layout" = yes ]; then
STATE=$(( $STATE + $STATE - $old_state ))
elif [ "$debconf_variant" != other ]; then
STATE=$(( $STATE + $STATE - $old_state ))
elif \
ask_debconf keyboard-configuration/layout "$layout_priority" \
layout "$debconf_layout"
then
debconf_layout="$RET"
STATE=$(($STATE + 1)) 
else
STATE=$(($STATE + 1))
fi
;;
4)
db_metaget keyboard-configuration/other description
othertext="$RET"
if [ "$unsupported_layout" = yes ]; then
STATE=$(( $STATE + $STATE - $old_state ))
elif [ "$is_debian_installer" ]; then
STATE=$(( $STATE + $STATE - $old_state ))
else
if \
! ask_debconf keyboard-configuration/variant \
"$layout_priority" \
"variant*${debconf_layout}" \
"$debconf_variant" \
"variant*${debconf_layout}*other*$othertext"
then
starting_state=$(($STATE - 1))
STATE=$(($STATE - 2))
elif [ "$RET" = other ]; then
debconf_variant="$RET"
STATE=$(($STATE - 1))
else
debconf_variant="$RET"
STATE=$(($STATE + 1))
fi
fi
if [ "$unsupported_layout" != yes ]; then
case "$debconf_layout" in
rs)
case "$debconf_variant" in
latin*)
XKBLAYOUT=$debconf_layout
;;
*)
XKBLAYOUT=rs,rs
;;
esac
;;
jp)
case "$debconf_variant" in
106|common|OADG109A|'')
XKBLAYOUT=$debconf_layout
;;
*)
XKBLAYOUT=jp,jp
;;
esac
;;
lt)
XKBLAYOUT=lt,us
;;
af|am|ara|ben|bd|bg|bt|by|et|ge|gh|gr|guj|guru|il|'in'|iq|ir|iku|kan|kh|kz|la|lao|lk|kg|ma|mk|mm|mn|mv|mal|np|ori|pk|ru|scc|sy|syr|tel|th|tj|tam|tib|ua|ug|uz)
XKBLAYOUT=us,$debconf_layout
;;
*)
XKBLAYOUT=$debconf_layout
;;
esac
case "$XKBLAYOUT" in
rs,rs)
case "$debconf_variant" in
yz)
XKBVARIANT="latinyz,$debconf_variant" ;;
alternatequotes)
XKBVARIANT="latinalternatequotes,$debconf_variant" ;;
*)
XKBVARIANT="latin,$debconf_variant" ;;
esac
;;
lt,us)
case "$debconf_variant" in
us)
XKBVARIANT="us," ;;
*)
XKBVARIANT="$debconf_variant,altgr-intl" ;;
esac
;;
*,*)
XKBVARIANT=",$debconf_variant"
;;
*)
XKBVARIANT="$debconf_variant"
;;
esac
fi
db_set keyboard-configuration/layoutcode "$XKBLAYOUT"
db_set keyboard-configuration/variantcode "$XKBVARIANT"
;;
5)
if \
[ "$unsupported_options" = yes -a "$is_not_debian_installer" ]
then
if [ -f $CONFIGFILE ]; then
template=keyboard-configuration/unsupported_config_options
else
template=keyboard-configuration/unsupported_options
fi
db_subst $template XKBOPTIONS "$XKBOPTIONS"
db_input medium $template || true
if db_go; then
STATE=$(($STATE + 1))
else
db_reset $template || true
db_fset $template seen false
STATE=$(($STATE - 1))
fi
db_get $template
if [ "$RET" != true ]; then
unsupported_options=no
fi
else
db_reset keyboard-configuration/unsupported_config_options || true
db_fset keyboard-configuration/unsupported_config_options seen false
db_reset keyboard-configuration/unsupported_options || true
db_fset keyboard-configuration/unsupported_options seen false
STATE=$(( $STATE + $STATE - $old_state ))
fi
;;
6)
if [ "$unsupported_options" = yes ]; then
db_set keyboard-configuration/optionscode "$XKBOPTIONS"
STATE=$(( $STATE + $STATE - $old_state ))
else
caps_allocated=no
lalt_allocated=no
lctrl_allocated=no
lshift_allocated=no
lwin_allocated=no
menu_allocated=no
ralt_allocated=no
rctrl_allocated=no
rshift_allocated=no
rwin_allocated=no
case "$XKBLAYOUT" in
*,*)
;;
*)
db_set keyboard-configuration/toggle 'No toggling'
db_set keyboard-configuration/switch 'No temporary switch'
;;
esac
db_beginblock
case "$XKBLAYOUT" in
*,*)
db_input high keyboard-configuration/toggle || true
if [ "$is_not_debian_installer" ]; then
db_input medium keyboard-configuration/switch || true
fi
;;
*)
;;
esac
if [ "$is_not_debian_installer" ]; then
db_input medium keyboard-configuration/altgr || true
db_input medium keyboard-configuration/compose || true
fi
if [ -f /usr/bin/X ]; then
db_input medium keyboard-configuration/ctrl_alt_bksp || true
fi
db_endblock
if db_go; then
STATE=$(($STATE + 1))
else
STATE=$(($STATE - 1))
fi
db_get keyboard-configuration/toggle
case "$RET" in
Caps\ Lock)
caps_allocated=yes
toggle=caps_toggle;;
Right\ Alt*)
ralt_allocated=yes
toggle=toggle;;
Right\ Control)
rctrl_allocated=yes
toggle=rctrl_toggle;;
Right\ Shift)
rshift_allocated=yes
toggle=rshift_toggle;;
Right\ Logo?key)
rwin_allocated=yes
toggle=rwin_toggle;;
Menu?key)
menu_allocated=yes
toggle=menu_toggle;;
Alt+Shift)
lalt_allocated=yes
ralt_allocated=yes
toggle=alt_shift_toggle;;
Left\ Alt+Left\ Shift)
lalt_allocated=yes
toggle=lalt_lshift_toggle;;
Control+Shift)
toggle=ctrl_shift_toggle;;
Left\ Control+Left\ Shift)
toggle=lctrl_lshift_toggle;;
Scroll\ Lock\ key)
toggle=sclk_toggle;;
Alt+Caps\ Lock)
toggle=alt_caps_toggle;;
Control+Alt)
toggle=ctrl_alt_toggle;;
Left\ Alt)
lalt_allocated=yes
toggle=lalt_toggle;;
Left\ Control)
lctrl_allocated=yes
toggle=lctrl_toggle;;
Left\ Shift)
lshift_allocated=yes
toggle=lshift_toggle;;
Left\ Logo?key)
lwin_allocated=yes
toggle=lwin_toggle;;
No\ toggling)
toggle='';;
*)
echo Unknown toggle key option
exit 1
;;
esac
if [ "$toggle" ]; then
toggle=grp:$toggle
fi
db_get keyboard-configuration/switch
switch=''
case "$RET" in
Right\ Alt*)
if [ "$ralt_allocated" != yes ]; then
switch=switch
ralt_allocated=yes
fi;;
Left\ Alt)
if [ "$lalt_allocated" != yes ]; then
switch=lswitch
lalt_allocated=yes
fi;;
Right\ Logo?key)
if [ "$rwin_allocated" != yes ]; then
switch=rwin_switch
rwin_allocated=yes
fi;;
Left\ Logo?key)
if [ "$lwin_allocated" != yes ]; then
switch=lwin_switch
lwin_allocated=yes
fi;;
Both\ Logo?keys)
if \
[ "$rwin_allocated" != yes ] \
&& [ "$lwin_allocated" != yes ]
then
switch=win_switch
rwin_allocated=yes
lwin_allocated=yes
fi;;
No\ temporary\ switch)
switch='';;
*)
echo Unknown switch key option
exit 1
;;
esac
if [ "$switch" ]; then
switch=grp:$switch
fi
db_get keyboard-configuration/altgr
altgr=''
case "$RET" in
The?default?for?the?keyboard?layout)
altgr='';;
No?AltGr?key)
if [ "$ralt_allocated" != yes ]; then
altgr=ralt_alt
fi;;
Right?Alt*)
if [ "$ralt_allocated" != yes ]; then
altgr=ralt_switch
ralt_allocated=yes
fi;;
Right?Control)
if [ "$rctrl_allocated" != yes ]; then
altgr=switch
rctrl_allocated=yes
fi;;
Menu?key)
if [ "$menu_allocated" != yes ]; then
altgr=menu_switch
menu_allocated=yes
fi;;
Keypad?Enter?key)
altgr=enter_switch;;
Right?Logo?key)
if [ "$rwin_allocated" != yes ]; then
altgr=rwin_switch
rwin_allocated=yes
fi;;
Left?Logo?key)
if [ "$lwin_allocated" != yes ]; then
altgr=lwin_switch
lwin_allocated=yes
fi;;
Both?Logo?keys)
if \
[ "$rwin_allocated" != yes ] \
&& [ "$lwin_allocated" != yes ]
then
altgr=win_switch
rwin_allocated=yes
lwin_allocated=yes
fi;;
Both?Alt?keys)
if \
[ "$lalt_allocated" != yes ] \
&& [ "$ralt_allocated" != yes ]
then
altgr=alt_switch
ralt_allocated=yes
lalt_allocated=yes
fi;;
Left?Alt)
if [ "$lalt_allocated" != yes ]; then
altgr=lalt_switch
lalt_allocated=yes
fi;;
*)
echo Unknown altgr key option
exit 1
;;
esac
if [ "$altgr" ]; then
altgr=lv3:$altgr
fi
db_get keyboard-configuration/compose
compose=''
case "$RET" in
No?compose?key)
compose='';;
Right?Alt*)
if [ "$ralt_allocated" != yes ]; then
compose=ralt
ralt_allocated=yes
fi;;
Right?Logo?key)
if [ "$rwin_allocated" != yes ]; then
compose=rwin
rwin_allocated=yes
fi;;
Left?Logo?key)
if [ "$lwin_allocated" != yes ]; then
compose=lwin 
lwin_allocated=yes
fi;;
Right?Control)
if [ "$rctrl_allocated" != yes ]; then
compose=rctrl 
rctrl_allocated=yes
fi;;
Menu?key)
if [ "$menu_allocated" != yes ]; then
compose=menu
menu_allocated=yes
fi;;
Caps?Lock)
if [ "$caps_allocated" != yes ]; then
compose=caps
caps_allocated=yes
fi;;
*)
echo Unknown compose key option
exit 1
;;
esac
if [ "$compose" ]; then
compose=compose:$compose
fi
db_get keyboard-configuration/ctrl_alt_bksp
if [ "$RET" = true ]; then
terminate=terminate:ctrl_alt_bksp
else
terminate=''
fi
if [ "$ralt_allocated" = yes -a "$altgr" = lv3:ralt_alt ]; then
altgr=''
fi
case "$XKBLAYOUT" in
*,*)
leds=grp_led:scroll;;
*)
leds='';;
esac
options=$(
echo $toggle $switch $altgr $compose $terminate $leds \
| sed -e 's/^ *//' -e 's/ *$//' -e 's/  */,/g'
)
db_set keyboard-configuration/optionscode "$options"
fi
;;
*)
break
;;
esac
old_state=$starting_state
done
if [ $STATE -eq 0 ]; then
exit 10
else
db_set keyboard-configuration/store_defaults_in_debconf_db false
fi
exit 0
