aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-17 20:16:48 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-17 20:16:48 +0200
commit41d4efda03af2cf6244ccfb3fb57fba5f664bb50 (patch)
treef7ce24814672b2ccff87125154fe648e99115925 /scripts
parentFix global version var. (diff)
downloadcalp-41d4efda03af2cf6244ccfb3fb57fba5f664bb50.tar.gz
calp-41d4efda03af2cf6244ccfb3fb57fba5f664bb50.tar.xz
Hopefully repaired --update-zoneinfo.-
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/tzget42
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/tzget b/scripts/tzget
new file mode 100755
index 00000000..1c2d7f04
--- /dev/null
+++ b/scripts/tzget
@@ -0,0 +1,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