Commit b5ff2b24 authored by Michael Shigorin's avatar Michael Shigorin

initial l10n feature

Aimed at live images at first but should cover installers as well. This has been brewing for quite some time and while the proper implementation is considerably more complex (and hard to do) looks like there's demand for the particular important use case, namely LiveCDs for Russian users, so this code has been shared with a few people before merge.
parent c293dd14
......@@ -14,7 +14,8 @@
удобно для анализа и обновления (и в отличие от _m-p-d_ -- нет
вынужденной необходимости либо контролировать включение нужных
фич "вручную" в скриптах по косвенным признакам, либо выносить
их в пакеты installer-feature-*).
их в пакеты installer-feature-*); также возможно добиться большей
степени интеграции по данным (например, язык gfxboot и LiveCD).
Создание и упаковку installer-feature-* можно рекомендовать, если:
......
Эта фича занимается поддержкой локализации (l10n).
# install locales
# setup locale
# setup console keyboard (kbd)
# setup X11 keyboard (xkb)
# install/setup additional packages
# TODO: KEYMAP for default keymap?
use/l10n:
@$(call add_feature)
@$(call add,STAGE2_BOOTARGS,lang=$$(LOCALE))
@$(call add,THE_PACKAGES,glibc-locales)
@$(call add,LOCALES,en_US)
@$(call add,XKB_KEYMAPS,us)
@$(call xport,LOCALE)
@$(call xport,LOCALES)
@$(call xport,XKB_KEYMAPS)
@$(call xport,XKB_VARIANTS)
@$(call xport,XKB_SWITCH)
@$(call xport,XKB_LED)
# see also alterator-sysconfig backend
use/l10n/xkb/switch/ctrl_shift: use/l10n
@$(call set,XKB_SWITCH,grp:ctrl_shift_toggle)
use/l10n/xkb/led/scroll: use/l10n
@$(call set,XKB_LED,grp_led:scroll)
# FIXME: derive from locale by default if possible
use/l10n/ru_RU: use/l10n/xkb/switch/ctrl_shift use/l10n/xkb/led/scroll
@$(call add,LOCALES,ru_RU)
@$(call set,LOCALE,ru_RU)
@$(call add,XKB_KEYMAPS,ru)
@$(call set,KEYTABLE,ruwin_ct_sh-UTF-8)
# NB: BOOT_LANG is used within mkimage internally
use/l10n/default/ru_RU: use/l10n/ru_RU
@$(call set,GLOBAL_BOOT_LANG,ru_RU)
#!/bin/sh
# partial port of livecd-setlocale (kbd bits)
CONFIG=/etc/sysconfig/keyboard
# Requires: console-scripts
if [ -s "$CONFIG" ]; then
echo "** l10n-kbd: expected $CONFIG to be an empty file" >&2
exit 0
fi
if [ -z "$GLOBAL_KEYTABLE" ]; then
echo "** l10n-kbd: empty GLOBAL_KEYTABLE" >&2
exit 0
fi
echo "KEYTABLE=$GLOBAL_KEYTABLE" > "$CONFIG"
#!/bin/sh
# partial port of livecd-setlocale (xkb bits)
PREFIX=/etc/X11/xinit
# Requires: xinitrc
if [ ! -d "$PREFIX" ]; then
echo "** l10n-xkb: expected $PREFIX to exist (xinitrc)" >&2
exit 0
fi
if [ -z "$GLOBAL_XKB_VARIANTS" -o -z "$GLOBAL_XKB_KEYMAPS" ]; then
echo "** l10n-xkb: empty GLOBAL_XKB_VARIANTS/GLOBAL_XKB_KEYMAPS" >&2
exit 0
fi
echo "-option $GLOBAL_XKB_SWITCH${GLOBAL_XKB_LED:+,$GLOBAL_XKB_LED} \
${GLOBAL_XKB_VARIANTS:+-variant $GLOBAL_XKB_VARIANTS} \
-layout $GLOBAL_XKB_KEYMAPS" > "$PREFIX"/Xkbmap
# supplement live with keyboard layout setup
XKB_KEYMAPS := $(subst $(SPACE),$(COMMA),$(XKB_KEYMAPS))
# handle the layouts with a specific variant in the wild
XKB_VARIANTS := $(subst ru,winkeys, \
$(subst ua,winkeys, \
$(subst be,winkeys, \
$(subst us,,$(XKB_KEYMAPS)))))
debug::
@echo "** live: LOCALES: $(LOCALES)"
@echo "** live: LOCALE: $(LOCALE)"
@echo "** live: XKB_KEYMAPS: $(XKB_KEYMAPS)"
@echo "** live: XKB_VARIANTS: $(XKB_VARIANTS)"
......@@ -42,7 +42,7 @@ use/live/x11: use/live/base use/syslinux/localboot.cfg \
# this target specifically pulls free xorg drivers in (and a few more bits);
# a browser is requested too, the recommended one can be overridden downstream
use/live/desktop: use/live/x11 use/x11/xorg use/x11/wacom \
use/browser/firefox/live use/xdg-user-dirs/deep +vmguest; @:
use/l10n use/browser/firefox/live use/xdg-user-dirs/deep +vmguest; @:
# preconfigure apt for both live and installed-from-live systems
use/live/repo: use/live
......@@ -78,6 +78,8 @@ use/live/nodm: use/live/.x11
use/live/hooks: use/live
@$(call add,LIVE_PACKAGES,livecd-run-hooks)
# a crude hack to make sure Russian is supported in a particular image
use/live/ru: use/live
@$(call add,LIVE_PACKAGES,livecd-ru)
# a crude hack to make sure Russian is the default in a particular image
use/live/ru: use/live use/l10n/default/ru_RU; @:
use/live/sound: use/live
@$(call add,LIVE_PACKAGES,amixer alsa-utils aplay udev-alsa)
......@@ -19,6 +19,7 @@ map = $(foreach a,$(2),$(call $(1),$(a)))
# kernel package list generation; see also #24669
NULL :=
SPACE := $(NULL) # the officially documented way of getting a space
COMMA := ,
list2re = $(subst $(SPACE),|,$(strip $(1)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment