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

r2122 - tzdata/trunk/debian



Author: aurel32
Date: 2007-04-24 20:40:28 +0000 (Tue, 24 Apr 2007)
New Revision: 2122

Modified:
   tzdata/trunk/debian/config
   tzdata/trunk/debian/postinst
Log:
Completely rewrite the config script to handle all cases


Modified: tzdata/trunk/debian/config
===================================================================
--- tzdata/trunk/debian/config	2007-04-24 18:06:11 UTC (rev 2121)
+++ tzdata/trunk/debian/config	2007-04-24 20:40:28 UTC (rev 2122)
@@ -5,38 +5,52 @@
 db_version 2.0
 db_capb backup
 
-# If /etc/localtime is a symlink, try to read where it points to.
-if [ -L /etc/localtime ] ; then
-    TIMEZONE=$(readlink /etc/localtime | sed 's%^/usr/share/zoneinfo/%%')
+# Read /etc/timezone
+if [ -e /etc/timezone ] ; then
+    TZ_TIMEZONE=$(head -n 1 /etc/timezone | sed -e "s/ .*//")
+    if ! [ -f "/usr/share/zoneinfo/$TZ_TIMEZONE" ] ; then
+        TZ_TIMEZONE=""
+    fi
 fi
 
-# If /etc/localtime is not a symlink, or if it is a dangling symlink, 
-# try to read /etc/timezone.
-if ! [ -f "/usr/share/zoneinfo/$TIMEZONE" ] && [ -f /etc/timezone ] ; then
-    TIMEZONE=$(head -n 1 /etc/timezone | sed -e "s/ .*//")
-
-    # Fix the timezone for some common cases
-    if [ "$TIMEZONE" = "UTC" ] ; then
-        TIMEZONE=Etc/UTC
+# Read /etc/localtime
+if [ -L /etc/localtime ] ; then
+    TZ_LOCALTIME=$(readlink /etc/localtime | sed 's%^/usr/share/zoneinfo/%%')
+elif [ -f /etc/localtime ] && [ -n "$TZ_TIMEZONE" ] ; then
+    if cmp -s /etc/localtime /usr/share/zoneinfo/$TZ_TIMEZONE ; then
+        TZ_LOCALTIME=$TZ_TIMEZONE
     fi
 fi
 
-# If $TIMEZONE contains a correct timezone, don't show the debconf template
-# again. Except if the user explicitely ask to do so (via dpkg-reconfigure).
-if [ -f "/usr/share/zoneinfo/$TIMEZONE" ] ; then
-    AREA=$(echo $TIMEZONE | sed 's%/.*$%%')
-    ZONE=$(echo $TIMEZONE | sed 's%^.*/%%')
+# The timezone has never been configured or is falsely configured
+if ! [ -e /etc/localtime ] ; then
+    if [ -n "$TZ_TIMEZONE" ] ; then
+        AREA=$(echo $TZ_TIMEZONE | sed 's%/.*$%%')
+        ZONE=$(echo $TZ_TIMEZONE | sed 's%^.*/%%')
+    else
+        AREA="Etc"
+	ZONE="UTC"
+        db_fset tzdata/Areas seen false
+        db_fset tzdata/Zones/Etc seen false
+    fi
+# The user want to handle the timezone by him/herself
+elif [ -z "$TZ_LOCALTIME" ] ; then
+    if [ "$1" = "reconfigure" ] || [ -n "$DEBCONF_RECONFIGURE" ] ; then
+        AREA="Etc"
+	ZONE="UTC"
+    else
+        echo "User defined" > /etc/timezone
+	exit 0
+    fi
+# The timezone has already been configured
+else
+    AREA=$(echo $TZ_LOCALTIME | sed 's%/.*$%%')
+    ZONE=$(echo $TZ_LOCALTIME | sed 's%^.*/%%')
+    # Don't ask the user, except if he/she explicitely asked that
     if [ "$1" != "reconfigure" ] && [ -z "$DEBCONF_RECONFIGURE" ] ; then
         db_fset tzdata/Areas seen true
         db_fset tzdata/Zones/$AREA seen true
     fi
-# If the user prefers to manage the timezone by itself, let him doing that.
-elif [ -f /etc/localtime ] ; then
-    exit 0
-# Otherwise just default to an UTC timezone and show the debconf template.
-else
-    AREA=Etc
-    ZONE=UTC
 fi
 
 # Initializes debconf default values from the ones found in
@@ -64,6 +78,9 @@
         db_input high tzdata/Zones/$RET || true
         ;;
     *)
+        if grep -q "^User defined$" /etc/timezone 2>/dev/null ; then
+            rm -f /etc/timezone
+        fi
         break
         ;;
     esac

Modified: tzdata/trunk/debian/postinst
===================================================================
--- tzdata/trunk/debian/postinst	2007-04-24 18:06:11 UTC (rev 2121)
+++ tzdata/trunk/debian/postinst	2007-04-24 20:40:28 UTC (rev 2122)
@@ -5,17 +5,18 @@
 LANG=C
 umask 022
 
+. /usr/share/debconf/confmodule
+db_version 2.0
+
 if [ "$1" = configure ]; then
     # If the user prefers to manage the timezone by itself, let him doing that.
-    if [ -f /etc/localtime ] && \
-       ! [ -f "/usr/share/zoneinfo/$(head -n 1 /etc/timezone | sed -e "s/ .*//")" ] ; then
+    if grep -q "^User defined$" /etc/timezone 2>/dev/null ; then
+        db_stop
         echo
-	echo "User defined timezone, leaving /etc/localtime unchanged."
+        echo "User defined timezone, leaving /etc/localtime unchanged."
         echo "Run 'dpkg-reconfigure tzdata' if you wish to change it."
 	echo
     else
-        . /usr/share/debconf/confmodule
-        db_version 2.0
     
         # Get the values from debconf
         AREA=Etc



Reply to: