Rework locale handling
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 25-locales
1 #!/bin/sh
2 # Filename:      /etc/grml/fai/config/scripts/GRMLBASE/25-locales
3 # Purpose:       locales (language) configuration of the live system
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2 or any later version.
7 ################################################################################
8
9 set -e
10
11 if [ -z "$ROOTCMD" ] ; then
12    echo "variable \$ROOTCMD not set, exiting to avoid any possible damage">&2
13    exit 1
14 fi
15
16 # use full locales setup only in classes GRML_FULL and LOCALES
17 if ifclass GRML_FULL || ifclass LOCALES ; then
18    echo 'Using /etc/locale.gen.grml for locales generation'
19    cp $target/etc/locale.gen.grml $target/etc/locale.gen
20 else
21    echo 'Using /etc/locale.gen.minimal for locales generation'
22    cp $target/etc/locale.gen.minimal $target/etc/locale.gen
23 fi
24
25 # make sure:
26 # localepurge     localepurge/nopurge     multiselect ....
27 # is set so localepurge works as expected
28 if [ -x $target/usr/sbin/localepurge ] ; then
29    $ROOTCMD dpkg-reconfigure -f noninteractive localepurge
30 fi
31
32 if [ -x $target/usr/sbin/locale-gen ] ; then
33    $ROOTCMD locale-gen
34 else
35    echo 'Warning: locale-gen [package locales] not available'
36 fi
37
38 if [ -x $target/usr/sbin/localepurge ] ; then
39    $ROOTCMD localepurge
40 fi
41
42 # get rid of LC_MESSAGES unless using class LOCALES
43 if ! ifclass LOCALES ; then
44    echo 'Removing /usr/share/locale'
45    $ROOTCMD rm -rf /usr/share/locale
46    $ROOTCMD mkdir /usr/share/locale
47    # TODO: /usr/share/i18n/locales
48 fi
49
50 ## END OF FILE #################################################################
51 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3