From 41d4efda03af2cf6244ccfb3fb57fba5f664bb50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 17 Aug 2020 20:16:48 +0200 Subject: Hopefully repaired --update-zoneinfo.- --- env | 5 ++++- module/calp/main.scm | 7 ++++--- module/directories.scm | 5 +++-- scripts/tzget | 42 ++++++++++++++++++++++++++++++++++++++++++ tzget | 42 ------------------------------------------ 5 files changed, 53 insertions(+), 48 deletions(-) create mode 100755 scripts/tzget delete mode 100755 tzget diff --git a/env b/env index c1bd360f..99b3f84d 100755 --- a/env +++ b/env @@ -6,7 +6,10 @@ GUILE_LOAD_PATH="$root/module:$GUILE_LOAD_PATH" #GUILE_LOAD_COMPILED_PATH="$root/obj/module:$GUILE_LOAD_COMPILED_PATH" #LD_LIBRARY_PATH="$root/lib:$LD_LIBRARY_PATH" -export GUILE_LOAD_PATH GUILE_LOAD_COMPILED_PATH LD_LIBRARY_PATH +XDG_DATA_HOME=$root +LIBEXEC=$root/scripts/ + +export GUILE_LOAD_PATH GUILE_LOAD_COMPILED_PATH LD_LIBRARY_PATH XDG_DATA_HOME LIBEXEC #export GUILE_AUTO_COMPILE=0 # exec "$@" diff --git a/module/calp/main.scm b/module/calp/main.scm index ee49c250..709658d8 100644 --- a/module/calp/main.scm +++ b/module/calp/main.scm @@ -165,15 +165,16 @@ (open-input-pipe (path-append libexec "/tzget"))))) ;; (define path (read-line pipe)) - (define names (string-split ((@ (ice-9 rdelim) read-line) pipe) #\space)) + (define line ((@ (ice-9 rdelim) read-line) pipe)) + (define names (string-split line #\space)) ((@ (util io) with-atomic-output-to-file) (path-append data-directory "/zoneinfo.scm") (lambda () (write `(set-config! 'tz-list ',names)) (newline) - (write `(set-config! 'last-zoneinfo-upgrade ,((@ (datetime) current-date))) (newline)))))) + (write `(set-config! 'last-zoneinfo-upgrade ,((@ (datetime) current-date)))) (newline))))) ;; always load zoneinfo if available. - (let ((z (path-append data-directory "/zoneinfo"))) + (let ((z (path-append data-directory "/zoneinfo.scm"))) (when (file-exists? z) (primitive-load z))) diff --git a/module/directories.scm b/module/directories.scm index fe86bdf6..8e46d8b6 100644 --- a/module/directories.scm +++ b/module/directories.scm @@ -22,8 +22,9 @@ "/calp")) (define (libexec%) - (path-append (get-config 'path-prefix) - "/lib/calp")) + (or (getenv "LIBEXEC") + (path-append (get-config 'path-prefix) + "/lib/calp"))) (define-syntax libexec (identifier-syntax (libexec%))) (export libexec) 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 diff --git a/tzget b/tzget deleted file mode 100755 index 1c2d7f04..00000000 --- a/tzget +++ /dev/null @@ -1,42 +0,0 @@ -#!/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 -- cgit v1.2.3