This file is indexed.

config is in console-setup 1.108ubuntu15.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

   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
#!/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. Initialise the variables $fontsets and $charmaps that list all
#    supported fontsets and charmaps.
#
# 2. Function available_fontsets - lists all fontfaces that can be
#    used with $CODESET.
#
# 3. Function available_fontsizes - lists all font sizes that can be
#    used with the $CODESET-$fontface combination.
#
# 4. Functions decode_charmap to decode 'Uni1' to 'Combined - Latin;
#    Slavic Cyrillic; Hebrew; basic Arabic' and encode_charmap for the
#    opposite conversion.
#
# 5. Set $locale.  Extract the strings for the chosen language in $kbdnames.
#
# 6. Compute default values for $CODESET, $FONTFACE, $FONTSIZE, based
#    on the the locale.
#
# 7. Overwrite (some of) the computed default values by the settings
#    in the configuration file (/etc/default/console-setup).
#
# 8. Compute default values for the Debconf questions.
#
# 9. Ask the Debconf questions starting from STATE=1.

set -e

. /usr/share/debconf/confmodule

CONFIGFILE=/etc/default/console-setup

default_codeset=''
default_fontface=''
CHARMAP=''
CODESET=''
FONTFACE=''
FONTSIZE=''


fontsets='Arabic-Fixed15
Arabic-Fixed16
Arabic-VGA14
Arabic-VGA16
Arabic-VGA28x16
Arabic-VGA32x16
Arabic-VGA8
Armenian-Fixed13
Armenian-Fixed14
Armenian-Fixed15
Armenian-Fixed16
Armenian-Fixed18
CyrAsia-Fixed13
CyrAsia-Fixed14
CyrAsia-Fixed15
CyrAsia-Fixed16
CyrAsia-Fixed18
CyrAsia-Terminus12x6
CyrAsia-Terminus14
CyrAsia-Terminus16
CyrAsia-Terminus20x10
CyrAsia-Terminus22x11
CyrAsia-Terminus24x12
CyrAsia-Terminus28x14
CyrAsia-Terminus32x16
CyrAsia-TerminusBold14
CyrAsia-TerminusBold16
CyrAsia-TerminusBold20x10
CyrAsia-TerminusBold22x11
CyrAsia-TerminusBold24x12
CyrAsia-TerminusBold28x14
CyrAsia-TerminusBold32x16
CyrAsia-TerminusBoldVGA14
CyrAsia-TerminusBoldVGA16
CyrKoi-Fixed13
CyrKoi-Fixed14
CyrKoi-Fixed15
CyrKoi-Fixed16
CyrKoi-Fixed18
CyrKoi-Terminus12x6
CyrKoi-Terminus14
CyrKoi-Terminus16
CyrKoi-Terminus20x10
CyrKoi-Terminus22x11
CyrKoi-Terminus24x12
CyrKoi-Terminus28x14
CyrKoi-Terminus32x16
CyrKoi-TerminusBold14
CyrKoi-TerminusBold16
CyrKoi-TerminusBold20x10
CyrKoi-TerminusBold22x11
CyrKoi-TerminusBold24x12
CyrKoi-TerminusBold28x14
CyrKoi-TerminusBold32x16
CyrKoi-TerminusBoldVGA14
CyrKoi-TerminusBoldVGA16
CyrKoi-VGA14
CyrKoi-VGA16
CyrKoi-VGA28x16
CyrKoi-VGA32x16
CyrKoi-VGA8
CyrSlav-Fixed13
CyrSlav-Fixed14
CyrSlav-Fixed15
CyrSlav-Fixed16
CyrSlav-Fixed18
CyrSlav-Terminus12x6
CyrSlav-Terminus14
CyrSlav-Terminus16
CyrSlav-Terminus20x10
CyrSlav-Terminus22x11
CyrSlav-Terminus24x12
CyrSlav-Terminus28x14
CyrSlav-Terminus32x16
CyrSlav-TerminusBold14
CyrSlav-TerminusBold16
CyrSlav-TerminusBold20x10
CyrSlav-TerminusBold22x11
CyrSlav-TerminusBold24x12
CyrSlav-TerminusBold28x14
CyrSlav-TerminusBold32x16
CyrSlav-TerminusBoldVGA14
CyrSlav-TerminusBoldVGA16
CyrSlav-VGA14
CyrSlav-VGA16
CyrSlav-VGA28x16
CyrSlav-VGA32x16
CyrSlav-VGA8
Ethiopian-Fixed15
Ethiopian-Fixed18
Ethiopian-Goha12
Ethiopian-Goha14
Ethiopian-Goha16
Ethiopian-GohaClassic12
Ethiopian-GohaClassic14
Ethiopian-GohaClassic16
Georgian-Fixed13
Georgian-Fixed14
Georgian-Fixed15
Georgian-Fixed16
Georgian-Fixed18
Greek-Fixed13
Greek-Fixed14
Greek-Fixed15
Greek-Fixed16
Greek-Fixed18
Greek-Terminus12x6
Greek-Terminus14
Greek-Terminus16
Greek-Terminus20x10
Greek-Terminus22x11
Greek-Terminus24x12
Greek-Terminus28x14
Greek-Terminus32x16
Greek-TerminusBold14
Greek-TerminusBold16
Greek-TerminusBold20x10
Greek-TerminusBold22x11
Greek-TerminusBold24x12
Greek-TerminusBold28x14
Greek-TerminusBold32x16
Greek-TerminusBoldVGA14
Greek-TerminusBoldVGA16
Greek-VGA14
Greek-VGA16
Greek-VGA28x16
Greek-VGA32x16
Greek-VGA8
Hebrew-Fixed13
Hebrew-Fixed14
Hebrew-Fixed15
Hebrew-Fixed16
Hebrew-Fixed18
Hebrew-VGA14
Hebrew-VGA16
Hebrew-VGA28x16
Hebrew-VGA32x16
Hebrew-VGA8
Lao-Fixed14
Lao-Fixed15
Lao-Fixed16
Lat15-Fixed13
Lat15-Fixed14
Lat15-Fixed15
Lat15-Fixed16
Lat15-Fixed18
Lat15-Terminus12x6
Lat15-Terminus14
Lat15-Terminus16
Lat15-Terminus20x10
Lat15-Terminus22x11
Lat15-Terminus24x12
Lat15-Terminus28x14
Lat15-Terminus32x16
Lat15-TerminusBold14
Lat15-TerminusBold16
Lat15-TerminusBold20x10
Lat15-TerminusBold22x11
Lat15-TerminusBold24x12
Lat15-TerminusBold28x14
Lat15-TerminusBold32x16
Lat15-TerminusBoldVGA14
Lat15-TerminusBoldVGA16
Lat15-VGA14
Lat15-VGA16
Lat15-VGA28x16
Lat15-VGA32x16
Lat15-VGA8
Lat2-Fixed13
Lat2-Fixed14
Lat2-Fixed15
Lat2-Fixed16
Lat2-Fixed18
Lat2-Terminus12x6
Lat2-Terminus14
Lat2-Terminus16
Lat2-Terminus20x10
Lat2-Terminus22x11
Lat2-Terminus24x12
Lat2-Terminus28x14
Lat2-Terminus32x16
Lat2-TerminusBold14
Lat2-TerminusBold16
Lat2-TerminusBold20x10
Lat2-TerminusBold22x11
Lat2-TerminusBold24x12
Lat2-TerminusBold28x14
Lat2-TerminusBold32x16
Lat2-TerminusBoldVGA14
Lat2-TerminusBoldVGA16
Lat2-VGA14
Lat2-VGA16
Lat2-VGA28x16
Lat2-VGA32x16
Lat2-VGA8
Lat38-Fixed13
Lat38-Fixed14
Lat38-Fixed15
Lat38-Fixed16
Lat38-Fixed18
Lat38-VGA14
Lat38-VGA16
Lat38-VGA28x16
Lat38-VGA32x16
Lat38-VGA8
Lat7-Fixed13
Lat7-Fixed14
Lat7-Fixed15
Lat7-Fixed16
Lat7-Fixed18
Lat7-Terminus12x6
Lat7-Terminus14
Lat7-Terminus16
Lat7-Terminus20x10
Lat7-Terminus22x11
Lat7-Terminus24x12
Lat7-Terminus28x14
Lat7-Terminus32x16
Lat7-TerminusBold14
Lat7-TerminusBold16
Lat7-TerminusBold20x10
Lat7-TerminusBold22x11
Lat7-TerminusBold24x12
Lat7-TerminusBold28x14
Lat7-TerminusBold32x16
Lat7-TerminusBoldVGA14
Lat7-TerminusBoldVGA16
Lat7-VGA14
Lat7-VGA16
Lat7-VGA28x16
Lat7-VGA32x16
Lat7-VGA8
Thai-Fixed13
Thai-Fixed14
Thai-Fixed15
Thai-Fixed16
Thai-Fixed18
Uni1-Fixed15
Uni1-Fixed16
Uni1-VGA14
Uni1-VGA16
Uni1-VGA28x16
Uni1-VGA32x16
Uni1-VGA8
Uni2-Fixed13
Uni2-Fixed14
Uni2-Fixed15
Uni2-Fixed16
Uni2-Fixed18
Uni2-Terminus12x6
Uni2-Terminus14
Uni2-Terminus16
Uni2-Terminus20x10
Uni2-Terminus22x11
Uni2-Terminus24x12
Uni2-Terminus28x14
Uni2-Terminus32x16
Uni2-TerminusBold14
Uni2-TerminusBold16
Uni2-TerminusBold20x10
Uni2-TerminusBold22x11
Uni2-TerminusBold24x12
Uni2-TerminusBold28x14
Uni2-TerminusBold32x16
Uni2-TerminusBoldVGA14
Uni2-TerminusBoldVGA16
Uni2-VGA14
Uni2-VGA16
Uni2-VGA28x16
Uni2-VGA32x16
Uni2-VGA8
Uni3-Fixed13
Uni3-Fixed14
Uni3-Fixed15
Uni3-Fixed16
Uni3-Fixed18
Uni3-Terminus12x6
Uni3-Terminus14
Uni3-Terminus16
Uni3-Terminus20x10
Uni3-Terminus22x11
Uni3-Terminus24x12
Uni3-Terminus28x14
Uni3-Terminus32x16
Uni3-TerminusBold14
Uni3-TerminusBold16
Uni3-TerminusBold20x10
Uni3-TerminusBold22x11
Uni3-TerminusBold24x12
Uni3-TerminusBold28x14
Uni3-TerminusBold32x16
Uni3-TerminusBoldVGA14
Uni3-TerminusBoldVGA16
Vietnamese-Fixed13
Vietnamese-Fixed14
Vietnamese-Fixed15
Vietnamese-Fixed16
Vietnamese-Fixed18
'
# fontsets='Arabic-Fixed15
# Arabic-Fixed16
# Arabic-VGA14
# ... 
# Vietnamese-Fixed18
# '

charmaps='ARMSCII-8
CP1251
CP1255
CP1256
GEORGIAN-ACADEMY
GEORGIAN-PS
IBM1133
ISIRI-3342
ISO-8859-1
ISO-8859-10
ISO-8859-11
ISO-8859-13
ISO-8859-14
ISO-8859-15
ISO-8859-16
ISO-8859-2
ISO-8859-3
ISO-8859-4
ISO-8859-5
ISO-8859-6
ISO-8859-7
ISO-8859-8
ISO-8859-9
KOI8-R
KOI8-U
TIS-620
VISCII
UTF-8'

# charmaps='ARMSCII-8
# CP1251
# CP1255
# ...
# UTF-8'

## CODESETS ##

codesets='guess*Guess optimal character set
Arabic*. Arabic
Armenian*# Armenian
CyrKoi*# Cyrillic - KOI8-R and KOI8-U
CyrAsia*# Cyrillic - non-Slavic languages
CyrSlav*# Cyrillic - Slavic languages (also Bosnian and Serbian Latin)
Ethiopian*. Ethiopic
Georgian*# Georgian
Greek*# Greek
Hebrew*# Hebrew
Lao*# Lao
Lat15*# Latin1 and Latin5 - western Europe and Turkic languages
Lat2*# Latin2 - central Europe and Romanian
Lat38*# Latin3 and Latin8 - Chichewa; Esperanto; Irish; Maltese and Welsh
Lat7*# Latin7 - Lithuanian; Latvian; Maori and Marshallese
Vietnamese*. Latin - Vietnamese
Thai*# Thai
Uni1*. Combined - Latin; Slavic Cyrillic; Hebrew; basic Arabic
Uni2*. Combined - Latin; Slavic Cyrillic; Greek
Uni3*. Combined - Latin; Slavic and non-Slavic Cyrillic'

db_capb backup

available_fontfaces () {
    local prefix
    case "$CODESET" in
        guess) prefix='[^-]*-' ;;
        *) prefix="$CODESET"- ;;
    esac
    echo "$fontsets" | sort | \
	grep "^$prefix" | \
	sed -e "s/^$prefix//" \
	    -e 's/[0-9][0-9]*x[0-9][0-9]*$//' \
	    -e 's/[0-9]*$//' | \
	sort -n | \
	uniq
}

available_fontsizes () {
    local prefix
    case "$CODESET" in
        guess) prefix='[^-]*-' ;;
        *) prefix="$CODESET"- ;;
    esac
    case "$fontface" in
        guess) prefix="$prefix[^0-9]*" ;;
        *) prefix="$prefix$fontface" ;; # this includes fontface=''
    esac
    echo "$fontsets" \
	| grep "^$prefix[0-9]" \
	| sed -e "s/^$prefix//" \
        | sort -n | uniq \
        | while read x; do
              decode_fontsize "$x"
          done \
}

db_metaget console-setup/framebuffer_only description
framebuffer_only="$RET"
decode_fontsize () {
    local a b fbonly
    case "$1" in
        8x*)
            echo 8x${1#*x}
            ;;
        *x8)
            echo 8x${1%x*}
            ;;
        *x*)
            a=${1#*x}
            b=${1%x*}
            if [ "$a" -lt "$b" ]; then
                echo ${a}x${b} "($framebuffer_only)"
            else
                echo ${b}x${a} "($framebuffer_only)"
            fi
            ;;
        *)
            echo 8x$1
            ;;
    esac
}

encode_fontsize () {
    echo $1 | sed -e 's/[\, ;].*//'
}

decode_codeset () {
    echo "$codesets" | \
	grep -F "$**" | \
	sed 's/.*[*]//'
}

encode_codeset () {
    echo "$codesets" | \
	grep -F "*$*" | \
	sed 's/[*].*//'
}

kernel=unknown
if which uname >/dev/null; then
    case "`uname`" in
        *Linux*) kernel=linux ;;
        *FreeBSD*) kernel=freebsd ;;
    esac
fi

if type 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 [ "$locale" = C ]; then
    case "$kernel" in
	freebsd)
	    CHARMAP=ISO-8859-15
	    ;;
	*)
	    CHARMAP=UTF-8
	    ;;
    esac
    charmap_priority=high
elif type locale 2>/dev/null >/dev/null; then
    CHARMAP=`locale charmap`
else
    CHARMAP=unknown
fi
if echo "$charmaps" | grep "$CHARMAP" >/dev/null; then
    charmap_priority=low
else
    CHARMAP=UTF-8
    charmap_priority=high
fi

case "$locale" in
    *KOI8*|*koi8*)
	CODESET=CyrKoi
	codeset_priority=low
	;;
    aa_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    af_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    am_*)
	CODESET=Ethiopic
	codeset_priority=low
	;;
    an_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    ar_*)
	CODESET=Arabic
	codeset_priority=low
	;;
    ast_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    az_*)
	CODESET=Uni3
	codeset_priority=low
	;;
    be_*)
	CODESET=CyrSlav
	codeset_priority=low
	;;
    bg_*)
	CODESET=CyrSlav
	codeset_priority=low
	;;
    bn_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    br_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    bs_*)
	CODESET=Uni3
	codeset_priority=low
	;;
    byn_*)
	CODESET=Ethiopian
	codeset_priority=low
	;;
    ca_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    cs_*)
	CODESET=Lat2
	codeset_priority=low
	;;
    cy_*)
	CODESET=Lat38
	codeset_priority=low
	;;
    da_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    de_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    el_*)
	CODESET=Greek
	codeset_priority=low
	;;
    en_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    eo|eo.*|eo_*|eo\@*)
	CODESET=Lat38
	codeset_priority=low
	;;
    es_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    et_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    eu_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    fa_*)
	CODESET=Arabic
	codeset_priority=low
	;;
    fi_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    fo_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    fr_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    ga_*)
	CODESET=Lat38
	codeset_priority=low
	;;
    gd_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    gez_*)
	CODESET=Ethiopian
	codeset_priority=low
	;;
    gl_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    gu_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    gv_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    he_*)
	CODESET=Hebrew
	codeset_priority=low
	;;
    hi_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    hr_*)
	CODESET=Lat2
	codeset_priority=low
	;;
    hu_*)
	CODESET=Lat2
	codeset_priority=low
	;;
    hy_*)
	CODESET=Armenian
	codeset_priority=low
	;;
    id_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    is_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    it_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    iw_*)
	CODESET=Hebrew
	codeset_priority=low
	;;
    ja_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    ka_*)
	CODESET=Georgian
	codeset_priority=low
	;;
    kl_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    kn_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    ko_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    kw_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    lg_*)
	CODESET=Lat15 # TODO: This must be ISO-8859-10 (Latin6)
	codeset_priority=low
	;;
    lo_*)
	CODESET=Lao
	codeset_priority=low
	;;
    lt_*)
	CODESET=Lat7
	codeset_priority=low
	;;
    lv_*)
	CODESET=Lat7
	codeset_priority=low
	;;
    ky_*)
	CODESET=CyrAsia
	codeset_priority=low
	;;
    mi_*)
	CODESET=Lat7
	codeset_priority=low
	;;
    mk_*)
	CODESET=CyrSlav
	codeset_priority=low
	;;
    ml_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    mn_*)
	CODESET=CyrAsia
	codeset_priority=low
	;;
    mr_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    ms_*)
	CODESET=Lat15 # TODO: Is this correct? (Malay language)
	codeset_priority=low
	;;
    mt_*)
	CODESET=Lat38
	codeset_priority=low
	;;
    nb_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    ne_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    nl_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    nn_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    oc_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    om_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    pa_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    pl_*)
	CODESET=Lat2
	codeset_priority=low
	;;
    pt_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    ro_*)
	CODESET=Lat2
	codeset_priority=low
	;;
    ru_*)
	CODESET=CyrSlav
	codeset_priority=low
	;;
    se_*)
	CODESET=Uni1
	codeset_priority=low
	;;
    sid_*)
	CODESET=Lat15 # TODO: Is this correct? (Sidama language)
	codeset_priority=low
	;;
    sk_*)
	CODESET=Lat2
	codeset_priority=low
	;;
    sl_*)
	CODESET=Lat2
	codeset_priority=low
	;;
    so_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    sq_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    sr_*)
	CODESET=CyrSlav
	codeset_priority=low
	;;
    st_*)
	CODESET=Lat15 # TODO: Is this correct? (Sotho language)
	codeset_priority=low
	;;
    sv_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    ta_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    te_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    tg_*)
	CODESET=CyrAsia
	codeset_priority=low
	;;
    th_*)
	CODESET=Thai
	codeset_priority=low
	;;
    ti_*)
	CODESET=Ethiopian
	codeset_priority=low
	;;
    tig_*)
	CODESET=Ethiopian
	codeset_priority=low
	;;
    tl_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    tr_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    tt_*)
	CODESET=Lat15 # TODO: Is this correct? (Tatar language)
	codeset_priority=low
	;;
    uk_*)
	CODESET=CyrSlav
	codeset_priority=low
	;;
    ur_*)
	CODESET=Arabic
	codeset_priority=low
	;;
    uz_*)
	CODESET=Lat15 # TODO: Is this correct? (Uzbek language)
	codeset_priority=low
	;;
    uz_*\@cyrillic)
	CODESET=CyrAsia
	codeset_priority=low
	;;
    vi_*)
	CODESET=Vietnamese
	codeset_priority=low
	;;
    wa_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    xh_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    yi_*)
	CODESET=Hebrew
	codeset_priority=low
	;;
    zh_*)
	CODESET=unsupported
	codeset_priority=low
	;;
    zu_*)
	CODESET=Lat15
	codeset_priority=low
	;;
    *)
	CODESET=guess
        if [ "$CHARMAP" = UTF-8 ]; then
	    codeset_priority=high
        else
            # for 8-bit encodings we can guess good codeset
	    codeset_priority=low
        fi
	;;
esac
if [ "$CODESET" = unsupported ]; then
    CODESET=guess
fi

case "$CODESET" in
    Arabic)
	FONTFACE=VGA
	;;
    Armenian)
	FONTFACE=Fixed
	;;
    CyrAsia)
	FONTFACE=Fixed
	;;
    CyrKoi)
	FONTFACE=VGA
	;;
    CyrSlav)
	FONTFACE=Fixed
	;;
    Ethiopian)
	FONTFACE=Goha
	;;
    Georgian)
	FONTFACE=Fixed
	;;
    Greek)
	FONTFACE=Fixed
	;;
    Hebrew)
	FONTFACE=Fixed
	;;
    Lao)
	FONTFACE=Fixed
	;;
    Lat15)
	FONTFACE=VGA
	;;
    Lat2)
	FONTFACE=Fixed
	;;
    Lat38)
	FONTFACE=Fixed
	;;
    Lat7)
	FONTFACE=Fixed
	;;
    Thai)
	FONTFACE=Fixed
	;;
    Uni1)
	FONTFACE=VGA
	;;
    Uni2)
	FONTFACE=Fixed
	;;
    Uni3)
	FONTFACE=Fixed
	;;
    Vietnamese)
	FONTFACE=Fixed
	;;
    *)
	FONTFACE=Fixed
	;;
esac

FONTSIZE=16

### READ THE DEFAULTS ##################################################

# Load the config file, if it exists.
if [ -e $CONFIGFILE ]; then
    . $CONFIGFILE || true
fi

# Compute default values for the Debconf questions

if [ "$CODESET" ]; then
    default_codeset="$(decode_codeset "$CODESET")"
fi

if [ "$FONTFACE" = guess ]; then
    db_metaget console-setup/guess_font description
    default_fontface="$RET"
elif [ "$FONTFACE" ]; then
    default_fontface="$FONTFACE"
else
    db_metaget console-setup/use_system_font description
    default_fontface="$RET"
fi

if [ "$FONTSIZE" = guess -a "$FONTFACE" != guess ]; then
    # this combination is currently unsupported
    FONTSIZE=16
fi
if [ "$FONTFACE" ]; then
    FONTSIZE=${FONTSIZE:-16}
fi

# Store the default values into debconf db.  Workaround #352697.
db_get console-setup/store_defaults_in_debconf_db
if [ "$RET" = true ]; then
    db_set console-setup/charmap47 "$CHARMAP"
    db_set console-setup/codeset47 "$default_codeset"
    db_set console-setup/fontface47 "$default_fontface"
    fontsizetext="`decode_fontsize $FONTSIZE`"
    db_set console-setup/fontsize-text47 "$fontsizetext"
    db_set console-setup/fontsize-fb47 "$fontsizetext"
    db_set console-setup/fontsize "$fontsizetext"

    db_set console-setup/store_defaults_in_debconf_db false
fi

#######################################################################

STATE=1
old_state=0
while :; do
    starting_state=$STATE
    case "$STATE" in
	1)
            # add commas
	    choices=`echo "$charmaps" | sed -e 's/$/,/g' | LC_ALL=C sort `
	    # remove newlines
	    choices=`echo $choices | sed -e 's/,$//' `
	    db_subst console-setup/charmap47 CHOICES "$choices"
	    db_input $charmap_priority console-setup/charmap47 || true
	    if db_go; then
		STATE=$(($STATE + 1))
	    else
		STATE=$(($STATE - 1))
	    fi
	    ;;
	2)
	    db_input $codeset_priority console-setup/codeset47 || true
	    if db_go; then
		db_get console-setup/codeset47
		CODESET="$(encode_codeset "$RET")"
		db_set console-setup/codesetcode "$CODESET"
		STATE=$(($STATE + 1))
	    else
		STATE=$(($STATE - 1))
	    fi
	    ;;
	3)
	    fontfaces=`available_fontfaces`
	    # add commas
	    choices=`echo "$fontfaces" | sed -e 's/$/,/g'`
	    # remove newlines
	    choices=`echo $choices | sed -e 's/,$//'`
	    db_metaget console-setup/use_system_font description
	    choices="$choices, $RET"
	    db_metaget console-setup/guess_font description
	    choices="$choices, $RET"
	    db_subst console-setup/fontface47 CHOICES "$choices"
	    db_input medium console-setup/fontface47 || true
	    if db_go; then
		STATE=$(($STATE + 1))
	    else
		STATE=$(($STATE - 1))
	    fi
	    db_get console-setup/fontface47
	    fontface=$RET
	    db_metaget console-setup/use_system_font description
	    if [ "$fontface" = "$RET" ]; then
		fontface=''
	    fi
	    db_metaget console-setup/guess_font description
	    if [ "$fontface" = "$RET" ]; then
		fontface=guess
	    fi
	    ;;
	4)
            if [ "$kernel" = freebsd ]; then
	        db_set console-setup/fontsize "$FONTSIZE"
		# skip the question without making Debconf loop
		STATE=$(( $STATE + $STATE - $old_state ))
            else
	        fontsizes=`available_fontsizes`
	        # add commas
	        choices=`echo "$fontsizes" | sed -e 's/$/,/g' `
	        # remove newlines and the last comma
	        choices=`echo $choices | sed -e 's/,$//'`
	        if [ -n "$choices" -a "$FONTSIZE" != guess ]; then
		    if echo "$choices" | grep -q x; then
		        size_template=console-setup/fontsize-fb47
		    else
		        size_template=console-setup/fontsize-text47
		    fi
		    db_subst $size_template CHOICES "$choices"
		    db_input medium $size_template || true
		    if db_go; then
		        STATE=$(($STATE + 1))
		    else
		        STATE=$(($STATE - 1))
		    fi
		    db_get $size_template
		    FONTSIZE=`encode_fontsize "$RET"`
	        else
                    FONTSIZE=${choices:+guess}
		    STATE=$(( $STATE + $STATE - $old_state ))
                fi
	        db_set console-setup/fontsize "$FONTSIZE"
	    fi
	    ;;
	*)
	    break
	    ;;
    esac
    old_state=$starting_state
done

if [ $STATE -eq 0 ]; then
    exit 10
fi

exit 0