]> git.pld-linux.org Git - packages/glibc.git/blob - glibc-localedb-gen
acaca342c843e7355243ac7c82f6ead21a89cc1e
[packages/glibc.git] / glibc-localedb-gen
1 #!/bin/sh
2
3 SUPPORTED_LOCALES=x
4 OLD_STYLE="no"
5 DESTDIR=
6
7 [ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
8 [ -f /etc/sysconfig/localedb ] && . /etc/sysconfig/localedb
9
10 LOCDIR=/usr/lib/locale
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"
50         exit 1
51 fi
52
53 if [ "${DESTDIR}" = "" ] && rpm -qf ${ARCHIVE} >/dev/null 2>&1 ; then
54         echo "${ARCHIVE} belongs to `rpm -qf ${ARCHIVE}` package - uninstall it first!"
55         exit 1
56 fi
57
58 rm -rf ${DESTDIR}${LOCDIR}
59 install -d ${DESTDIR}${LOCDIR}
60
61 if [ "${DESTDIR}" = "" ]; then
62         DESTDIROPT=
63 else
64         DESTDIROPT="--prefix ${DESTDIR}"
65 fi
66
67 for loc in ${SUPPORTED_LOCALES} ; do
68         if echo ${loc} | grep -q / ; then
69                 chset="`echo ${loc} | sed -e 's@^.*/@@'`"
70                 loc="`echo ${loc} | sed -e 's@/.*$@@'`"
71         elif echo ${loc} | grep -q '\.' ; then
72                 chset="`echo ${loc} | sed -e 's@^.*\.@@'`"
73         elif grep -qs "^${loc}/[^ ]* .*$" /usr/share/i18n/SUPPORTED ; then
74                 chset="`grep \"^${loc}/.* .*$\" /usr/share/i18n/SUPPORTED | sed -e 's@^.*/\([^ ]*\) .*$@\1@'`"
75         else
76                 echo "Charset not known for locale ${loc} - skipping..."
77                 continue
78         fi
79         echo -n "Generating ${loc} using charset ${chset}... "
80         if [ "${OLD_STYLE}" = "yes" ]; then
81                 localedef -f ${chset} -i ${loc} ${DESTDIR}${LOCDIR}${loc}
82         else
83                 localedef -f ${chset} -i ${loc} ${loc} ${DESTDIROPT}
84         fi
85         echo
86 done
87
88 echo "DONE."
This page took 0.029999 seconds and 3 git commands to generate.