aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
;;;
;;; 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 build locale)
  #:use-module (guix build utils)
  #:use-module (srfi srfi-1)
  #:use-module (ice-9 rdelim)
  #:use-module (ice-9 match)
  #:use-module (ice-9 regex)
  #:export (build-locale
            normalize-codeset
            locale->name+codeset
            read-supported-locales))

(define locale-rx
  ;; Regexp matching a locale line in 'localedata/SUPPORTED'.
  (make-regexp
   "^[[:space:]]*([[:graph:]]+)/([[:graph:]]+)[[:space:]]*\\\\$"))

(define (read-supported-locales port)
  "Read the 'localedata/SUPPORTED' file from PORT.  That file is actually a
makefile snippet, with one locale per line, and a header that can be
discarded."
  (let loop ((locales '()))
    (define line
      (read-line port))

    (cond ((eof-object? line)
           (reverse locales))
          ((string-prefix? "#" (string-trim line)) ;comment
           (loop locales))
          ((string-contains line "=")            ;makefile variable assignment
           (loop locales))
          (else
           (match (regexp-exec locale-rx line)
             (#f
              (loop locales))
             (m
              (loop (alist-cons (match:substring m 1)
                                (match:substring m 2)
                                locales))))))))

(define (normalize-codeset codeset)
  "Compute the \"normalized\" variant of CODESET."
  ;; info "(libc) Using gettextized software", for the algorithm used to
  ;; compute the normalized codeset.
  (letrec-syntax ((-> (syntax-rules ()
                        ((_ proc value)
                         (proc value))
                        ((_ proc rest ...)
                         (proc (-> rest ...))))))
    (-> (lambda (str)
          (if (string-every char-set:digit str)
              (string-append "iso" str)
              str))
        string-downcase
        (lambda (str)
          (string-filter char-set:letter+digit str))
        codeset)))

(define* (build-locale locale
                       #:key
                       (localedef "localedef")
                       (directory ".")
                       (codeset "UTF-8")
                       (name (string-append locale "." codeset)))
  "Compute locale data for LOCALE and CODESET--e.g., \"en_US\" and
\"UTF-8\"--with LOCALEDEF, and store it in DIRECTORY under NAME."
  (format #t "building locale '~a'...~%" name)
  (invoke localedef "--no-archive" "--prefix" directory
          "-i" locale "-f" codeset
          (string-append directory "/" name)))

(define (locale->name+codeset locale)
  "Split a locale name such as \"aa_ER@saaho.UTF-8\" into two values: the
language/territory/modifier part, and the codeset."
  (match (string-rindex locale #\.)
    (#f  (values locale #f))
    (dot (values (string-take locale dot)
                 (string-drop locale (+ dot 1))))))
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-08gnu: ibus-rime: Fix license....* gnu/packages/ibus.scm (ibus-rime)[license]: Change license to GPLv3. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Peng Mei Yu 2020-07-08gnu: rime-data: Fix license....* gnu/packages/ibus.scm (rime-data)[license]: Change license to LGPLv3. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Peng Mei Yu 2020-07-08gnu: rime-data: Disable git operations and update comments....* gnu/packages/ibus.scm (rime-data)[arguments]: Disable git operations and update comments. Suppress warnings during build. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Peng Mei Yu 2020-07-08gnu: rime-data: Iterate over inputs to find Rime schemas....* gnu/packages/ibus.scm (rime-data)[arguments]: Iterate over inputs to find Rime schemas rather than using a pre-loaded list. [native-inputs]: Move to ... [inputs]: ... here. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Peng Mei Yu 2020-07-08gnu: rime-data: Update to 0.38.20200623....* gnu/packages/ibus.scm (rime-data): Update to 0.38.20200623. [native-inputs]: Add rime-cantonese. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Peng Mei Yu 2020-04-04gnu: IBus: Build with 'gettext-minimal'....* gnu/packages/ibus.scm (ibus)[native-inputs]: Change from GNU-GETTEXT to GETTEXT-MINIMAL. Marius Bakke 2020-04-04gnu: ibus: Make some inputs native....* gnu/packages/ibus.scm (ibus)[inputs]: Move gettext from here... [native-inputs]: ...to here. Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> Vincent Legoll 2020-03-04gnu: ibus: Update to 1.5.22....* gnu/packages/ibus.scm (ibus): Update to 1.5.22. Marius Bakke 2020-02-03gnu: ibus: Use new ucd package....* gnu/packages/ibus.scm (ibus)[native-inputs]: Add ucd; remove unicode-nameslist and unicode-blocks. [arguments]: Update configure flags and remove prepare-ucd-dir phase. Signed-off-by: Ricardo Wurmus <rekado@elephly.net> Leo Prikler 2020-02-03gnu: ibus: Disable parallel build....* gnu/packages/ibus.scm (ibus)[arguments]: Disable parallel build. Signed-off-by: Ricardo Wurmus <rekado@elephly.net> Leo Prikler 2020-02-03gnu: ibus: Build with emoji support....* gnu/packages/ibus.scm (ibus)[native-inputs]: Add unicode-emoji and unicode-cldr-common. [arguments]<configure-flags>: Use list instead of quote. Add flags for unicode-emoji-dir and emoji-annotation-dir. Signed-off-by: Ricardo Wurmus <rekado@elephly.net> Leo Prikler 2020-01-06gnu: ibus-rime: Record the right file name in "rime.xml"....* gnu/packages/ibus.scm (ibus-rime)[arguments]: Add 'fix-file-names' phase. Co-authored-by: Ludovic Courtès <ludo@gnu.org> kanichos@yandex.ru 2020-01-03gnu: Add ibus-libhangul....* gnu/packages/ibus.scm (ibus-libhangul): New variable. Signed-off-by: Ricardo Wurmus <rekado@elephly.net> kanichos@yandex.ru 2020-01-03gnu: Add libhangul....* gnu/packages/ibus.scm (libhangul): New variable. Signed-off-by: Ricardo Wurmus <rekado@elephly.net> kanichos@yandex.ru 2020-01-02gnu: ibus: Update to 1.5.21....* gnu/packages/ibus.scm (ibus): Update to 1.5.21. Ricardo Wurmus 2020-01-01gnu: ibus: Fix substitution....* gnu/packages/ibus.scm (ibus)[arguments]: Fix command substitution. Signed-off-by: Ricardo Wurmus <rekado@elephly.net> kanichos@yandex.ru 2019-11-11gnu: ibus-libpinyin: Update to 1.11.1....* gnu/packages/ibus.scm (ibus-libpinyin): Update to 1.11.1. Tobias Geerinckx-Rice 2019-07-31gnu: Remove workarounds for <https://bugs.gnu.org/36721>....These are no longer needed since 941ef1a1e54893ca917ebbaa4b8cc14b5ce9b75c. * gnu/packages/compression.scm (innoextract)[arguments]: Remove "-DBoost_NO_BOOST_CMAKE=ON" from <#:configure-flags>. * gnu/packages/game-development.scm (openmw)[arguments]: Likewise. * gnu/packages/games.scm (supertux, colobot, leela-zero)[arguments]: Likewise. * gnu/packages/graphics.scm (openimageio)[arguments]: Likewise. * gnu/packages/ibus.scm (librime)[arguments]: Likewise. Marius Bakke 2019-07-19gnu: librime: Update to 1.5.3....* gnu/packages/ibus.scm (librime): Update to 1.5.3. [arguments]: Add <#:configure-flags>. Marius Bakke