[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#281538: languagechooser: [s390] Invalid setup of localization



tags 281538 + patch
thanks

I would like to propose the attached patch.

I have tested it during another s390 installation by manually running the 
script in various variants:
- with and without locales installed
- for locale C
- for locales en_US, nl_NL@euro

Christian: could you have a critical look at the patch?

--
Cheers,
FJP

--- prebaseconfig	2004-10-31 15:23:19.000000000 +0100
+++ prebaseconfig.new	2004-11-17 17:52:12.000000000 +0100
@@ -1,8 +1,14 @@
-#! /bin/sh -e
+#! /bin/sh
+
+set -e
 
 . /usr/share/debconf/confmodule
 
-LOG=/var/log/messages
+MSGLOG=/var/log/messages
+
+log() {
+    logger -t prebaseconfig "$@"
+}
 
 modify_cyrconfig() {
         if [ "$2" ]; then
@@ -61,43 +67,63 @@
     ;;
 esac
  
-# Pass the language/locale information needed by base-config into
-# /target/root/dbootstrap_settings.
-# This exists only to support installing woody (skolelinux, etc)
+# Determine the locale and language list set for the installation
 
 db_get debian-installer/locale
 LOCALE="$RET"
 
+# Set locale to C if it has not yet been set
+# This can happen during e.g. s390 installs where localechooser is not run
+[ -z "$LOCALE" ] && LOCALE="C"
+
 db_get debian-installer/language
 LANGLIST="$RET"
 
+# Pass the language/locale information needed by base-config into
+# /target/root/dbootstrap_settings.
+# This exists only to support installing woody (skolelinux, etc)
+
 if [ ! -d /target/root ] ; then
     if mkdir /target/root ; then
         :
     else
-        echo "error: unable to create /target/root"
+        log "Error: unable to create /target/root"
     fi
 fi
 
-(
-    echo "# Inserted by languagechooser."
-    echo "LANG_INST=\"$LOCALE\""
-    echo "LANGUAGE_INST=\"$LANGLIST\""
-) >> /target/root/dbootstrap_settings
+DESTFILE="/target/root/dbootstrap_settings"
+echo "# Inserted by languagechooser." > $DESTFILE
+echo "LANG_INST=\"$LOCALE\"" >> $DESTFILE
+if [ -n "$LANGLIST" ] ; then
+    echo "LANGUAGE_INST=\"$LANGLIST\"" >> $DESTFILE
+fi
 
 # Set global locale and language, and make sure the glibc locale is
 # generated.  This task is also done in termwrap and base-config, and
 # should probably be removed from there when this part work.
-(
-    echo "LANG=\"$LOCALE\""
-    echo "LANGUAGE=\"$LANGLIST\""
-) >> /target/etc/environment
-# If the locale isn't already valid, append it to locale.gen
-if chroot /target/ /usr/sbin/validlocale $LOCALE \
-    >> /target/etc/locale.gen 2>> $LOG ; then
-    : # Nothing to do
-else
-    # New locale added to locale.gen, generate it
-    chroot /target /usr/sbin/locale-gen >> $LOG 2>&1
+DESTFILE="/target/etc/environment"
+echo "LANG=\"$LOCALE\"" > $DESTFILE
+if [ -n "$LANGLIST" ] ; then
+    echo "LANGUAGE=\"$LANGLIST\"" >> $DESTFILE
 fi
 
+# If the locale isn't already valid, append it to /etc/locale.gen
+set +e
+GEN_LOCALE=$(chroot /target/ /usr/sbin/validlocale "$LOCALE" 2>> $MSGLOG)
+RESULT="$?"
+set -e
+
+case "$RESULT" in
+    0)
+        : # Nothing to do
+        ;;
+    1)
+        # Add new locale to locale.gen, generate it
+        echo $GEN_LOCALE >> /target/etc/locale.gen
+        chroot /target /usr/sbin/locale-gen >> $MSGLOG 2>&1
+        ;;
+    *)
+        log "Error running validlocale \"$LOCALE\": $RESULT"
+        exit 1
+        ;;
+esac

Reply to: