2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
6 [[ "$mount_needs" ]] && return 1
15 dracut_install -o $systemdutildir/systemd-vconsole-setup
16 KBDSUBDIRS=consolefonts,consoletrans,keymaps,unimaps
17 DEFAULT_FONT="${i18n_default_font:-LatArCyrHeb-16}"
18 I18N_CONF="/etc/locale.conf"
19 VCONFIG_CONF="/etc/vconsole.conf"
21 # This is from 10redhat-i18n.
25 MAP=$(find ${kbddir}/keymaps -type f -name $MAP -o -name $MAP.\* | head -n1)
26 [[ " $KEYMAPS " = *" $MAP "* ]] && return
27 KEYMAPS="$KEYMAPS $MAP"
34 for INCL in $($cmd "^include " $MAP | while read a a b; do echo ${a//\"/}; done); do
35 for FN in $(find ${kbddir}/keymaps -type f -name $INCL\*); do
41 # Function gathers variables from distributed files among the tree, maps to
42 # specified names and prints the result in format "new-name=value".
44 # $@ = list in format specified below (BNF notation)
46 # <list> ::= <element> | <element> " " <list>
47 # <element> ::= <conf-file-name> ":" <map-list>
48 # <map-list> ::= <mapping> | <mapping> "," <map-list>
49 # <mapping> ::= <src-var> "-" <dst-var> | <src-var>
51 # We assume no whitespace are allowed between symbols.
52 # <conf-file-name> is a file holding <src-var> in your system.
53 # <src-var> is a variable holding value of meaning the same as <dst-var>.
54 # <dst-var> is a variable which will be set up inside initramfs.
55 # If <dst-var> has the same name as <src-var> we can omit <dst-var>.
58 # /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
59 # <list> = /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
60 # <element> = /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
61 # <conf-file-name> = /etc/conf.d/keymaps
62 # <map-list> = KEYMAP,extended_keymaps-EXT_KEYMAPS
65 # <mapping> = extended_keymaps-EXT_KEYMAPS
66 # <src-var> = extended_keymaps
67 # <dst-var> = EXT_KEYMAPS
74 for map in ${item[1]//,/ }
77 if [[ -f "${item[0]}" ]]; then
78 value=$(grep "^${map[0]}=" "${item[0]}")
80 echo "${map[1]:-${map[0]}}=${value}"
87 dracut_install setfont loadkeys kbd_mode stty
89 if ! dracut_module_included "systemd"; then
90 inst ${moddir}/console_init.sh /lib/udev/console_init
91 inst_rules ${moddir}/10-console.rules
92 inst_hook cmdline 20 "${moddir}/parse-i18n.sh"
99 for _src in $(eval echo ${kbddir}/{${KBDSUBDIRS}}); do
101 cp --reflink=auto --sparse=auto -prfL -t "${initdir}/${_src}" "$_src"/*
104 # remove unnecessary files
105 rm -f -- "${initdir}${kbddir}/consoletrans/utflist"
106 find "${initdir}${kbddir}/" -name README\* -delete
107 find "${initdir}${kbddir}/" -name '*.gz' -print -quit \
108 | while read line; do
112 find "${initdir}${kbddir}/" -name '*.bz2' -print -quit \
113 | while read line; do
118 install_local_i18n() {
121 eval $(gather_vars ${i18n_vars})
122 [ -f $I18N_CONF ] && . $I18N_CONF
123 [ -f $VCONFIG_CONF ] && . $VCONFIG_CONF
125 shopt -q -s nocasematch
128 if [[ ${UNICODE} = YES || ${UNICODE} = 1 ]]
131 elif [[ ${UNICODE} = NO || ${UNICODE} = 0 ]]
138 if [[ ! ${UNICODE} && ${LANG} =~ .*\.UTF-?8 ]]
142 shopt -q -u nocasematch
144 # Gentoo user may have KEYMAP set to something like "-u pl2",
147 # KEYTABLE is a bit special - it defines base keymap name and UNICODE
148 # determines whether non-UNICODE or UNICODE version is used
150 if [[ ${KEYTABLE} ]]; then
151 if [[ ${UNICODE} == 1 ]]; then
152 [[ ${KEYTABLE} =~ .*\.uni.* ]] || KEYTABLE=${KEYTABLE%.map*}.uni
157 # I'm not sure of the purpose of UNIKEYMAP and GRP_TOGGLE. They were in
158 # original redhat-i18n module. Anyway it won't hurt.
159 EXT_KEYMAPS+=\ ${UNIKEYMAP}\ ${GRP_TOGGLE}
162 dinfo 'No KEYMAP configured.'
168 for map in ${EXT_KEYMAPS}
170 ddebug "Adding extra map: ${map}"
174 inst_opt_decompress ${KEYMAPS}
176 inst_opt_decompress ${kbddir}/consolefonts/${DEFAULT_FONT}.*
178 if [[ ${FONT} ]] && [[ ${FONT} != ${DEFAULT_FONT} ]]
181 inst_opt_decompress ${kbddir}/consolefonts/${FONT}.*
186 FONT_MAP=${FONT_MAP%.trans}
187 inst_simple ${kbddir}/consoletrans/${FONT_MAP}.trans
190 if [[ ${FONT_UNIMAP} ]]
192 FONT_UNIMAP=${FONT_UNIMAP%.uni}
193 inst_simple ${kbddir}/unimaps/${FONT_UNIMAP}.uni
196 mksubdirs ${initdir}${I18N_CONF}
197 mksubdirs ${initdir}${VCONFIG_CONF}
198 print_vars LC_ALL LANG >> ${initdir}${I18N_CONF}
199 print_vars KEYMAP EXT_KEYMAPS UNICODE FONT FONT_MAP FONT_UNIMAP >> ${initdir}${VCONFIG_CONF}
204 for kbddir in ${kbddir} /usr/lib/kbd /lib/kbd /usr/share /usr/share/kbd
206 [[ -d "${kbddir}" ]] && \
207 for dir in ${KBDSUBDIRS//,/ }
209 [[ -d "${kbddir}/${dir}" ]] && continue
216 derror "Directories ${KBDSUBDIRS//,/, } not found. Please" \
217 "inform us about the issue including your OS name and version."
221 [[ -f $I18N_CONF && -f $VCONFIG_CONF ]] || \
222 [[ ! ${hostonly} || ${i18n_vars} ]] || {
223 derror 'i18n_vars not set! Please set up i18n_vars in ' \
224 'configuration file.'
235 install_local_i18n || install_all_kbd