5 # initramfs-tools header
21 # live-initramfs header
23 . /scripts/live-functions
25 log_begin_msg "Setting up locales..."
27 # live-initramfs script
29 if [ -e /root/etc/default/locale ]; then
30 grep_file=/root/etc/default/locale
31 elif [ -e /root/etc/environment ]; then # Old locales policy
32 grep_file=/root/etc/environment
35 if [ -n "${grep_file}" ]; then
36 # use rootfs configured locale
37 locale=$(grep -s 'LANG=' ${grep_file} | sed s/'LANG='// | tr -d '"' )
39 grep_file=/root/etc/default/locale
42 if [ -n "${LOCALE}" ]; then
47 if [ -z "${locale}" ]; then
53 if [ "${set_locale}" ]; then
54 if echo "${locale}" | grep -sqE '^[[:lower:]]{2}$' ; then
55 # input is like "locale=it", so we will convert and setup also the keyboard if not already set
56 if [ -z "${KBD}" ]; then
57 # FIXME: look if this keyb is supported
61 uploc=$(echo "${locale}" | tr '[a-z]' '[A-Z]')
62 locale="${locale}_${uploc}.UTF-8"
64 LANG=$(grep "^${locale}" /root/usr/share/i18n/SUPPORTED | grep UTF-8 |sed -e 's, .*,,' -e q)
65 if [ -z "${LANG}" ]; then
66 log_warning_message "Locale ${locale} is unsupported."
73 if [ "${BUILD_SYSTEM}" == "Ubuntu" ]; then
74 printf 'LANG="%s"\n' "${LANG}" > "${grep_file}"
75 chroot /root /usr/sbin/locale-gen "${LANG}"
76 live-preseed /root debian-installer/locale "${locale}"
78 printf 'LANG=%s\n' "${LANG}" > "${grep_file}"
79 printf '%s UTF-8\n' "${LANG}" > /root/etc/locale.gen
80 chroot /root /usr/sbin/locale-gen