#!/bin/bash # Downloads zoneinfo files if not already present # echos 2 lines, # - the directory with the zoneinfo files # - the names of the zoneinfo files to be parsed CACHE_DIR=${CACHE_DIR:-~/.cache/calp} TAR=tzdata-latest.tar.gz TZ_SRC="https://www.iana.org/time-zones/repository/$TAR" mkdir -p $CACHE_DIR cd $CACHE_DIR test -d "tzdata" || { test -f "/tmp/$TAR" || env --chdir=/tmp curl -sOL $TZ_SRC mkdir tzdata tar xf "/tmp/$TAR" -C tzdata } cd "tzdata" tzpath=$(pwd) size=$(stat -c "%s" Makefile) cat >> Makefile << EOF .PHONY: print-tdata print-tdata: @echo \$(TDATA_TO_CHECK) EOF files=$(make print-tdata) truncate -cs $size Makefile echo $tzpath echo $files