]>
Commit | Line | Data |
---|---|---|
38b77968 JB |
1 | #!/bin/sh |
2 | ||
3 | SUPPORTED_LOCALES=x | |
4 | OLD_STYLE="no" | |
5 | DESTDIR= | |
6 | ||
7 | [ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n | |
37cd6ebc | 8 | [ -f /etc/sysconfig/localedb ] && . /etc/sysconfig/localedb |
38b77968 | 9 | |
09df111e | 10 | LOCDIR=/usr/lib/locale |
38b77968 JB |
11 | ARCHIVE=${LOCDIR}/locale-archive |
12 | ||
13 | while [ $# -gt 0 ]; do | |
14 | case $1 in | |
15 | -l=* | --locales=*) | |
16 | SUPPORTED_LOCALES="`echo $1 | sed -e 's/^[^=]*=//'`" | |
17 | ;; | |
18 | -l | --locales) | |
19 | SUPPORTED_LOCALES="$2" | |
20 | shift | |
21 | ;; | |
22 | -o | --old-style) | |
23 | OLD_STYLE="yes" | |
24 | ;; | |
25 | -d=* | --destdir=*) | |
26 | DESTDIR="`echo $1 | sed -e 's/^[^]]*=//'`" | |
27 | ;; | |
28 | -d | --destdir) | |
29 | DESTDIR="$2" | |
30 | shift | |
31 | ;; | |
32 | -h | --help | --usage) | |
33 | cat <<EOF | |
34 | Usage: localedb-gen [-l|--locales <locales>] [-o|--old-style] | |
35 | [-d|--destdir <DESTDIR>] | |
36 | localedb-gen [-h|--help|--usage] | |
37 | EOF | |
38 | exit | |
39 | ;; | |
40 | *) | |
41 | echo "Unrecognized option: $1" | |
42 | exit 1 | |
43 | ;; | |
44 | esac | |
45 | shift | |
46 | done | |
47 | ||
48 | if [ "${SUPPORTED_LOCALES}" = "x" ]; then | |
49 | echo "SUPPORTED_LOCALES not set" | |
37566d3b | 50 | echo "You can set it in /etc/sysconfig/i18n file" |
38b77968 JB |
51 | exit 1 |
52 | fi | |
53 | ||
54 | if [ "${DESTDIR}" = "" ] && rpm -qf ${ARCHIVE} >/dev/null 2>&1 ; then | |
55 | echo "${ARCHIVE} belongs to `rpm -qf ${ARCHIVE}` package - uninstall it first!" | |
56 | exit 1 | |
57 | fi | |
58 | ||
59 | rm -rf ${DESTDIR}${LOCDIR} | |
60 | install -d ${DESTDIR}${LOCDIR} | |
c6d84547 | 61 | cd ${DESTDIR}${LOCDIR} |
38b77968 JB |
62 | |
63 | if [ "${DESTDIR}" = "" ]; then | |
64 | DESTDIROPT= | |
65 | else | |
66 | DESTDIROPT="--prefix ${DESTDIR}" | |
67 | fi | |
68 | ||
e54f46e7 | 69 | rc=0 |
38b77968 JB |
70 | for loc in ${SUPPORTED_LOCALES} ; do |
71 | if echo ${loc} | grep -q / ; then | |
72 | chset="`echo ${loc} | sed -e 's@^.*/@@'`" | |
73 | loc="`echo ${loc} | sed -e 's@/.*$@@'`" | |
74 | elif echo ${loc} | grep -q '\.' ; then | |
75 | chset="`echo ${loc} | sed -e 's@^.*\.@@'`" | |
76 | elif grep -qs "^${loc}/[^ ]* .*$" /usr/share/i18n/SUPPORTED ; then | |
37cd6ebc | 77 | chset="`grep \"^${loc}/.* .*$\" /usr/share/i18n/SUPPORTED | sed -e 's@^.*/\([^ ]*\) .*$@\1@'`" |
38b77968 JB |
78 | else |
79 | echo "Charset not known for locale ${loc} - skipping..." | |
80 | continue | |
81 | fi | |
37566d3b | 82 | iloc="`echo ${loc} | sed -e 's/\.[^@]*//'`" |
38b77968 JB |
83 | echo -n "Generating ${loc} using charset ${chset}... " |
84 | if [ "${OLD_STYLE}" = "yes" ]; then | |
37566d3b | 85 | localedef -f ${chset} -i ${iloc} ${DESTDIR}${LOCDIR}${loc} |
38b77968 | 86 | else |
37566d3b | 87 | localedef -f ${chset} -i ${iloc} ${loc} ${DESTDIROPT} |
38b77968 | 88 | fi |
e54f46e7 | 89 | rc=$(($rc + $?)) |
38b77968 JB |
90 | echo |
91 | done | |
92 | ||
93 | echo "DONE." | |
e54f46e7 | 94 | exit $rc |