Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Mar 2011 08:38:35 -0700
From:      David Wolfskill <david@catwhisker.org>
To:        hackers@freebsd.org
Subject:   Keeping /etc/localtime up-to-date
Message-ID:  <20110327153835.GA87420@albert.catwhisker.org>

next in thread | raw e-mail | index | archive | help

--9jxsPFA5p3P2qPhR
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Recent changes to /usr/share/zoneinfo have reminded me that my
regular updates to my FreeBSD machines via source update
/usr/share/zoneinfo, but /etc/localtime remains a copy of whatever
was in /usr/share/zoneinfo for the selected zone at the time
tzsetup(8) was last run -- and I certainly don't run tzsetup as
often as I update my sources (nor would I want to).

And while I (think I) recall that the equivalent of /etc/localtime
was implemented in some version of SunOS many years ago as a symlink,
I believe that approach could be problematic for FreeBSD, as it
could impose some unintended requirements on some of the start-up
scripts.

I believe that it would be appropriate to have a facility to update
/etc/localtime if the file to which it is supposed to correspond
in /usr/share/zoneinfo (now) differs.

Even if tzsetup is invoked with the -s flag and having the desired
zoneinfo file specified on the command-line, it goes into full-screen
mode and requests confirmation.  Further, if the confirmation is
given, it unconditionally overwrites /etc/localtime.

It would (in principle) be possible to teach mergemaster(8) how to
do this (possibly by including a cookie in ~/.mergemasterrc or
/etc/mergemaster.rc to tell it what the "reference" zoneinfo pathname
is), but this type of approach seems sufficiently different from
(the bulk of?) what mergemaster does currently that I'm unconvinced
that this is reasonable, let alone ideal.

So it seems to me that requirements would be:
* The content of /etc/localtime must provide the appropriate
  "zoneinfo" information, even when /usr/share/zoneinfo/* has been
  modified (or shortly thereafter, in concert with "make installworld").

* The content of /etc/localtime must be available when the only file
  system mounted is the root file system (and prior to any attempt to
  start any services (ref. {,/usr/local}/etc/rc.d)).

* The process must be amenable to automation; to that end, it must be
  possible to perform it without requiring confirmation, and it
  must be doable from a command-line.

* /etc/localtime should not be modified unless the content prior to
  modification differs from the selected specification in
  /usr/share/zoneinfo.

* The process should not add unnecessary complexity to existing tools
  and procedures.

 =20
As a crude, brute-force hack, what I did (yesterday) was:
* Create a symlink (which I called "/etc/tz") pointing to an
  appropriate zoneinfo entry.

* Augment the commands I run on successful completion of "make
  installkernel" (from src/UPDATING):

  mergemaster -p
  make installworld
  mergemaster -i
  make delete-old

  by appending

  cmp -s /etc/tz /etc/localtime || cp -p /etc/tz /etc/localtime

  to the set.

  While I make no claim as to elegance, I believe it meets the
  requirements I listed.


Of course, another approach -- which is likely to be fairly popular
-- would be to run the machine on UTC, and let folks who want to
care about TZ stuff set their own personal TZ environment variables.  :-}
Still, even that approach leads to the existence of /etc/localtime
as being somewhat of an "attractive nuisance" (in that if it exists,
it is likely to lead to a degree of mischief).

Thoughts?

Peace,
david
--=20
David H. Wolfskill				david@catwhisker.org
Depriving a girl or boy of an opportunity for education is evil.

See http://www.catwhisker.org/~david/publickey.gpg for my public key.

--9jxsPFA5p3P2qPhR
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (FreeBSD)

iEYEARECAAYFAk2PWfoACgkQmprOCmdXAD1xMQCfb2DwphkVnGIX6+9sTeIp+skA
jBsAn0+92sQPOoM0UD0eKFBdTt7/gZuv
=1hFb
-----END PGP SIGNATURE-----

--9jxsPFA5p3P2qPhR--



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