r2086 - tzdata/trunk/debian
Author: aurel32
Date: 2007-04-17 10:15:52 +0000 (Tue, 17 Apr 2007)
New Revision: 2086
Modified:
tzdata/trunk/debian/changelog
tzdata/trunk/debian/config
tzdata/trunk/debian/postinst
Log:
* Don't overwrite /etc/localtime if the user choose to manage it by
him/herself.
Modified: tzdata/trunk/debian/changelog
===================================================================
--- tzdata/trunk/debian/changelog 2007-04-17 09:52:30 UTC (rev 2085)
+++ tzdata/trunk/debian/changelog 2007-04-17 10:15:52 UTC (rev 2086)
@@ -3,8 +3,10 @@
* Don't ask debconf questions during the first upgrade if the timezone
is already configured (closes: bug#419276).
* Set the old timezone in case of cancellation (closes: bug#419344).
+ * Don't overwrite /etc/localtime if the user choose to manage it by
+ him/herself.
- -- Aurelien Jarno <aurel32@debian.org> Sun, 15 Apr 2007 20:03:24 +0200
+ -- Aurelien Jarno <aurel32@debian.org> Tue, 17 Apr 2007 12:12:24 +0200
tzdata (2007e-3) unstable; urgency=low
Modified: tzdata/trunk/debian/config
===================================================================
--- tzdata/trunk/debian/config 2007-04-17 09:52:30 UTC (rev 2085)
+++ tzdata/trunk/debian/config 2007-04-17 10:15:52 UTC (rev 2086)
@@ -5,17 +5,24 @@
db_version 2.0
db_capb backup
-# Initializes debconf default values from the ones found in
-# configuration files
+# 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/%%')
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
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%^.*/%%')
@@ -23,11 +30,17 @@
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
+# configuration files
db_set tzdata/Areas "$AREA"
db_set tzdata/Zones/$AREA "$ZONE"
@@ -35,14 +48,18 @@
while [ "$STATE" -ge 0 ]; do
case "$STATE" in
0)
+ # The user has cancel the timezone change, reset the debconf
+ # values to the initial one.
db_set tzdata/Areas "$AREA"
db_set tzdata/Zones/$AREA "$ZONE"
break
;;
1)
+ # Ask the user of the Area
db_input high tzdata/Areas || true
;;
2)
+ # Ask the user of the Zone
db_get tzdata/Areas || RET=Etc
db_input high tzdata/Zones/$RET || true
;;
Modified: tzdata/trunk/debian/postinst
===================================================================
--- tzdata/trunk/debian/postinst 2007-04-17 09:52:30 UTC (rev 2085)
+++ tzdata/trunk/debian/postinst 2007-04-17 10:15:52 UTC (rev 2086)
@@ -1,32 +1,45 @@
#! /bin/sh
set -e
+LC_ALL=C
+LANG=C
+umask 022
+
if [ "$1" = configure ]; then
- . /usr/share/debconf/confmodule
- db_version 2.0
-
- LC_ALL=C
- LANG=C
- AREA=Etc
- ZONE=UTC
- db_get tzdata/Areas && AREA="$RET"
- db_get tzdata/Zones/$AREA && ZONE="$RET"
- db_stop
-
- umask 022
- echo $AREA/$ZONE > /etc/timezone
- rm -f /etc/localtime && \
- cp -f /usr/share/zoneinfo/$AREA/$ZONE /etc/localtime
-
- TZBase=$(LC_ALL=C TZ=UTC0 date)
- UTdate=$(TZ=UTC0 date -d "$TZBase")
- TZdate=$(TZ="$AREA/$ZONE" date -d "$TZBase")
- echo
- echo "Current default timezone: '$AREA/$ZONE'"
- echo "Local time is now: $TZdate."
- echo "Universal Time is now: $UTdate."
- echo "Run 'dpkg-reconfigure tzdata' if you wish to change it."
- echo
+ # 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
+ echo
+ 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
+ ZONE=UTC
+ db_get tzdata/Areas && AREA="$RET"
+ db_get tzdata/Zones/$AREA && ZONE="$RET"
+ db_stop
+
+ # Update the timezone
+ echo $AREA/$ZONE > /etc/timezone
+ rm -f /etc/localtime && \
+ cp -f /usr/share/zoneinfo/$AREA/$ZONE /etc/localtime
+
+ # Show the new setting to the user
+ TZBase=$(LC_ALL=C TZ=UTC0 date)
+ UTdate=$(TZ=UTC0 date -d "$TZBase")
+ TZdate=$(TZ="$AREA/$ZONE" date -d "$TZBase")
+ echo
+ echo "Current default timezone: '$AREA/$ZONE'"
+ echo "Local time is now: $TZdate."
+ echo "Universal Time is now: $UTdate."
+ echo "Run 'dpkg-reconfigure tzdata' if you wish to change it."
+ echo
+ fi
fi
#DEBHELPER#
Reply to: