/etc/localtime problems

Jilles Tjoelker jilles at stack.nl
Sun Oct 30 13:43:15 UTC 2011


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


More information about the freebsd-arch mailing list