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

Bug#813226: tzdata config script ignores /etc/timezone on non-interactive configuration



On Fri, 12 Feb 2016 10:01:34 +0100
Aurelien Jarno <aurelien@aurel32.net> wrote:

> On 2016-02-02 00:23, YAMADA Tsuyoshi wrote:
> > 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?
> 
> This patch will break all software which change /etc/localtime without
> changing /etc/timezone. I don't know if it is better to break the
> compatibility with external scripts or with software we ship in
> debian.
> 
> Aurelien
> 

There is also possibility, to decide by mtime of /etc/localtime
and /etc/timezone. The newer file will be the source of truth.
Then both types of software will work, provided that dpkg-reconfigure
will be run to synchronize state of those files. This is not a clean
solution (and I would hesitate to accept it), but your opinion may be
different, so I wanted to mention this idea. Anyways, the final
solution should be documented, as I mentioned in my previous email.



-- 
*Úspěch, charisma a inspirace v jednom magazínu. *
*Čtěte o nejúspěšnějších ženách Česka.*

*Objednejte si exkluzivní magazín Hospodářských novin Top ženy Česka 2016 
<https://predplatne.ihned.cz/objednat/top-zeny-ceska-2016?utm_source=economia-email&utm_medium=odkaz-zapati&utm_campaign=top-zeny-ceska-2016>.*

Attachment: signature.asc
Description: PGP signature


Reply to: