From ee6fa3240d2c7542d11f318e658de6a66956153e Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Fri, 29 Oct 2010 13:39:20 +0200 Subject: [PATCH] i18n: move to vconfig.* and locale.* namespace --- dracut.conf.d/fedora.conf.example | 3 +- dracut.conf.d/gentoo-openrc.conf.example | 3 +- dracut.conf.d/gentoo.conf.example | 3 +- dracut.conf.d/suse.conf.example | 3 +- dracut.kernel.7.xml | 88 ++++++++++++++++++++++++++------ modules.d/10i18n/10-console.rules | 2 +- modules.d/10i18n/README | 14 +++-- modules.d/10i18n/console_init | 4 +- modules.d/10i18n/install | 58 +++++++++++---------- modules.d/10i18n/parse-i18n.sh | 34 +++++++----- 10 files changed, 136 insertions(+), 76 deletions(-) diff --git a/dracut.conf.d/fedora.conf.example b/dracut.conf.d/fedora.conf.example index 38f4291..5ead070 100644 --- a/dracut.conf.d/fedora.conf.example +++ b/dracut.conf.d/fedora.conf.example @@ -2,5 +2,4 @@ # Dracut config file customized for RedHat/Fedora. # i18n -keyboard_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP" -i18n_vars="/etc/sysconfig/i18n:SYSFONT,SYSFONTACM-CONTRANS,UNIMAP" +i18n_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP /etc/sysconfig/i18n:FONT,FONTACM-FONT_MAP,FONT_UNIMAP" diff --git a/dracut.conf.d/gentoo-openrc.conf.example b/dracut.conf.d/gentoo-openrc.conf.example index cd5da46..f5aa8ed 100644 --- a/dracut.conf.d/gentoo-openrc.conf.example +++ b/dracut.conf.d/gentoo-openrc.conf.example @@ -6,5 +6,4 @@ # # i18n -keyboard_vars="/etc/conf.d/keymaps:keymap-KEYMAP,extended_keymaps-EXT_KEYMAPS" -i18n_vars="/etc/conf.d/consolefont:consolefont-SYSFONT,consoletranslation-CONTRANS /etc/rc.conf:unicode-UNICODE" +i18n_vars="/etc/conf.d/keymaps:keymap-KEYMAP,extended_keymaps-EXT_KEYMAPS /etc/conf.d/consolefont:consolefont-FONT,consoletranslation-FONT_MAP /etc/rc.conf:unicode-UNICODE" diff --git a/dracut.conf.d/gentoo.conf.example b/dracut.conf.d/gentoo.conf.example index 43e66e8..a40b746 100644 --- a/dracut.conf.d/gentoo.conf.example +++ b/dracut.conf.d/gentoo.conf.example @@ -6,5 +6,4 @@ # # i18n -keyboard_vars="/etc/conf.d/keymaps:KEYMAP,EXTENDED_KEYMAPS-EXT_KEYMAPS" -i18n_vars="/etc/conf.d/consolefont:CONSOLEFONT-SYSFONT,CONSOLETRANSLATION-CONTRANS /etc/rc.conf:UNICODE" +i18n_vars="/etc/conf.d/keymaps:KEYMAP,EXTENDED_KEYMAPS-EXT_KEYMAPS /etc/conf.d/consolefont:CONSOLEFONT-FONT,CONSOLETRANSLATION-FONT_MAP /etc/rc.conf:UNICODE" diff --git a/dracut.conf.d/suse.conf.example b/dracut.conf.d/suse.conf.example index 4b3ee29..9c44520 100644 --- a/dracut.conf.d/suse.conf.example +++ b/dracut.conf.d/suse.conf.example @@ -1,5 +1,4 @@ -i18n_vars="/etc/sysconfig/language:RC_LANG-LANG,RC_LC_ALL-LC_ALL /etc/sysconfig/console:CONSOLE_UNICODEMAP-UNIMAP,CONSOLE_FONT-SYSFONT,CONSOLE_SCREENMAP-CONTRANS" -keyboard_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP" +i18n_vars="/etc/sysconfig/language:RC_LANG-LANG,RC_LC_ALL-LC_ALL /etc/sysconfig/console:CONSOLE_UNICODEMAP-FONT_UNIMAP,CONSOLE_FONT-FONT,CONSOLE_SCREENMAP-FONT_MAP /etc/sysconfig/keyboard:KEYTABLE-KEYMAP" omit_dracutmodules+=" selinux " hostonly="yes" diff --git a/dracut.kernel.7.xml b/dracut.kernel.7.xml index e95980d..7f54e9e 100644 --- a/dracut.kernel.7.xml +++ b/dracut.kernel.7.xml @@ -177,74 +177,74 @@ This parameter can be specified multiple times. - KEYMAP= + voonsole.keymap= <keymap base file name> - keyboard translation table loaded by loadkeys; taken from keymaps directory; will be written to /etc/sysconfig/keyboard in the initramfs, e.g.: KEYMAP=de-latin1-nodeadkeys + keyboard translation table loaded by loadkeys; taken from keymaps directory; will be written as KEYMAP to /etc/vconsole.conf in the initramfs, e.g.: vconsole.keymap=de-latin1-nodeadkeys - EXT_KEYMAPS= + vconsole.keymap.ext= <list of keymap base file names> - list of extra keymaps to bo loaded (sep. by space); will be written to /etc/sysconfig/keyboard in the initramfs + list of extra keymaps to bo loaded (sep. by space); will be written as EXT_KEYMAP to /etc/vconsole.conf in the initramfs - UNICODE= + vconsole.font.unicode= <1|0> - boolean, indicating UTF-8 mode; will be written to /etc/sysconfig/i18n in the initramfs + boolean, indicating UTF-8 mode; will be written as UNICODE to /etc/vconsole.conf in the initramfs - SYSFONT= + vconsole.font= <font base file name> - console font; taken from consolefonts directory; will be written to /etc/sysconfig/i18n in the initramfs; e.g.: SYSFONT=LatArCyrHeb-16 + console font; taken from consolefonts directory; will be written as FONT to /etc/vconsole.conf in the initramfs; e.g.: vconsole.font=LatArCyrHeb-16 - CONTRANS= + vconsole.font.map= <console map base file name> - see description of '-m' parameter in setfont manual; taken from consoletrans directory; will be written to /etc/sysconfig/i18n in the initramfs + see description of '-m' parameter in setfont manual; taken from consoletrans directory; will be written as FONT_MAP to /etc/vconsole.conf in the initramfs - UNIMAP= + vconsole.font.unimap= <unicode table base file name> - see description of '-u' parameter in setfont manual; taken from unimaps directory; will be written to /etc/sysconfig/i18n in the initramfs + see description of '-u' parameter in setfont manual; taken from unimaps directory; will be written as FONT_UNIMAP to /etc/vconsole.conf in the initramfs - LANG= + locale.LANG= <locale> - taken from the environment; if no UNICODE is defined we set its value in basis of LANG value (whether it ends with ".utf8" (or similar) or not); will be written to /etc/sysconfig/i18n in the initramfs; e.g.: LANG=pl_PL.utf8 + taken from the environment; if no UNICODE is defined we set its value in basis of LANG value (whether it ends with ".utf8" (or similar) or not); will be written as LANG to /etc/locale.conf in the initramfs; e.g.: locale.LANG=pl_PL.utf8 - LC_ALL= + locale.LC_ALL= <locale> - taken from the environment; will be written to /etc/sysconfig/i18n in the initramfs + taken from the environment; will be written as LC_ALL to /etc/locale.conf in the initramfs @@ -1063,6 +1063,62 @@ rd_ZNET=ctc,0.0.0600,0.0.0601,0.0.0602,protocol=bar rd.zfcp + + + KEYMAP + + + vconsole.keymap + + + + + KEYTABLE + + + vconsole.keymap + + + + + SYSFONT + + + vconsole.font + + + + + CONTRANS + + + vconsole.font.map + + + + + UNIMAP + + + vconsole.font.unimap + + + + + UNICODE + + + vconsole.font.unicode + + + + + EXT_KEYMAP + + + vconsole.keymap.ext + + diff --git a/modules.d/10i18n/10-console.rules b/modules.d/10i18n/10-console.rules index c234c8a..80ed090 100644 --- a/modules.d/10i18n/10-console.rules +++ b/modules.d/10i18n/10-console.rules @@ -1,2 +1,2 @@ # Console initialization - keyboard, font, etc. -KERNEL=="tty0", RUN+="/lib/udev/console_init %k" +KERNEL=="tty0", RUN+="/lib/udev/console_init $root/$name" diff --git a/modules.d/10i18n/README b/modules.d/10i18n/README index c1878a7..db84d02 100644 --- a/modules.d/10i18n/README +++ b/modules.d/10i18n/README @@ -49,9 +49,9 @@ runtime: KEYMAP - keyboard translation table loaded by loadkeys EXT_KEYMAPS - list of extra keymaps to bo loaded (sep. by space) UNICODE - boolean, indicating UTF-8 mode - SYSFONT - console font - CONTRANS - see description of '-m' parameter in setfont manual - UNIMAP - see description of '-u' parameter in setfont manual + FONT - console font + FONT_MAP - see description of '-m' parameter in setfont manual + FONT_UNIMAP - see description of '-u' parameter in setfont manual The following are appended to EXT_KEYMAPS only during build time: @@ -72,11 +72,9 @@ used on the basis of LANG value (if it ends with ".utf8" or similar). Mappings between variables listed in 2.1. and the ones spread around your system are set up in /etc/dracut.conf.d/.conf. You need to -assign mappings to fields keyboard_vars and i18n_vars. Here's an -example: +assign mappings to i18n_vars. Here's an example: -keyboard_vars="/etc/conf.d/keymaps:KEYMAP,EXTENDED_KEYMAPS-EXT_KEYMAPS" -i18n_vars="/etc/conf.d/consolefont:CONSOLEFONT-SYSFONT,CONSOLETRANSLATION-CONTRANS /etc/rc.conf:UNICODE" +i18n_vars="/etc/conf.d/keymaps:KEYMAP,EXTENDED_KEYMAPS-EXT_KEYMAPS /etc/conf.d/consolefont:CONSOLEFONT-FONT,CONSOLETRANSLATION-FONT_MAP /etc/rc.conf:UNICODE" First we've got name of file in host file system tree. After colon there's mapping: -. If both variables have the same name you @@ -121,4 +119,4 @@ file (the same where you put mappings). If you create generic initramfs you can set up i18n by kernel parameters using variables listed in 2.1. (except of UNIKEYMAP -and GRP_TOGGLE) The recommended minimum is: SYSFONT, KEYMAP and UNICODE. +and GRP_TOGGLE) The recommended minimum is: FONT and KEYMAP. diff --git a/modules.d/10i18n/console_init b/modules.d/10i18n/console_init index f8f9bf3..e6f2da4 100755 --- a/modules.d/10i18n/console_init +++ b/modules.d/10i18n/console_init @@ -2,13 +2,11 @@ # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh -[ -e /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n -[ -e /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard +[ -e /etc/vconsole.conf ] && . /etc/vconsole.conf DEFAULT_SYSFONT=LatArCyrHeb-16 DEFAULT_KEYMAP=/etc/sysconfig/console/default.kmap - set_keyboard() { local param diff --git a/modules.d/10i18n/install b/modules.d/10i18n/install index 2409193..2b26358 100755 --- a/modules.d/10i18n/install +++ b/modules.d/10i18n/install @@ -3,10 +3,9 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh KBDSUBDIRS=consolefonts,consoletrans,keymaps,unimaps -DEFAULT_SYSFONT=LatArCyrHeb-16 -I18N_CONF="${initdir}/etc/sysconfig/i18n" -KEYBOARD_CONF="${initdir}/etc/sysconfig/keyboard" - +DEFAULT_FONT=LatArCyrHeb-16 +I18N_CONF="${initdir}/etc/locale.conf" +KEYBOARD_CONF="${initdir}/etc/vconsole.conf" # This is from 10redhat-i18n. findkeymap () { @@ -73,7 +72,14 @@ gather_vars() { install_base() { dracut_install setfont loadkeys kbd_mode stty - inst ${moddir}/console_init /lib/udev/console_init + + if [ -x /lib/systemd/systemd-vconsole-setup ]; then + dracut_install /lib/systemd/systemd-vconsole-setup + inst_dir /lib/udev + ln -s /lib/systemd/systemd-vconsole-setup "${initdir}/lib/udev/console_init" + else + inst ${moddir}/console_init /lib/udev/console_init + fi inst_rules ${moddir}/10-console.rules inst_hook cmdline 20 "${moddir}/parse-i18n.sh" } @@ -94,10 +100,16 @@ install_all_kbd() { } install_local_keyboard() { - local map eval $(gather_vars ${keyboard_vars}) + mksubdirs ${KEYBOARD_CONF} +} + +install_local_i18n() { + local map + eval $(gather_vars ${i18n_vars}) + # Gentoo user may have KEYMAP set to something like "-u pl2", KEYMAP=${KEYMAP#-* } # I'm not sure of the purpose of UNIKEYMAP and GRP_TOGGLE. They were in @@ -115,27 +127,20 @@ install_local_keyboard() { inst_opt_decompress ${KEYMAPS} - mksubdirs ${KEYBOARD_CONF} - print_vars KEYMAP EXT_KEYMAPS >> ${KEYBOARD_CONF} -} + [[ ${FONT} ]] || FONT=${DEFAULT_FONT} + FONT=${FONT%.psf*} + inst_opt_decompress ${kbddir}/consolefonts/${FONT}.* -install_local_i18n() { - eval $(gather_vars ${i18n_vars}) - - [[ ${SYSFONT} ]] || SYSFONT=${DEFAULT_SYSFONT} - SYSFONT=${SYSFONT%.psf*} - inst_opt_decompress ${kbddir}/consolefonts/${SYSFONT}.* - - if [[ ${CONTRANS} ]] + if [[ ${FONT_MAP} ]] then - CONTRANS=${CONTRANS%.trans} - inst ${kbddir}/consoletrans/${CONTRANS}.trans + FONT_MAP=${FONT_MAP%.trans} + inst ${kbddir}/consoletrans/${FONT_MAP}.trans fi - if [[ ${UNIMAP} ]] + if [[ ${FONT_UNIMAP} ]] then - UNIMAP=${UNIMAP%.uni} - inst ${kbddir}/unimaps/${UNIMAP}.uni + FONT_UNIMAP=${FONT_UNIMAP%.uni} + inst ${kbddir}/unimaps/${FONT_UNIMAP}.uni fi if [[ ${UNICODE} ]] @@ -156,7 +161,9 @@ install_local_i18n() { fi mksubdirs ${I18N_CONF} - print_vars LC_ALL LANG UNICODE SYSFONT CONTRANS UNIMAP >> ${I18N_CONF} + mksubdirs ${KEYBOARD_CONF} + print_vars LC_ALL LANG >> ${I18N_CONF} + print_vars KEYMAP EXT_KEYMAPS UNICODE FONT FONT_MAP FONT_UNIMAP >> ${KEYBOARD_CONF} } checks() { @@ -176,8 +183,8 @@ checks() { return 1 } - [[ ! ${hostonly} || ${keyboard_vars} && ${i18n_vars} ]] || { - derror 'Please set up keyboard_vars and i18n_vars in configuration file.' + [[ ! ${hostonly} || ${i18n_vars} ]] || { + derror 'Please set up i18n_vars in configuration file.' return 1 } } @@ -189,7 +196,6 @@ then if [[ ${hostonly} ]] then - install_local_keyboard install_local_i18n else install_all_kbd diff --git a/modules.d/10i18n/parse-i18n.sh b/modules.d/10i18n/parse-i18n.sh index 0d41eb7..0f267e6 100755 --- a/modules.d/10i18n/parse-i18n.sh +++ b/modules.d/10i18n/parse-i18n.sh @@ -3,24 +3,30 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh inst_key_val() { - local value - value=$(getarg $1) - [ -n "${value}" ] && printf '%s="%s"\n' $1 ${value} >> $2 + local _value + local _file + _file=$1 + shift + _value=$(getarg $@) + if [ -n "${_value}" ]; then + printf '%s="%s"\n' $1 ${_value} >> $_file + fi + unset _file + unset _value } +inst_key_val /etc/vconsole.conf KEYMAP vconsole.keymap KEYTABLE +inst_key_val /etc/vconsole.conf FONT vconsole.font SYSFONT +inst_key_val /etc/vconsole.conf FONT_MAP vconsole.font.map CONTRANS +inst_key_val /etc/vconsole.conf FONT_UNIMAP vconsole.font.unimap UNIMAP +inst_key_val /etc/vconsole.conf UNICODE vconsole.font.unicode +inst_key_val /etc/vconsole.conf EXT_KEYMAP vconsole.keymap.ext -mkdir -p /etc/sysconfig -inst_key_val KEYMAP /etc/sysconfig/keyboard -inst_key_val EXT_KEYMAPS /etc/sysconfig/keyboard -inst_key_val UNICODE /etc/sysconfig/i18n -inst_key_val SYSFONT /etc/sysconfig/i18n -inst_key_val CONTRANS /etc/sysconfig/i18n -inst_key_val UNIMAP /etc/sysconfig/i18n -inst_key_val LANG /etc/sysconfig/i18n -inst_key_val LC_ALL /etc/sysconfig/i18n +inst_key_val /etc/locale.conf LANG locale.LANG +inst_key_val /etc/locale.conf LC_ALL locale.LC_ALL -if [ -f /etc/sysconfig/i18n ]; then - . /etc/sysconfig/i18n +if [ -f /etc/locale.conf ]; then + . /etc/locale.conf export LANG export LC_ALL fi -- 2.7.4