blob: c6be1af34208693c6e9fc3db81699e6d0c6132dc (
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
|
(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 ,(G_ "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"
(G_ "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)))
|