2
0

build-zonedata.pl 897 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. my $remote_version = `wget --quiet https://data.iana.org/time-zones/tzdb/version --output-document -` =~ s/\n//r;
  5. my $local_version;
  6. if ( open my $in, "<data/version" ) {
  7. $local_version = do { local $/; <$in> };
  8. close $in;
  9. }
  10. my $up_to_date = defined($local_version) && $local_version eq $remote_version;
  11. if ( ! $up_to_date ) {
  12. open my $out, ">data/version";
  13. print $out $remote_version;
  14. close $out;
  15. }
  16. $local_version = $remote_version;
  17. `wget --quiet --timestamping --directory-prefix=data https://data.iana.org/time-zones/tzdb-latest.tar.lz`;
  18. `tar --extract --file=data/tzdb-latest.tar.lz --directory=data`;
  19. `make DESTDIR=../ TZDIR=zones-$local_version --directory=data/tzdb-$local_version posix_only`;
  20. print("Yay. Now you can run\n ./timezone-gen.pl --base=data/zones-$local_version --output=timezones-$local_version.conf.xml")