summaryrefslogtreecommitdiff
path: root/core/glibc/locale-gen
diff options
context:
space:
mode:
authorroot <root@rshg054.dnsready.net>2013-10-26 01:22:45 -0700
committerroot <root@rshg054.dnsready.net>2013-10-26 01:22:45 -0700
commit24152c3ea77087edccf017c13d44904a75799ff7 (patch)
tree65e25106816e5071dd5b2edc2270e0138c23dc7c /core/glibc/locale-gen
parent5a3821aec094b38a412cf5e6997c08b6428d6f77 (diff)
Sat Oct 26 01:21:13 PDT 2013
Diffstat (limited to 'core/glibc/locale-gen')
-rwxr-xr-xcore/glibc/locale-gen60
1 files changed, 37 insertions, 23 deletions
diff --git a/core/glibc/locale-gen b/core/glibc/locale-gen
index 5aff344c4..51191f810 100755
--- a/core/glibc/locale-gen
+++ b/core/glibc/locale-gen
@@ -4,39 +4,53 @@ set -e
LOCALEGEN=/etc/locale.gen
LOCALES=/usr/share/i18n/locales
-if [ -n "$POSIXLY_CORRECT" ]; then
- unset POSIXLY_CORRECT
-fi
+unset POSIXLY_CORRECT
-
-[ -f $LOCALEGEN -a -s $LOCALEGEN ] || exit 0;
+[ -s "$LOCALEGEN" ] || exit 0
# Remove all old locale dir and locale-archive before generating new
# locale data.
-rm -rf /usr/lib/locale/* || true
+rm -rf /usr/lib/locale/*
umask 022
-is_entry_ok() {
- if [ -n "$locale" -a -n "$charset" ] ; then
- true
- else
- echo "error: Bad entry '$locale $charset'"
- false
- fi
+gen() {
+ local locale=$1
+ local charset=$2
+ local input=
+
+ if [ -z "$locale" ] || [ -z "$charset" ]; then
+ echo "error: Bad entry '$locale $charset'"
+ return
+ fi
+
+ printf ' %s.%s\n' "$(echo "$locale" | sed 's/\([^.\@]*\).*/\1/')" "$charset"
+
+ if [ -f "$LOCALES/$locale" ]; then
+ input=$locale
+ else
+ input=$(echo $locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/')
+ fi
+
+ localedef -i "$input" -c -f "$charset" -A /usr/share/locale/locale.alias "$locale"
}
+maxjobs=$(grep -c processor /proc/cpuinfo 2>/dev/null || echo 1)
echo "Generating locales..."
while read locale charset; do \
- case $locale in \#*) continue;; "") continue;; esac; \
- is_entry_ok || continue
- echo -n " `echo $locale | sed 's/\([^.\@]*\).*/\1/'`"; \
- echo -n ".$charset"; \
- echo -n `echo $locale | sed 's/\([^\@]*\)\(\@.*\)*/\2/'`; \
- echo -n '...'; \
- if [ -f $LOCALES/$locale ]; then input=$locale; else \
- input=`echo $locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; fi; \
- localedef -i $input -c -f $charset -A /usr/share/locale/locale.alias $locale; \
- echo ' done'; \
+ case $locale in
+ \#*|'')
+ continue
+ ;;
+ esac
+ gen "$locale" "$charset" &
+
+ # keep no more than $maxjobs jobs in flight
+ while [ $(jobs | wc -l) -ge $maxjobs ]; do
+ sleep 0.25
+ jobs >/dev/null
+ done
done < $LOCALEGEN
+wait
+
echo "Generation complete."