summary refs log tree commit diff
path: root/gnu/installer/locale.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-05-13 23:30:51 +0200
committerLudovic Courtès <ludo@gnu.org>2019-05-13 23:46:08 +0200
commit76269f6bc4200ef79aa80a8a6160ae269c2a36c9 (patch)
treeadea56c977be7aec00a919440234932a3ad34110 /gnu/installer/locale.scm
parent1be065c4784805e7a7b4c3f08970d8e4043b0a60 (diff)
downloadguix-76269f6bc4200ef79aa80a8a6160ae269c2a36c9.tar.gz
installer: Use 'glibc-supported-locales'.
The list of locales supported by glibc is now built from source.

* gnu/installer/locale.scm (locale-string->locale): Add optional
'codeset' parameter and honor it.
(supported-locales->locales): Rewrite to 'read' from SUPPORTED-LOCALES.
* gnu/installer.scm (compute-locale-step): Pass the result of
'glibc-supported-locales' instead of the "aux-files/SUPPORTED" file.
* gnu/installer/aux-files/SUPPORTED: Remove.
* gnu/local.mk (dist_installer_DATA): Remove it.
Diffstat (limited to 'gnu/installer/locale.scm')
-rw-r--r--gnu/installer/locale.scm24
1 files changed, 10 insertions, 14 deletions
diff --git a/gnu/installer/locale.scm b/gnu/installer/locale.scm
index 284062a6e7..2ee5eecd96 100644
--- a/gnu/installer/locale.scm
+++ b/gnu/installer/locale.scm
@@ -62,12 +62,13 @@
 (define (locale-modifier assoc)
   (assoc-ref assoc 'modifier))
 
-(define (locale-string->locale string)
-  "Return the locale association list built from the parsing of STRING."
+(define* (locale-string->locale string #:optional codeset)
+  "Return the locale association list built from the parsing of STRING and,
+optionally, CODESET."
   (let ((matches (string-match locale-regexp string)))
     `((language  . ,(match:substring matches 1))
       (territory . ,(match:substring matches 3))
-      (codeset   . ,(match:substring matches 5))
+      (codeset   . ,(or codeset (match:substring matches 5)))
       (modifier  . ,(match:substring matches 7)))))
 
 (define (normalize-codeset codeset)
@@ -107,17 +108,12 @@
                    '())))))
 
 (define (supported-locales->locales supported-locales)
-  "Parse the SUPPORTED-LOCALES file from the glibc and return the matching
-list of LOCALE association lists."
- (call-with-input-file supported-locales
-    (lambda (port)
-      (let ((lines (read-lines port)))
-        (map (lambda (line)
-               (match (string-split line #\ )
-                 ((locale-string codeset)
-                  (let ((line-locale (locale-string->locale locale-string)))
-                    (assoc-set! line-locale 'codeset codeset)))))
-             lines)))))
+  "Given SUPPORTED-LOCALES, a file produced by 'glibc-supported-locales',
+return a list of locales where each locale is an alist."
+  (map (match-lambda
+         ((locale . codeset)
+          (locale-string->locale locale codeset)))
+       (call-with-input-file supported-locales read)))
 
 
 ;;;