Bug#813226: tzdata config script ignores /etc/timezone on non-interactive configuration
2016-02-01 16:43 GMT+09:00 Aurelien Jarno <aurelien@aurel32.net>:
> I don't think it is a bug. The correct way to configure the timezone has
> always been to change /etc/localtime symlink, ie in your case by doing
> "ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime". This is what
> desktop environments do when changing the timezone and it is what
> systemd expects.
>
> Changing /etc/timezone worked in some cases before as we use to store
> /etc/localtime as a copy of the file instead of a symlink when possible,
> in order to allow the timezone to be correct without a /usr partition.
> This is not needed anymore given /usr is now mount from the initramfs
> when needed.
Hmm, I understand the correct way, but many people are using incorrect way.
("echo Foo/Bar > /etc/timezone" and "dpkg-reconfigure -f noninteractive tzdata")
Please see github:
https://github.com/search?q=%2Fetc%2Ftimezone+dpkg-reconfigure+noninteractive+tzdata&type=Code&utf8=%E2%9C%93
There are about 4,000 codes!
I think this incompatibility for those codes is not so good.
I propose a patch for debian/tzdata.config (/var/lib/dpkg/info/tzdata.config):
--- /tmp/tzdata.config.bak 2016-01-29 20:28:52.000000000 +0000
+++ tzdata.config 2016-02-01 14:42:09.462282218 +0000
@@ -326,15 +326,6 @@
esac
}
-# If /etc/localtime is a link, update /etc/timezone
-if [ -L /etc/localtime ] ; then
- TIMEZONE="$(readlink /etc/localtime)"
- TIMEZONE="${TIMEZONE#/usr/share/zoneinfo/}"
- if [ -f "/usr/share/zoneinfo/$TIMEZONE" ] ; then
- echo ${TIMEZONE} > /etc/timezone
- fi
-fi
-
# Read /etc/timezone
if [ -e /etc/timezone ]; then
TIMEZONE="$(head -n 1 /etc/timezone)"
@@ -350,6 +341,15 @@
fi
fi
+# If /etc/localtime is a link, update /etc/timezone
+if [ -L /etc/localtime ] ; then
+ TIMEZONE="$(readlink /etc/localtime)"
+ TIMEZONE="${TIMEZONE#/usr/share/zoneinfo/}"
+ if [ -f "/usr/share/zoneinfo/$TIMEZONE" ] ; then
+ echo ${TIMEZONE} > /etc/timezone
+ fi
+fi
+
# The timezone is already configured
if [ -e /etc/timezone ] && [ -e /etc/localtime ] ; then
# Don't ask the user, except if he/she explicitely asked that
This patch will keep compatibility like this:
root@031baca8faac:~# echo Asia/Tokyo > /etc/timezone
root@031baca8faac:~# readlink /etc/localtime
/usr/share/zoneinfo/Etc/UTC
root@031baca8faac:~# dpkg-reconfigure -f noninteractive tzdata
Current default time zone: 'Asia/Tokyo'
Local time is now: Mon Feb 1 23:45:19 JST 2016.
Universal Time is now: Mon Feb 1 14:45:19 UTC 2016.
root@031baca8faac:~# cat /etc/timezone
Asia/Tokyo
root@031baca8faac:~# readlink /etc/localtime
/usr/share/zoneinfo/Asia/Tokyo
Could you please consider this patch?
Reply to: