aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu installer timezone)
  #:use-module (gnu installer utils)
  #:use-module (guix i18n)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:use-module (srfi srfi-34)
  #:use-module (srfi srfi-35)
  #:use-module (ice-9 match)
  #:use-module (ice-9 receive)
  #:export (locate-children
            timezone->posix-tz
            timezone-has-child?
            zonetab->timezone-tree
            posix-tz->configuration))

(define %not-blank
  (char-set-complement char-set:blank))

(define (posix-tz->timezone tz)
  "Convert given TZ in Posix format like \"Europe/Paris\" into a list like
(\"Europe\" \"Paris\")."
  (string-split tz #\/))

(define (timezone->posix-tz timezone)
  "Convert given TIMEZONE like (\"Europe\" \"Paris\") into a Posix timezone
like \"Europe/Paris\"."
  (string-join timezone "/"))

(define (zonetab->timezones zonetab)
  "Parse ZONETAB file and return the corresponding list of timezones."

  (define (zonetab-line->posix-tz line)
    (let ((tokens (string-tokenize line %not-blank)))
      (match tokens
        ((code coordinates tz _ ...)
         tz))))

  (call-with-input-file zonetab
    (lambda (port)
      (let* ((lines (read-lines port))
             ;; Filter comment lines starting with '#' character.
             (tz-lines (filter (lambda (line)
                                 (not (eq? (string-ref line 0)
                                           #\#)))
                               lines)))
        (map (lambda (line)
               (posix-tz->timezone
                (zonetab-line->posix-tz line)))
             tz-lines)))))

(define (timezones->timezone-tree timezones)
  "Convert the list of timezones, TIMEZONES into a tree under the form:

	(\"America\" (\"North_Dakota\" \"New_Salem\" \"Center\"))

representing America/North_Dakota/New_Salem and America/North_Dakota/Center
timezones."

  (define (remove-first lists)
    "Remove the first element of every sublists in the argument LISTS."
    (map (lambda (list)
           (if (null? list) list (cdr list)))
         lists))

  (let loop ((cur-timezones timezones))
    (match cur-timezones
      (() '())
      (((region . rest-region) . rest-timezones)
       (if (null? rest-region)
           (cons (list region) (loop rest-timezones))
           (receive (same-region other-region)
               (partition (lambda (timezone)
                            (string=? (car timezone) region))
                          cur-timezones)
             (acons region
                    (loop (remove-first same-region))
                    (loop other-region))))))))

(define (locate-children tree path)
  "Return the children of the timezone indicated by PATH in the given
TREE. Raise a condition if the PATH could not be found."
  (let ((extract-proc (cut map car <>)))
    (match path
      (() (sort (extract-proc tree) string<?))
      ((region . rest)
       (or (and=> (assoc-ref tree region)
                  (cut locate-children <> rest))
           (raise
            (condition
             (&message
              (message
               (format #f (G_ "Unable to locate path: ~a.") path))))))))))

(define (timezone-has-child? tree timezone)
  "Return #t if the given TIMEZONE any child in TREE and #f otherwise."
  (not (null? (locate-children tree timezone))))

(define* (zonetab->timezone-tree zonetab)
  "Return the timezone tree corresponding to the given ZONETAB file."
  (timezones->timezone-tree (zonetab->timezones zonetab)))


;;;
;;; Configuration formatter.
;;;

(define (posix-tz->configuration timezone)
  "Return the configuration field for TIMEZONE."
  `((timezone ,timezone)))
sign-esign), * gnu/packages/ruby.scm (ruby-cucumber, ruby_version, ruby-addressable), * gnu/packages/sagemath.scm (python-cypari2), * gnu/packages/skarnet.scm (s6-linux-init), * gnu/packages/vpn.scm (sshuttle), * gnu/packages/web.scm (libcyaml), * gnu/packages/xdisorg.scm (kbdd), * gnu/packages/xorg.scm (xpra): Same. Efraim Flashner 2020-09-29gnu: giac: Update to 1.6.0-23....* gnu/packages/algebra.scm (giac): Update to 1.6.0-23. [arguments]: Fix more hard-coded /bin/cp in Make files. [native-inputs]: Add python-wrapper. Nicolas Goaziou 2020-09-28gnu: cm: Update to 0.3.1....* gnu/packages/algebra.scm (cm): Update to 0.3.1. Andreas Enge 2020-09-23gnu: fplll: Correct include files....* gnu/packages/patches/fplll-std-fenv.patch: New patch. * gnu/local.mk (dist_patch_DATA): Register patch. * gnu/packages/algebra.scm (fplll): Use patch and move all inputs to propagated-inputs. Andreas Enge 2020-09-23gnu: fplll: Update to 5.3.3....* gnu/packages/algebra.scm (fplll): Update to 5.3.3. [native-inputs]: Add pkg-config. Andreas Enge 2020-09-01gnu: gap: Update to 4.11.0....* gnu/packages/algebra.scm (gap)[source]: Update to 4.11.0. Identify kept packages by name prefix, dropping version number comparisons. [inputs]: Add readline. [arguments]: Use make targets instead of file copying where possible. Andreas Enge 2020-08-20gnu: python-fpylll: Update to 0.5.2....* gnu/packages/algebra.scm (python-fpylll): Update to 0.5.2. Andreas Enge 2020-08-20gnu: fplll: Update to 5.3.2....* gnu/packages/algebra.scm (fplll): Update to 5.3.2. Andreas Enge 2020-08-19gnu: cmh: Update home-page....* gnu/packages/algebra.scm (cmh)[home-page]: Update to new home-page. Efraim Flashner 2020-08-18gnu: mpfrcx: Update to 0.6....* gnu/packages/algebra.scm (mpfrcx): Update to 0.6. Andreas Enge 2020-08-15gnu: flint: Update to 2.6.3....* gnu/packages/algebra.scm (flint): Update to 2.6.3. [license]: Update to LGPL 2.1+. Tobias Geerinckx-Rice 2020-08-08gnu: flint: Add a comment about the licence....* gnu/packages/algebra.scm (flint): Note the upstream licence change/fix. Reported by Max Horn <max@quendi.de>. Tobias Geerinckx-Rice 2020-08-08gnu: flint: Update to 2.6.2....* gnu/packages/algebra.scm (flint): Update to 2.6.2. Tobias Geerinckx-Rice 2020-07-25gnu: flint: Update to 2.6.1....* gnu/packages/algebra.scm (flint): Update to 2.6.1. Tobias Geerinckx-Rice 2020-07-22arb: Update to 2.18.1....* gnu/packages/patches/arb-flint-2.6.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/algebra.scm (arb): Update to 2.18.1. [source](patches): Remove. Andreas Enge 2020-07-22gnu: gp2c: Update to 0.0.11pl4....* gnu/packages/algebra.scm (gp2c): Update to 0.0.11pl4. Andreas Enge 2020-07-12gnu: Remove ".git" from "https://github/…/….git"....Until now, 'lookup-origin' and thus 'lookup-origin-revision' in (guix swh) would sometimes return #f for these because the ".git" URLs are redirects to the non-".git" URLs. Consequently, 'guix lint -c archival' would keep saying "scheduled Software Heritage archival"; likewise, the fallback download code would fail. * gnu/packages/ada.scm, gnu/packages/admin.scm, gnu/packages/aidc.scm, gnu/packages/algebra.scm, gnu/packages/android.scm, gnu/packages/animation.scm, gnu/packages/arcan.scm, gnu/packages/assembly.scm, gnu/packages/audio.scm, gnu/packages/authentication.scm, gnu/packages/avr.scm, gnu/packages/axoloti.scm, gnu/packages/backup.scm, gnu/packages/bash.scm, gnu/packages/benchmark.scm, gnu/packages/bioconductor.scm, gnu/packages/bioinformatics.scm, gnu/packages/bittorrent.scm, gnu/packages/boost.scm, gnu/packages/build-tools.scm, gnu/packages/c.scm, gnu/packages/calendar.scm, gnu/packages/cdrom.scm, gnu/packages/check.scm, gnu/packages/chemistry.scm, gnu/packages/chez.scm, gnu/packages/clojure.scm, gnu/packages/code.scm, gnu/packages/compression.scm, gnu/packages/compton.scm, gnu/packages/coq.scm, gnu/packages/cpp.scm, gnu/packages/cran.scm, gnu/packages/crypto.scm, gnu/packages/curl.scm, gnu/packages/databases.scm, gnu/packages/datastructures.scm, gnu/packages/debug.scm, gnu/packages/disk.scm, gnu/packages/distributed.scm, gnu/packages/django.scm, gnu/packages/dlang.scm, gnu/packages/dns.scm, gnu/packages/docker.scm, gnu/packages/education.scm, gnu/packages/efi.scm, gnu/packages/elixir.scm, gnu/packages/emacs-xyz.scm, gnu/packages/embedded.scm, gnu/packages/emulators.scm, gnu/packages/engineering.scm, gnu/packages/erlang.scm, gnu/packages/fabric-management.scm, gnu/packages/file-systems.scm, gnu/packages/finance.scm, gnu/packages/firmware.scm, gnu/packages/flashing-tools.scm, gnu/packages/fonts.scm, gnu/packages/fontutils.scm, gnu/packages/fpga.scm, gnu/packages/game-development.scm, gnu/packages/games.scm, gnu/packages/genealogy.scm, gnu/packages/genimage.scm, gnu/packages/geo.scm, gnu/packages/gimp.scm, gnu/packages/gl.scm, gnu/packages/gnome-xyz.scm, gnu/packages/gnome.scm, gnu/packages/gnuzilla.scm, gnu/packages/golang.scm, gnu/packages/gpodder.scm, gnu/packages/graph.scm, gnu/packages/graphics.scm, gnu/packages/graphviz.scm, gnu/packages/groff.scm, gnu/packages/groovy.scm, gnu/packages/gtk.scm, gnu/packages/guile-xyz.scm, gnu/packages/guile.scm, gnu/packages/hardware.scm, gnu/packages/haskell-apps.scm, gnu/packages/haskell-xyz.scm, gnu/packages/hexedit.scm, gnu/packages/i2p.scm, gnu/packages/ibus.scm, gnu/packages/image-processing.scm, gnu/packages/image-viewers.scm, gnu/packages/image.scm, gnu/packages/ipfs.scm, gnu/packages/java-graphics.scm, gnu/packages/java-maths.scm, gnu/packages/java.scm, gnu/packages/javascript.scm, gnu/packages/jrnl.scm, gnu/packages/julia.scm, gnu/packages/jupyter.scm, gnu/packages/kodi.scm, gnu/packages/language.scm, gnu/packages/lego.scm, gnu/packages/less.scm, gnu/packages/libusb.scm, gnu/packages/linux.scm, gnu/packages/lirc.scm, gnu/packages/lisp-xyz.scm, gnu/packages/llvm.scm, gnu/packages/logging.scm, gnu/packages/lolcode.scm, gnu/packages/lua.scm, gnu/packages/lxde.scm, gnu/packages/lxqt.scm, gnu/packages/machine-learning.scm, gnu/packages/mail.scm, gnu/packages/markup.scm, gnu/packages/maths.scm, gnu/packages/maven.scm, gnu/packages/mes.scm, gnu/packages/messaging.scm, gnu/packages/monitoring.scm, gnu/packages/mpd.scm, gnu/packages/music.scm, gnu/packages/networking.scm, gnu/packages/node-xyz.scm, gnu/packages/ocaml.scm, gnu/packages/ocr.scm, gnu/packages/onc-rpc.scm, gnu/packages/opencl.scm, gnu/packages/opencog.scm, gnu/packages/pantheon.scm, gnu/packages/password-utils.scm, gnu/packages/patchutils.scm, gnu/packages/pdf.scm, gnu/packages/perl6.scm, gnu/packages/phabricator.scm, gnu/packages/popt.scm, gnu/packages/printers.scm, gnu/packages/prolog.scm, gnu/packages/protobuf.scm, gnu/packages/pulseaudio.scm, gnu/packages/python-crypto.scm, gnu/packages/python-web.scm, gnu/packages/python-xyz.scm, gnu/packages/qt.scm, gnu/packages/radio.scm, gnu/packages/rails.scm, gnu/packages/rdf.scm, gnu/packages/rednotebook.scm, gnu/packages/rpc.scm, gnu/packages/rsync.scm, gnu/packages/ruby.scm, gnu/packages/rust.scm, gnu/packages/scheme.scm, gnu/packages/screen.scm, gnu/packages/security-token.scm, gnu/packages/selinux.scm, gnu/packages/serialization.scm, gnu/packages/shells.scm, gnu/packages/shellutils.scm, gnu/packages/simh.scm, gnu/packages/sml.scm, gnu/packages/ssh.scm, gnu/packages/statistics.scm, gnu/packages/stenography.scm, gnu/packages/sync.scm, gnu/packages/syncthing.scm, gnu/packages/synergy.scm, gnu/packages/telephony.scm, gnu/packages/terminals.scm, gnu/packages/tex.scm, gnu/packages/texinfo.scm, gnu/packages/text-editors.scm, gnu/packages/textutils.scm, gnu/packages/time.scm, gnu/packages/tmux.scm, gnu/packages/tor.scm, gnu/packages/toys.scm, gnu/packages/version-control.scm, gnu/packages/video.scm, gnu/packages/vim.scm, gnu/packages/virtualization.scm, gnu/packages/vlang.scm, gnu/packages/vnc.scm, gnu/packages/vpn.scm, gnu/packages/web-browsers.scm, gnu/packages/web.scm, gnu/packages/wireservice.scm, gnu/packages/wm.scm, gnu/packages/wxwidgets.scm, gnu/packages/xdisorg.scm, gnu/packages/xml.scm, gnu/packages/xorg.scm, tests/lint.scm: Remove trailing ".git" from 'git-reference' URL. Ludovic Courtès 2020-07-10gnu: linbox: Fix linking of dependant packages....* gnu/packages/algebra.scm (linbox)[source]: Add a patch. [inputs]: Move fflas-ffpack to... [propagated-inputs]: ...here. * gnu/packages/patches/linbox-fix-pkgconfig.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. Jakub Kądziołka 2020-07-10gnu: arb: Build with flint 2.6....Backport an upstream patch to fix a compatibility issue with flint 2.6. * gnu/packages/algebra.scm (arb): Add patch. * gnu/packages/patches/arb-flint-2.6.patch: New file. * gnu/local.mk (dist_patch_DATA): Register new file. Jakub Kądziołka 2020-07-10gnu: flint: Build with ntl....* gnu/packages/algebra.scm (flint)[inputs]: Add ntl. [arguments]: Pass --with-ntl to configure. Jakub Kądziołka 2020-07-10gnu: flint: Update to 2.6.0....* gnu/packages/algebra.scm (flint): Update to 2.6.0. * gnu/packages/patches/flint-ldconfig.patch: Remove the patch as it got applied upstream. * gnu/local.mk (dist_patch_DATA): Deregister the removed file. Jakub Kądziołka 2020-07-08gnu: giac: Update to 1.6.0-7....* gnu/packages/algebra.scm (giac): Update to 1.6.0-7. Nicolas Goaziou 2020-06-24gnu: symengine: Fix indentation....* gnu/packages/algebra.scm (symengine): Fix indentation and apply small cosmetic fixes. Nicolas Goaziou 2020-06-24gnu: Add symengine....* gnu/packages/algebra.scm (symengine): New variable. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Vinicius Monego 2020-06-09gnu: singular: Update to 4.1.3p2....* gnu/packages/algebra.scm (singular): Update to 4.1.3p2. Tobias Geerinckx-Rice 2020-06-05gnu: singular: Update to 4.1.3p1....* gnu/packages/algebra.scm (singular): Update to 4.1.3p1. Tobias Geerinckx-Rice 2020-05-05Merge branch 'master' into core-updatesMarius Bakke 2020-05-04gnu: Add lmfit....* gnu/packages/algebra.scm (lmfit): New variable. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Vincent Legoll 2020-04-23Merge branch 'master' into core-updates... Conflicts: etc/news.scm gnu/local.mk gnu/packages/bootloaders.scm gnu/packages/linphone.scm gnu/packages/linux.scm gnu/packages/tls.scm gnu/system.scm Marius Bakke 2020-04-22gnu: pari-gp: Update to 2.11.4....* gnu/packages/algebra.scm (pari-gp): Update to 2.11.4. Andreas Enge 2020-04-08Merge branch 'master' into core-updates... Conflicts: etc/news.scm gnu/local.mk gnu/packages/check.scm gnu/packages/cross-base.scm gnu/packages/gimp.scm gnu/packages/java.scm gnu/packages/mail.scm gnu/packages/sdl.scm gnu/packages/texinfo.scm gnu/packages/tls.scm gnu/packages/version-control.scm Marius Bakke 2020-04-07gnu: gp2c: Update to 0.0.11pl3....* gnu/packages/algebra.scm (gp2c): Update to 0.0.11pl3. Andreas Enge 2020-04-07gnu: pari-gp: Update to 2.11.3....* gnu/packages/algebra.scm (pari-gp): Update to 2.11.3. Andreas Enge 2020-03-30Merge branch 'master' into core-updates... Conflicts: gnu/packages/admin.scm gnu/packages/commencement.scm gnu/packages/guile.scm gnu/packages/linux.scm gnu/packages/package-management.scm gnu/packages/pulseaudio.scm gnu/packages/web.scm Marius Bakke 2020-03-29algebra.scm: Add a copyright line...This is a follow-up to commit d96ad7fa1dcb12082db1acc07876f1ff219489df. Jakub Kądziołka 2020-03-29gnu: ntl: Update to 11.4.3....* gnu/packages/algebra.scm (ntl): Update to 11.4.3. [source], [home-page]: Use https URL. [source](snippet): Remove bundled libtool. [inputs]: Add gf2x. [arguments](configure): Use invoke insteam of system*. Remove the no longer supported WIZARD argument. Add a LIBTOOL parameter, since it's now required. Enable building with gf2x. Pass the paths to dependencies explicitly. (eclib)[inputs]: Remove the transitive dependency on gmp, which is now handled automatically by libtool. Jakub Kądziołka 2020-03-29gnu: Remove packages deprecated for over a year....* gnu/packages/admin.scm (intel-gpu-tools): Remove variable. * gnu/packages/algebra.scm (giac-xcas): Likewise. Tobias Geerinckx-Rice 2020-03-18Merge branch 'master' into core-updatesMarius Bakke 2020-03-14Merge branch 'master' into core-updatesMarius Bakke 2020-03-17gnu: eigen: Update to 3.3.7....* gnu/packages/algebra.scm (eigen): Update to 3.3.7. [source]: Add a patch to fix a test failure. * gnu/packages/patches/eigen-stabilise-sparseqr-test.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. Tobias Geerinckx-Rice 2020-03-10gnu: java-jlargearrays: Update source URI....* gnu/packages/algebra.scm (java-jlargearrays)[source]: Update URI. Björn Höfling 2020-03-10gnu: java-jtransforms: Update source URI....* gnu/packages/algebra.scm (java-jtransforms)[source]: Update URI. Björn Höfling