header image
Main Page arrow Published Articles arrow Howto's arrow Manually Patching Linux (and UNIX) for DST
Manually Patching Linux (and UNIX) for DST PDF Print E-mail
Contributed by anti-trend   
Mar 12, 2007 at 08:53 AM
ImageThe recent DST changes which primarily impacts North Americans (or those which will interact with them extensively -- so almost everybody); it is a subtle but decidedly important change. Linux systems which are currently supported by their distributors should receive the corrected zone files automatically. Older systems with no vendor support, however, will not have such a luxury. Fortunately, older Linux (and most other UNIX-like) systems can easily be patched manually to accommodate for changes in DST behavior.
  1. Download the latest zonefiles from nih.gov. As of the date of this writing, the latest file is 'tzdata2007c.tar.gz', but you should always get the latest version available to you.
    $ wget ftp://elsie.nci.nih.gov/pub/tzdata2007c.tar.gz
  2. Now you need to create a temp folder someplace on your system, then extract contents of the tzdata file there. I like using '/tmp', since I don't have to remember to clean it up later.
    $ mkdir /tmp/tzpatch
    $ tar xzvf  tzdata2007c.tar.gz -C /tmp/tzpatch
  3. From here on, you'll need root privileges if you don't already; I'll assume you know how to get root on your respective systems. Change directories to where you've extracted the new zone files, then run the 'zic' command to extract the pertinent zone files. For me, it's 'northamerica', but you might need to choose a different zone depending on where you live.
    $ cd /tmp/tzpatch
    $ zic -d zoneinfo northamerica
  4. We've extracted the zone files we need, so now we simply replace the existing system files with the ones we've just built. On most systems, this is kept in '/usr/share/zoneinfo', but yours may vary if it's a bit of an unusual distro.
    $ cp -Rf /tmp/tzpatch/ /usr/share/zoneinfo 
  5. All we have left to do at this point is replace the local zone file which is currently in use on our system. Depending on the distro, this is either a copy of or a symlink to a specific zone file in your zoneinfo folder, which is typically kept in '/etc/localtime'. In the case that file is already a symlink to the correct file in '/usr/share/zoneinfo', we are done here. If it's a copy and not a symlink, we'll need to replace the file by either copying or linking to the appropriate zone file. I prefer linking, because it makes future patches easier, but copying will work also.
    $ rm -rf /etc/localtime
    $ ln -s /usr/share/zoneinfo/PST8PDT /etc/localtime


Note: On most UNIX systems with a few exceptions, all of the above should hold true. That said, the more official route would be to forgo step 5 and instead run the 'tzsetup' utility. Even so, I prefer to symlink the appropriate zonefile so that if you need to update your zoneinfo files again, your localtime file is updated automatically. The choice, of course, is yours.

We're finished! If you chose to symlink the localtime file rather than simply overwriting, patching the zonefile in the future will be one step shorter; simply follow steps 1-4.

All the best,

-AT 

Last Updated ( Mar 25, 2007 at 11:56 AM )
<Previous