Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Oct 2011 14:43:13 +0100
From:      Jilles Tjoelker <jilles@stack.nl>
To:        Lev Serebryakov <lev@FreeBSD.org>
Cc:        arch@freebsd.org
Subject:   Re: /etc/localtime problems
Message-ID:  <20111030134313.GA94944@stack.nl>
In-Reply-To: <457576448.20111030151023@serebryakov.spb.ru>
References:  <457576448.20111030151023@serebryakov.spb.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Oct 30, 2011 at 03:10:23PM +0400, Lev Serebryakov wrote:
>   Now, /etc/localtime is copy of one of files from
> /usr/share/zoneinfo. It is created at install time or with "tzsetup"
> utility.

>   IMHO, it is bad practice. For example, Russia changed rules
> (cancelled Winter Time). Ok, our database was updated properly
> (r223629 and MFCes), but "make buildworld installworld && mergemaster"
> doesn't touch /etc/localtime! So, every administrator of every FreeBSD
> server in Russia needs not to forget to update this file manually.

>  It looks not good.

>  IMHO, /etc/localtime should be symlink (in such case "installworld"
> or "freebsd-update" will fix problem), or "mergemaster" should know
> about this file and update it too...

Recent tzsetup(8) (in 10.x, 9.x and recent 8.x but not in any release)
stores the choice in /var/db/zoneinfo, allowing "tzsetup -r" to install
the new version of the previous time zone. This happens automatically on
installworld, but for some reason not on freebsd-update install.
However, this only works if the new tzsetup(8) was run at least once to
select the time zone (there is no code to create /var/db/zoneinfo from
which /usr/share/zoneinfo file matches /etc/localtime).

Code to create /var/db/zoneinfo could be something like

if [ ! -s /var/db/zoneinfo ] && [ -s /etc/localtime ]; then
  zone=$(cd /usr/share/zoneinfo && for z in */* */*/* *; do
    if cmp -s "$z" /etc/localtime; then echo "$z"; break; fi done)
  if [ -n "$zone" ]; then echo "$zone" >/var/db/zoneinfo; fi
fi

It should be run against the old /usr/share/zoneinfo and assumes the
/etc/localtime is up-to-date against that.

-- 
Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111030134313.GA94944>