[[ "$mount_needs" ]] && return 1
require_binaries setfont loadkeys kbd_mode || return 1
if dracut_module_included "systemd"; then
[[ -f /etc/vconsole.conf ]] && . /etc/vconsole.conf
KBDSUBDIRS=consolefonts,consoletrans,keymaps,unimaps
DEFAULT_FONT="${i18n_default_font:-LatArCyrHeb-16}"
I18N_CONF="/etc/locale.conf"
VCONFIG_CONF="/etc/vconsole.conf"
# This is from 10redhat-i18n.
MAPS=$(find ${kbddir}/keymaps -type f -name ${MAPNAME} -o -name ${MAPNAME}.map -o -name ${MAPNAME}.map.\*)
for INCL in $($cmd "^include " $map | while read a a b || [ -n "$a" ]; do echo ${a//\"/}; done); do
for FN in $(find ${kbddir}/keymaps -type f -name $INCL\*); do
strstr "$KEYMAPS" "$FN" || findkeymap $FN
# Function gathers variables from distributed files among the tree, maps to
# specified names and prints the result in format "new-name=value".
# $@ = list in format specified below (BNF notation)
# <list> ::= <element> | <element> " " <list>
# <element> ::= <conf-file-name> ":" <map-list>
# <map-list> ::= <mapping> | <mapping> "," <map-list>
# <mapping> ::= <src-var> "-" <dst-var> | <src-var>
# We assume no whitespace are allowed between symbols.
# <conf-file-name> is a file holding <src-var> in your system.
# <src-var> is a variable holding value of meaning the same as <dst-var>.
# <dst-var> is a variable which will be set up inside initramfs.
# If <dst-var> has the same name as <src-var> we can omit <dst-var>.
# /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
# <list> = /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
# <element> = /etc/conf.d/keymaps:KEYMAP,extended_keymaps-EXT_KEYMAPS
# <conf-file-name> = /etc/conf.d/keymaps
# <map-list> = KEYMAP,extended_keymaps-EXT_KEYMAPS
# <mapping> = extended_keymaps-EXT_KEYMAPS
# <src-var> = extended_keymaps
# <dst-var> = EXT_KEYMAPS
for map in ${item[1]//,/ }
if [[ -f "${item[0]}" ]]; then
value=$(grep "^${map[0]}=" "${item[0]}")
echo "${map[1]:-${map[0]}}=${value}"
inst_multiple setfont loadkeys kbd_mode stty
if ! dracut_module_included "systemd"; then
inst ${moddir}/console_init.sh /lib/udev/console_init
inst_rules ${moddir}/10-console.rules
inst_hook cmdline 20 "${moddir}/parse-i18n.sh"
if [[ ${kbddir} != "/usr/share" ]]; then
for _src in $(eval echo {${KBDSUBDIRS}}); do
[ ! -e "${initdir}/usr/share/${_src}" ] && ln -s "${kbddir}/${_src}" "${initdir}/usr/share/${_src}"
for _src in $(eval echo ${kbddir}/{${KBDSUBDIRS}}); do
$DRACUT_CP -L -t "${initdir}/${_src}" "$_src"/*
# remove unnecessary files
rm -f -- "${initdir}${kbddir}/consoletrans/utflist"
find "${initdir}${kbddir}/" -name README\* -delete
find "${initdir}${kbddir}/" -name '*.gz' -print -quit \
| while read line || [ -n "$line" ]; do
find "${initdir}${kbddir}/" -name '*.bz2' -print -quit \
| while read line || [ -n "$line" ]; do
eval $(gather_vars ${i18n_vars})
[ -f $I18N_CONF ] && . $I18N_CONF
[ -f $VCONFIG_CONF ] && . $VCONFIG_CONF
if [[ ${UNICODE} = YES || ${UNICODE} = 1 ]]
elif [[ ${UNICODE} = NO || ${UNICODE} = 0 ]]
if [[ ! ${UNICODE} && ${LANG} =~ .*\.UTF-?8 ]]
# Gentoo user may have KEYMAP set to something like "-u pl2",
# openSUSE user may have KEYMAP set to something like ".gz"
# KEYTABLE is a bit special - it defines base keymap name and UNICODE
# determines whether non-UNICODE or UNICODE version is used
if [[ ${KEYTABLE} ]]; then
if [[ ${UNICODE} == 1 ]]; then
[[ ${KEYTABLE} =~ .*\.uni.* ]] || KEYTABLE=${KEYTABLE%.map*}.uni
# I'm not sure of the purpose of UNIKEYMAP and GRP_TOGGLE. They were in
# original redhat-i18n module. Anyway it won't hurt.
EXT_KEYMAPS+=\ ${UNIKEYMAP}\ ${GRP_TOGGLE}
dinfo 'No KEYMAP configured.'
for map in ${EXT_KEYMAPS}
ddebug "Adding extra map: ${map}"
for keymap in ${KEYMAPS}; do
inst_opt_decompress ${keymap}
inst_opt_decompress ${kbddir}/consolefonts/${DEFAULT_FONT}.*
if [[ ${FONT} ]] && [[ ${FONT} != ${DEFAULT_FONT} ]]
inst_opt_decompress ${kbddir}/consolefonts/${FONT}.*
FONT_MAP=${FONT_MAP%.trans}
# There are three different formats that setfont supports
inst_simple ${kbddir}/consoletrans/${FONT_MAP} \
|| inst_simple ${kbddir}/consoletrans/${FONT_MAP}.trans \
|| inst_simple ${kbddir}/consoletrans/${FONT_MAP}_to_uni.trans \
|| dwarn "Could not find FONT_MAP ${FONT_MAP}!"
FONT_UNIMAP=${FONT_UNIMAP%.uni}
inst_simple ${kbddir}/unimaps/${FONT_UNIMAP}.uni
if dracut_module_included "systemd" && [[ -f ${I18N_CONF} ]]; then
mksubdirs ${initdir}${I18N_CONF}
print_vars LC_ALL LANG >> ${initdir}${I18N_CONF}
if dracut_module_included "systemd" && [[ -f ${VCONFIG_CONF} ]]; then
inst_simple ${VCONFIG_CONF}
mksubdirs ${initdir}${VCONFIG_CONF}
print_vars KEYMAP EXT_KEYMAPS UNICODE FONT FONT_MAP FONT_UNIMAP >> ${initdir}${VCONFIG_CONF}
for kbddir in ${kbddir} /usr/lib/kbd /lib/kbd /usr/share /usr/share/kbd
[[ -d "${kbddir}" ]] && \
for dir in ${KBDSUBDIRS//,/ }
[[ -d "${kbddir}/${dir}" ]] && continue
[[ -f $I18N_CONF && -f $VCONFIG_CONF ]] || \
[[ ! ${hostonly} || ${i18n_vars} ]] || {
derror 'i18n_vars not set! Please set up i18n_vars in ' \
if [[ ${hostonly} ]] && ! [[ ${i18n_install_all} == "yes" ]]; then
install_local_i18n || install_all_kbd