r2702 - in glibc-package/trunk/debian: . debhelper.in rules.d
Author: aurel32
Date: 2007-11-26 17:43:39 +0000 (Mon, 26 Nov 2007)
New Revision: 2702
Modified:
glibc-package/trunk/debian/changelog
glibc-package/trunk/debian/debhelper.in/locales.config
glibc-package/trunk/debian/debhelper.in/locales.postinst
glibc-package/trunk/debian/rules.d/debhelper.mk
Log:
* debhelper.in/locales.config, debhelper.in/locales.postinst,
rules.d/debhelper.mk: rework the maintainer scripts of locales to handle
locales addition or removal.
* debhelper.in/locales.config: convert no_NO into nb_NO while upgrading.
Closes: #452788.
Modified: glibc-package/trunk/debian/changelog
===================================================================
--- glibc-package/trunk/debian/changelog 2007-11-26 17:24:38 UTC (rev 2701)
+++ glibc-package/trunk/debian/changelog 2007-11-26 17:43:39 UTC (rev 2702)
@@ -9,8 +9,13 @@
packages.
* any/cvs-tzfile.diff: new patch from CVS to fix reading version 0 timezone
data files. Closes: #451892.
+ * debhelper.in/locales.config, debhelper.in/locales.postinst,
+ rules.d/debhelper.mk: rework the maintainer scripts of locales to handle
+ locales addition or removal.
+ * debhelper.in/locales.config: convert no_NO into nb_NO while upgrading.
+ Closes: #452788.
- -- Aurelien Jarno <aurel32@debian.org> Mon, 26 Nov 2007 16:20:36 +0100
+ -- Aurelien Jarno <aurel32@debian.org> Mon, 26 Nov 2007 18:43:25 +0100
glibc (2.7-1) unstable; urgency=low
Modified: glibc-package/trunk/debian/debhelper.in/locales.config
===================================================================
--- glibc-package/trunk/debian/debhelper.in/locales.config 2007-11-26 17:24:38 UTC (rev 2701)
+++ glibc-package/trunk/debian/debhelper.in/locales.config 2007-11-26 17:43:39 UTC (rev 2702)
@@ -1,39 +1,38 @@
-#!/bin/sh
+#! /bin/sh
set -e
. /usr/share/debconf/confmodule
db_version 2.0
db_capb backup multiselect
-# Initializes debconf default values from the ones found in
-# configuration files
+# List of locales supported by the current version
+SUPPORTED_LOCALES="__SUPPORTED_LOCALES__"
+
+# Get the list of selected locales from /etc/locale.gen
SELECTED_LOCALES=
if [ -L /etc/locale.gen ] && [ "$(readlink /etc/locale.gen)" = /usr/share/i18n/SUPPORTED ]; then
SELECTED_LOCALES="All locales"
- LG=/dev/null
elif [ -e /etc/locale.gen ]; then
- LG=/etc/locale.gen
- # Debconf templates in locales < 2.3.2 were completely different,
- # the locales/locales_to_be_generated question could have a "Leave alone"
- # value in which case locale-gen was not run.
- # With current implementation, this string has to be removed.
- grep -q "Leave alone" $LG && sed -e '/^Leave alone/d' $LG > $LG.tmp && mv $LG.tmp $LG
-
- SELECTED_LOCALES=$(LC_ALL=C sed -e '/^[a-zA-Z]/!d' $LG | tr '\n' ',' | sed -e 's/,/, /g' -e 's/, *$//')
-else
- LG=/dev/null
+ SELECTED_LOCALES=$(LC_ALL=C sed -e '/^[a-zA-Z]/!d' -e "s/^ *//g" -e 's/ *$//g' -e 's/no_NO/nb_NO/' /etc/locale.gen | sort -u | while read LINE ; do
+ if echo "$SUPPORTED_LOCALES" | grep -q -e "\b$LINE\b" ; then
+ echo -n "$LINE, "
+ fi
+ done)
+ SELECTED_LOCALES=${SELECTED_LOCALES%%, }
fi
+
DEFAULT_ENVIRONMENT=$(cat /etc/environment /etc/default/locale 2>/dev/null | awk 'BEGIN {lang="None"} /^LANG=/ {gsub("\"", ""); sub("LANG=", ""); lang=$0;} END {print lang}')
-[ -n "$DEFAULT_ENVIRONMENT" ] || DEFAULT_ENVIRONMENT=None
-# Add a newline in case /etc/locale.gen has no trailing newline at EOF
-SUPPORTED_LOCALES="
-__SUPPORTED_LOCALES__"
-SUPPORTED_LOCALES=$( (cat $LG && echo "$SUPPORTED_LOCALES") | LC_ALL=C sed -e '/^[a-zA-Z]/!d' | LC_ALL=C sort -u | tr '\n' ',' | sed -e 's/,/, /g' -e 's/, *$//')
+# Convert no_NO locales to nb_NO
+DEFAULT_ENVIRONMENT=$(echo "$DEFAULT_ENVIRONMENT" | sed -e "s/no_NO/nb_NO/")
-if [ -z "$DEBCONF_IS_A_REGISTRY" ] && [ -e /etc/locale.gen ]; then
+if ! echo "$SUPPORTED_LOCALES" | grep -q -e "\b$DEFAULT_ENVIRONMENT\b" ; then
+ DEFAULT_ENVIRONMENT=None
+fi
+
+if [ -e /etc/locale.gen ]; then
db_set locales/locales_to_be_generated "${SELECTED_LOCALES}"
- db_set locales/default_environment_locale "$DEFAULT_ENVIRONMENT"
+ db_set locales/default_environment_locale "${DEFAULT_ENVIRONMENT}"
fi
db_subst locales/locales_to_be_generated locales "${SUPPORTED_LOCALES}"
Modified: glibc-package/trunk/debian/debhelper.in/locales.postinst
===================================================================
--- glibc-package/trunk/debian/debhelper.in/locales.postinst 2007-11-26 17:24:38 UTC (rev 2701)
+++ glibc-package/trunk/debian/debhelper.in/locales.postinst 2007-11-26 17:43:39 UTC (rev 2702)
@@ -1,31 +1,25 @@
#! /bin/sh
-set -e
+set -e
LG="/etc/locale.gen"
EE="/etc/default/locale"
+# List of locales supported by the current version
+SUPPORTED_LOCALES="__SUPPORTED_LOCALES__"
+
if [ "$1" = configure ]; then
. /usr/share/debconf/confmodule
db_version 2.0
db_get locales/locales_to_be_generated && SELECTED_LOCALES=$RET
- db_get locales/default_environment_locale && SELECTED="$RET"
+ db_get locales/default_environment_locale && DEFAULT_ENVIRONMENT="$RET"
- if [ -n "$SELECTED_LOCALES" ]; then
- if [ "$SELECTED_LOCALES" = "All locales" ]; then
- [ -e $LG ] && rm -f $LG
- ln -s /usr/share/i18n/SUPPORTED $LG
- else
- [ -L $LG ] && [ "$(readlink $LG)" = /usr/share/i18n/SUPPORTED ] && rm -f $LG
- if [ -e $LG ]; then
- # Comment previous defined locales
- LC_ALL=C sed -e 's/^[a-zA-Z]/#&/' $LG > $LG.tmp || true
- mv -f $LG.tmp $LG
- last=`tail -n 1 "$LG"`
- if test -n "$last"; then echo >> $LG; fi
- else
- cat > $LG << EOF
+ if [ "$SELECTED_LOCALES" = "All locales" ]; then
+ [ -e $LG ] && rm -f $LG
+ ln -s /usr/share/i18n/SUPPORTED $LG
+ else
+ cat > $LG << EOF
# This file lists locales that you wish to have built. You can find a list
# of valid supported locales at /usr/share/i18n/SUPPORTED. Other
# combinations are possible, but may not be well tested. If you change
@@ -33,32 +27,16 @@
#
EOF
+ IFS=","
+ for LOCALE in $SUPPORTED_LOCALES ; do
+ LOCALE=${LOCALE## }
+ if echo "$SELECTED_LOCALES" | grep -q "\b$LOCALE\b" ; then
+ echo "$LOCALE" >> $LG
+ else
+ echo "# $LOCALE" >> $LG
fi
- list=`echo $SELECTED_LOCALES | sed -e 's/, /,/g'`
- save_IFS=$IFS
- IFS=,
- for locale in $list; do
- if grep -q "^$locale *\$" $LG; then
- # This locale has already been inserted, do nothing
- :
- elif grep -q "^#$locale *\$" $LG; then
- # Uncomment previous defined locales
- sed -e "s,#$locale *\$,$locale," $LG > $LG.tmp || true
- mv -f $LG.tmp $LG
- else
- # Add a new locale
- echo $locale >> $LG
- fi
- done
- IFS=$save_IFS
- fi
- else
- if [ -L $LG ]; then
- rm -f $LG
- elif [ -e $LG ]; then
- LC_ALL=C sed -e 's/^[a-zA-Z]/#&/' $LG > $LG.tmp || true
- mv -f $LG.tmp $LG
- fi
+ done
+ IFS=" "
fi
# Update requested locales if locales-all is not installed
if [ -f /usr/lib/locales-all/supported.tar.lzma ] ; then
@@ -72,8 +50,8 @@
# Remove previous definitions
/usr/sbin/update-locale --no-checks LANG
fi
- if [ -n "$SELECTED" ] && [ "$SELECTED" != "None" ]; then
- /usr/sbin/update-locale "LANG=$SELECTED"
+ if [ -n "$DEFAULT_ENVIRONMENT" ] && [ "$DEFAULT_ENVIRONMENT" != "None" ]; then
+ /usr/sbin/update-locale "LANG=$DEFAULT_ENVIRONMENT"
fi
fi
Modified: glibc-package/trunk/debian/rules.d/debhelper.mk
===================================================================
--- glibc-package/trunk/debian/rules.d/debhelper.mk 2007-11-26 17:24:38 UTC (rev 2701)
+++ glibc-package/trunk/debian/rules.d/debhelper.mk 2007-11-26 17:43:39 UTC (rev 2702)
@@ -225,7 +225,8 @@
done
# Substitute __SUPPORTED_LOCALES__.
- perl -i -pe 'BEGIN {undef $$/; open(IN, "debian/tmp-libc/usr/share/i18n/SUPPORTED"); $$j=<IN>;} s/__SUPPORTED_LOCALES__/$$j/g;' debian/locales.config
+ SUPPORTED_LOCALES=$$(cat debian/tmp-libc/usr/share/i18n/SUPPORTED | tr '\n' ',' | sed -e 's/,/, /g' -e 's/, *$$//') ; \
+ sed -i -e "s/__SUPPORTED_LOCALES__/$$SUPPORTED_LOCALES/" debian/locales.config debian/locales.postinst
# Generate common substvars files.
echo "locale:Depends=$(shell perl debian/debver2localesdep.pl $(LOCALES_DEP_VER))" > tmp.substvars
Reply to: