1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813
|
#!/bin/sh
# Copyright © 2005 Anton Zinoviev <anton@lml.bas.bg>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# If you have not received a copy of the GNU General Public License
# along with this program, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# ----------
# CONTENTS
# ----------
#
# 1. Define the auxiliary functions db_default, regex_excape,
# regex_pattern_escape and regex_unescape.
#
# 2. Define the function all_kbdnames listing all supported keyboard
# models, layouts and variants and a function keyboard_present
# testing whether the computer has at least one keyboard
#
# 3. Function ask_debconf. Ask the user to choose amongst the options
# listed in $kbdnames.
#
# 4. Function guess_arch - detect the architecture and subarchitecture
#
# 5. Function keyboard_present - test if the computer has at least one keyboard
#
# 6. Set $locale. Extract the strings for the chosen language in $kbdnames.
#
# 7. Compute default values for $XKBMODEL, $XKBLAYOUT, $XKBVARIANT
# based on the architecture and the locale.
#
# 8. Overwrite (some of) the computed default values by:
# - preseeded values (for the udeb);
# - the value of debian-installer/keymap
# - the contents of /etc/X11/xorg.conf
# - the settings in the configuration files (/etc/default/...).
# - correct some bugs of previous versions of console-setup
#
# 9. If the computer doesn't have keyboard then do not ask questions,
# simply store the default values in the configuration file. This
# is in order to support headless installs in d-i. The regular
# packages (console-setup and console-setup-mini) should not be
# installed on such sistems.
#
# 10. Compute default values for the Debconf questions. For example
# from XKBLAYOUT=us,el we obtain debconf_layout=el and from
# XKBOPTIONS=lv3:ralt_switch we obtain debconf_altgr='Right Alt (AltGr)'
#
# 11. Ask the Debconf questions starting from STATE=1.
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
######################################################################
# Define auxiliary the functions db_default, regex_excape,
# regex_pattern_escape and regex_unescape.
######################################################################
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
}
# Store default value into debconf db. Workaround #352697.
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'
}
######################################################################
# Define the function all_kbdnames listing all supported keyboard
# models, layouts and variants and a function keyboard_present
# testing whether the computer has at least one keyboard
######################################################################
## KBDNAMES ## Will be replaced by all_kbdnames function:
# all_kbdnames () {
# cat <<'EOF'
# C*model*logidinovo*Logitech diNovo Keyboard
# C*model*amiga*Amiga
# ...
# zh_TW*layout*al*阿爾巴尼亞
# zh_TW*variant*al**阿爾巴尼亞
# EOF
# }
## KEYBOARD_PRESENT ## Will be replaced by keyboard_present function
# keyboard_present () {
# if there is a keyboard; then
# return 0
# else
# return 1
# fi
# }
######################################################################
# Function ask_debconf. Ask the user to choose amongst the options
# listed in $kbdnames.
######################################################################
ask_debconf () {
local template priority prefix default_code default_description choices add
# The template to ask
template="$1"
# The priority for the question
priority="$2"
# The prefix for $kbdnames
prefix="$(echo "$3"|regex_pattern_escape)"
# The default choice (optional)
default_code="$(echo "$4"|regex_pattern_escape)"
# Additional string to append to $kbdnames
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
# For XkbVariant the empty string is usually a sensible default
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
# A default was requested, but we couldn't resolve it to a
# description, so we'd better ask.
priority=critical
fi
db_input $priority $template || true
db_go || return 255
db_get $template
else
# There is only one choice - no need to use debconf
[ $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
}
######################################################################
# Function guess_arch - detect the architecture and subarchitecture
######################################################################
# The guess arch code is taken from "console-data.conf"
# (translated from Perl to shell)
# 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/ps3 pc "platform: PS3"
# ppc/cell pc "platform: Cell"
# ppc/{bbox,mbx,ppc64,82xx,8xx} Not yet supported by Debian
# arm/* pc (refered to as 'arm' only)
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
}
#########################################################################
# Set $locale. Extract the strings for the chosen language in $kbdnames
#########################################################################
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
######################################################################
# Compute default values for $XKBMODEL, $XKBLAYOUT, $XKBVARIANT
# based on the architecture and the locale.
######################################################################
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
# Keyboards for countries
*_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
;;
# Keyboards for specific languages and international keyboards:
# TODO: Is the following list correct?
*_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
XKBVARIANT=la # Berber (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
;;
# Fallback
*)
XKBLAYOUT=us
;;
esac
######################################################################
# Overwrite (some of) the computed default values by:
# - preseeded values (for the udeb);
# - the value of debian-installer/keymap
# - the contents of /etc/X11/xorg.conf
# - the settings in the configuration files (/etc/default/...).
# - correct some bugs of previous versions of console-setup
######################################################################
# Get defaults from debconf, to allow preseeding in the udeb
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
# Use the value of console-data debian-installer/keymap to get better default
# layout. This guesswork is copied from xserver-xorg.config.
# Lower the priority of the Debconf question to medium.
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
# Get default layout from xorg.conf if available
# Lower the priority of the Debconf question to medium.
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
# Load the config file, if it exists. Overwrite the current values of
# XKBMODEL, XKBLAYOUT, XKBVARIANT, etc. in the process.
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')
# Version 1.37 of console-setup would destroy the values of $XKBMODEL,
# $XKBLAYOUT and $XKBVARIANT in the configfile if sharutils was not
# installed. Version 1.47 destroyed $XKBMODEL.
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 the computer doesn't have keyboard then do not ask questions,
# simply store the default values in the configuration file. This
# is in order to support headless installs in d-i. The regular
# packages (console-setup and console-setup-mini) should not be
# installed on such sistems.
#######################################################################
if ! keyboard_present; then
# No questions, just store the defaults for postinst
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
#######################################################################
# Compute default values for the Debconf questions. For example
# from XKBLAYOUT=us,el we obtain debconf_layout=el and from
# XKBOPTIONS=lv3:ralt_switch we obtain debconf_altgr='Right Alt (AltGr)'
#######################################################################
# Set debconf_model. There is no difference between debconf_model and
# XKBMODEL, but lets create a new variable for consistency.
debconf_model="$XKBMODEL"
# Compute debconf_layout, debconf_variant and unsupported_layout based
# on values of $XKBLAYOUT and $XKBVARIANT.
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
;;
# TODO: make s.t. to not forget to update this list
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
# Make sure debconf_layout and debconf_variant point to existing in
# $kbdnames layout and variant. If the requested layout and/or
# variant are not in the $kbdnames, then we prefer debconf_layout=us
# and debconf_variant=''
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
# Compute debconf_* variables based on the value of $XKBOPTIONS. The
# values of these variables are human-friendly text.
debconf_toggle='Alt+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: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
# Store the default values for the options into debconf db. Notice we
# do not store the default values for the model, the layout and the
# variant since the respective questions are asked by the function
# ask_debconf and it takes care to store in debconf db the reqired text.
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"
# Compute a default value for the xkb-keymap question used by the
# Debian installer (one question listing all supported layouts instead
# of one question for the layout only and another for the variant).
# Store the value in the debconf db.
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"
#######################################################################
# Ask the Debconf questions starting from STATE=1.
#######################################################################
# At this point if unsupported_layout=yes, then the values of
# XKBLAYOUT and XKBVARIANT are relevant. Otherwise the values of
# debconf_layout and debconf_variant have to be used. Notice the
# difference between these variables - for example when
# XKBLAYOUT=us,el we have debconf_layout=el.
# Notice that the user may choose to disregard the fact that the
# configuration is unsupported (question unsupported_config_layout).
# Because of this, at this point we have to have sensible values for
# debconf_layout and debconf_variant even when unsupported_layout=yes.
STATE=1
old_state=0
while :; do
starting_state=$STATE
case "$STATE" in
1)
if [ "$is_debian_installer" ]; then
# do not ask model question in Debian installer
db_set keyboard-configuration/modelcode "$debconf_model"
db_fset keyboard-configuration/model seen true
# skip the question without making Debconf loop
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
# We use two different Debconf templates for the
# question about unsupported configuration. One for
# the case when the unsupported layout/variant
# combination has been taken from existing
# configuration file (obviously in this case the admin
# is responsible) and another for the case when it has
# been computed based on the system configuration such
# as the locale or xorg.conf (in which case the user
# may be unaware).
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
# The following code is for the following
# situation: admin creates unsupported
# configuration, then asks c-s not to keep this
# configuration (i.e. gives answer 'no' to this
# question), then restores by hand the unsupported
# configuration. Un upgrade the old answer to
# this question will be remembered by Debconf so
# c-s will overwrite the configuration. See #729321.
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
# The following code is for the following situation:
# first admin configures unsupported configuration,
# then gives answer to keep the configuration. After
# that admin configures (by hand) a supported
# configuration. And after that again unsupported.
# In this case we want the question about unsupported
# layout to be asked again.
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
# skip the question without making Debconf loop
STATE=$(( $STATE + $STATE - $old_state ))
fi
;;
3)
if [ "$is_debian_installer" ]; then
# ask simplified layout question in Debian installer
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
# skip the question without making Debconf loop
STATE=$(( $STATE + $STATE - $old_state ))
elif [ "$debconf_variant" != other ]; then
# skip the question without making Debconf loop
STATE=$(( $STATE + $STATE - $old_state ))
elif \
ask_debconf keyboard-configuration/layout "$layout_priority" \
layout "$debconf_layout"
then
debconf_layout="$RET"
STATE=$(($STATE + 1))
else
# always to the next question
STATE=$(($STATE + 1))
fi
;;
4)
db_metaget keyboard-configuration/other description
othertext="$RET"
if [ "$unsupported_layout" = yes ]; then
# skip the question without making Debconf loop
STATE=$(( $STATE + $STATE - $old_state ))
elif [ "$is_debian_installer" ]; then
# skip the question without making Debconf loop
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
# skip the previous question
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
# Compute $XKBLAYOUT and $XKBVARIANT and store their
# values in debconf db.
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
;;
# TODO: make s.t. to not forget to update this
# list. Do not forget to update also the
# nonlatin list in kbdcompiler
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
# skip the question without making Debconf loop
STATE=$(( $STATE + $STATE - $old_state ))
fi
;;
6)
if [ "$unsupported_options" = yes ]; then
db_set keyboard-configuration/optionscode "$XKBOPTIONS"
# skip the questions without making Debconf loop
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)
toggle=alt_shift_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
# no need for ralt_allocated=yes
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
# A fix for #566009
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
|