diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-04-21 20:59:07 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-04-23 21:53:39 +0200 |
commit | abcf0b98ff9797427f305a67c030a0086b4dfaea (patch) | |
tree | 0b5668b5411096a739838528215d59ca3155f711 /module/calp/entry-points | |
parent | Fix missing hower-text for changelog tabs. (diff) | |
download | calp-abcf0b98ff9797427f305a67c030a0086b4dfaea.tar.gz calp-abcf0b98ff9797427f305a67c030a0086b4dfaea.tar.xz |
Made update-zoneinfo own entry point.
Diffstat (limited to 'module/calp/entry-points')
-rw-r--r-- | module/calp/entry-points/update-zoneinfo.scm | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/module/calp/entry-points/update-zoneinfo.scm b/module/calp/entry-points/update-zoneinfo.scm new file mode 100644 index 00000000..b565faeb --- /dev/null +++ b/module/calp/entry-points/update-zoneinfo.scm @@ -0,0 +1,42 @@ +(define-module (calp entry-points update-zoneinfo) + :export (main) + ;; :use-module (hnh util) + :use-module (datetime) + :use-module (srfi srfi-1) + :use-module (hnh util path) + :use-module ((hnh util io) :select (with-atomic-output-to-file)) + :use-module ((xdg basedir) :prefix xdg-) + :use-module ((ice-9 rdelim) :select (read-line)) + :use-module (hnh util options) + :use-module (ice-9 getopt-long) + :use-module (ice-9 popen) + :use-module (ice-9 format) + :use-module (calp translation)) + +(define opt-spec + `((help (single-char #\h) (description ,(_ "Print this help."))))) + +(define (main args) + (define opts (getopt-long args (getopt-opt opt-spec))) + + (when (option-ref opts 'help #f) + (print-arg-help opt-spec) + (throw 'return)) + + (let* ((locations (list "/usr/libexec/calp/tzget" + (path-append (xdg-data-home) "tzget"))) + (filename (or (find file-exists? locations) + (scm-error 'missing-helper "update-zoneinfo" + (_ "tzget not installed, please put it in one of ~a") + (list locations) + (list "tzget" locations)))) + + (pipe (open-input-pipe filename)) + (names (string-split (read-line pipe) #\space))) + (with-atomic-output-to-file (path-append (xdg-data-home) "calp" "zoneinfo.scm") + (lambda () + (format #t ";;; Autogenerated file~%;;; Last updated ~a~%~y~%" + (datetime->string (current-datetime)) + `((@ (datetime instance) tz-list) (quote ,names))))) + + (close-pipe pipe))) |