#!/bin/sh # Copyright © 2005 Anton Zinoviev # 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='' default_fontsize='' CHARMAP='' CODESET='' FONTFACE='' FONTSIZE='' ## FONTSETS ## Will be replaced by assignment for $fontsets: # fontsets='Arabic-Fixed15 # Arabic-Fixed16 # Arabic-vga14 # ... # Vietnamese-Fixed18 # ' ## CHARMAPS ## Will be replaced by assignment for $charmaps: # charmaps='ARMSCII-8 # CP1251 # CP1255 # ... # UTF-8' ## CODESETS ## codesets='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 () { echo "$fontsets" | sort | \ grep "^$CODESET-" | \ sed -e "s/^$CODESET-//" \ -e 's/[0-9][0-9]*x[0-9][0-9]*$//' \ -e 's/[0-9]*$//' | \ uniq } available_fontsizes () { echo "$fontsets" | sort | \ grep "^$CODESET-$fontface[0-9]" | \ sed -e "s/^$CODESET-$fontface//" | \ sort -n | \ uniq } decode_codeset () { echo "$codesets" | \ grep -F "$**" | \ sed 's/.*[*]//' } encode_codeset () { echo "$codesets" | \ grep -F "*$*" | \ sed 's/[*].*//' } 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 [ -d /lib/debian-installer ]; then CHARMAP=UTF-8 elif [ "$locale" = C ]; then CHARMAP=UTF-8 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=Uni2 codeset_priority=high ;; esac if [ "$CODESET" = unsupported ]; then CODESET=Uni2 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")" if [ -z "$default_codeset" ]; then default_codeset=Uni1 codeset_priority=high fi fi if [ "$FONTFACE" ]; then default_fontface="$FONTFACE" else db_metaget console-setup/use_system_font description default_fontface="$RET" fi if [ "$FONTSIZE" ]; then default_fontsize="$FONTSIZE" else # if $FONTSIZE='' this will be replaced by '' in the postinst default_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" db_set console-setup/fontsize-text47 "$default_fontsize" db_set console-setup/fontsize-fb47 "$default_fontsize" db_set console-setup/fontsize "$default_fontsize" 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) if [ -d /lib/debian-installer ] \ && db_get debian-installer/charmap \ && [ "$RET" ] then db_set console-setup/charmap47 "$CHARMAP" # skip the questions without making Debconf loop STATE=$(( $STATE + $STATE - $old_state )) else # 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 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_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 ;; 4) fontsizes=`available_fontsizes` # add commas choices=`echo "$fontsizes" | sed -e 's/$/,/g' ` # remove newlines choices=`echo $choices | sed -e 's/,$//'` if [ "$choices" ]; 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=$RET db_set console-setup/fontsize "$fontsize" else db_set console-setup/fontsize '' STATE=$(( $STATE + $STATE - $old_state )) fi ;; *) break ;; esac old_state=$starting_state done if [ $STATE -eq 0 ]; then exit 10 fi exit 0