Programmatic way of determining the latest release number?
Hi folks, I'm aware of the ability to use ftp://ftp.iana.org/tz/tzcode-latest.tar.gz and the similar data URL to get the latest actual files, but is there a URL which either serves an HTTP redirect to the latest version, or gives the latest version number in some other easily-retrievable machine-readable format? I could parse the content of http://www.iana.org/time-zones, but that doesn't feel like a very robust approach :) Presumably this might all drop out of the tzdist work, but I was wondering whether there was a low-tech way at the moment. Jon
Yeah, that's how I'm doing it here: https://github.com/dateutil/tzdata If you want, I store a metadata file on a mirror of the tzdata archive here: https://dateutil.github.io/tzdata/ The latest metadata is always at: https://dateutil.github.io/tzdata/zonefile_metadata/zonefile_metadata.json Note that I run the update script manually, so there's a (short) lag between new releases and updates to the metadata file. On April 30, 2016 3:57:19 AM EDT, Zefram <zefram@fysh.org> wrote:
Jon Skeet wrote:
latest version number in some other easily-retrievable machine-readable format?
You can do an FTP NLST on the /tz/releases directory, and search through the list for the highest version number.
-zefram
On Apr 30, 2016, at 3:39 AM, Jon Skeet <skeet@pobox.com> wrote:
I could parse the content of http://www.iana.org/time-zones, but that doesn't feel like a very robust approach :)
That’s exactly what I ended up doing: https://github.com/HowardHinnant/date/blob/master/tz.cpp#L1937-L1971 Howard
Thanks. May use that as a crude approach for now... although what it'll be like in a bash script when I'm far from a bash wizard is anyone's guess :) Jon On 30 April 2016 at 13:27, Howard Hinnant <howard.hinnant@gmail.com> wrote:
On Apr 30, 2016, at 3:39 AM, Jon Skeet <skeet@pobox.com> wrote:
I could parse the content of http://www.iana.org/time-zones, but that
doesn't feel like a very robust approach :)
That’s exactly what I ended up doing:
https://github.com/HowardHinnant/date/blob/master/tz.cpp#L1937-L1971
Howard
On 2016-04-30 01:39, Jon Skeet wrote:
I'm aware of the ability to use ftp://ftp.iana.org/tz/tzcode-latest.tar.gz and the similar data URL to get the latest actual files, but is there a URL which either serves an HTTP redirect to the latest version, or gives the latest version number in some other easily-retrievable machine-readable format? I could parse the content of http://www.iana.org/time-zones, but that doesn't feel like a very robust approach :)> Presumably this might all drop out of the tzdist work, but I was wondering whether there was a low-tech way at the moment.
Wget allows you to download synlinks verbatim with option --retr-symlinks=no which gets the symlinks themselves, whereas --retr-symlinks[=yes] gets the files pointed to the symlinks. Extract from daily tz download check job: site=ftp://ftp.iana.org/tz cl=tzcode-latest.tar.gz dl=tzdata-latest.tar.gz # get remote links to latest releases wget -qN --retr-symlinks=no $site/$cl $site/$dl # if links get remote names from link contents [ -L "$cl" -a -L "$dl" ] && \ rca=$(readlink $cl) && \ rda=$(readlink $dl) && \ ... Symlinks contain/point to 'releases/tzcode2016d.tar.gz' and 'releases/tzdata2016d.tar.gz' currently. You can then extract the releases from these linsk and compare against previous/current code/data Makefile lines starting /^VERSION=/ using your favourite tools and decide whether to download the actual files pointed to by the links and their .asc signatures, for gpg verification against Paul's trusted key ED97E90E62AA7E34 which I dug up from somewhere. HTTP server redirects are transparent to wget but are available from curl. By default curl displays the HTTP server 30# redirect error code and message, including HSTS redirections from http: to https: pages. Specifying option -w redirect_url shows the redirect URL and option -L follows the redirect to get the file. HTML "redirects" can also be performed by tags like: <meta http-equiv="refresh" content="0;..."> and full screen iframes: <iframe src="..." frameborder="0" allowtransparency="true" seamless="seamless" scrolling="auto" allowfullscreen="true"> </iframe> which may have to be dealt with programmatically. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
If you have the git repository, you could do something like this: $ git fetch $ version=$(git describe --abbrev=0 origin/master) $ echo $version 2016d The above assumes a conventional upstream remote repository of "origin". If you're doing something less conventional, you probably know how to modify the above accordingly. :-) Chris On Sat, Apr 30, 2016 at 2:39 AM, Jon Skeet <skeet@pobox.com> wrote:
Hi folks,
I'm aware of the ability to use ftp://ftp.iana.org/tz/tzcode-latest.tar.gz and the similar data URL to get the latest actual files, but is there a URL which either serves an HTTP redirect to the latest version, or gives the latest version number in some other easily-retrievable machine-readable format?
I could parse the content of http://www.iana.org/time-zones, but that doesn't feel like a very robust approach :)
Presumably this might all drop out of the tzdist work, but I was wondering whether there was a low-tech way at the moment.
Jon
participants (6)
-
Brian Inglis -
Chris Rorvick -
Howard Hinnant -
Jon Skeet -
Paul G -
Zefram