aboutsummaryrefslogtreecommitdiff
path: root/scripts/tzget
blob: 1c2d7f04affe7ac96c4b574c8cf067841063c0b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/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

PREFIX=${PREFIX:-/usr}
DATA_DIR=${XDG_DATA_HOME:-$PREFIX/share}/calp/zoneinfo

# Where to savze the file
CACHE_DIR=${CACHE_DIR:-~/.cache/calp}
# Which file to get
TAR=tzdata-latest.tar.gz
# Where to get it from
TZ_SRC="https://www.iana.org/time-zones/repository/$TAR"

mkdir -p $DATA_DIR
cd $DATA_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