diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-03 12:39:30 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-03 12:41:15 +0200 |
commit | 7bbf2470bbdc46089dec1eb4c2328d0c87ba594f (patch) | |
tree | 56aa27c14ed7f42a7a184ce715983795ea9d839a /configure | |
parent | Add TODO's about early load. (diff) | |
download | calp-7bbf2470bbdc46089dec1eb4c2328d0c87ba594f.tar.gz calp-7bbf2470bbdc46089dec1eb4c2328d0c87ba594f.tar.xz |
Resolve (datetime instance) TODO with ./configure?
Tried adding a ./configure script, which mostly is responsible for
downloading a default zoneinfo file, and setting up the environment for
the program.
I have for quite a while thought about having a configure system for
things like these, but also for setting up default paths. Let's see if
it works out.
Diffstat (limited to '')
-rwxr-xr-x | configure | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/configure b/configure new file mode 100755 index 00000000..30a78a24 --- /dev/null +++ b/configure @@ -0,0 +1,44 @@ +#!/usr/bin/guile \ +--no-auto-compile -s +!# + +(define // file-name-separator-string) + +(define here (cond ((current-filename) => dirname) + (else (getcwd)))) +(define module-dir (string-append here // "module")) +(add-to-load-path module-dir) + +(use-modules (util)) + +;; --with-zoneinfo +(define zoneinfo #t) + +;; when zoneinfo +(use-modules (ice-9 rdelim)) + +(define pipe + (-> here + (string-append "/tzget") + ((@ (ice-9 popen) open-input-pipe)))) +(define path (read-line pipe)) +(define names (string-split (read-line pipe) #\space)) + +(use-modules (util io) + (datetime)) +(with-atomic-output-to-file + (string-append module-dir // "autoconfig.scm") + (lambda () + (display ";;; Commentary:") (newline) + (display ";;; File genererated by ./configure on ") + (display (datetime->string + (current-datetime) "~Y-~m-~d ~H:~M:~S~Z")) + (newline) + (display ";;; DONT make any manual changes") (newline) + (display ";;; Code:") (newline) + (for-each (@ (ice-9 pretty-print) pretty-print) + `((define-module (autoconfig) + use-module: (util config)) + ,@(when zoneinfo + `((set-config! 'tz-file ,path) + (set-config! 'tz-list (quote ,names)))))))) |