diff options
author | Ludovic Courtès <ludo@gnu.org> | 2019-06-06 13:36:51 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2019-06-07 21:50:18 +0200 |
commit | 15ec93a7832ae7dde747ccd9bb2bb2776be9f199 (patch) | |
tree | c6b97d333950ec8ad734624244586cb60ca7e47d /gnu/system | |
parent | bc48088b14a4513044f87ce656db6945311c40d6 (diff) | |
download | guix-15ec93a7832ae7dde747ccd9bb2bb2776be9f199.tar.gz |
Add (gnu build locale).
* gnu/build/locale.scm: New file. * gnu/local.mk (MODULES_NOT_COMPILED): Add it. * gnu/installer/locale.scm (normalize-codeset): Remove. * gnu/system/locale.scm (localedef-command): Remove. (single-locale-directory): Use (gnu build locale). (glibc-supported-locales)[build]: Likewise, and remove 'read-supported-locales'.
Diffstat (limited to 'gnu/system')
-rw-r--r-- | gnu/system/locale.scm | 83 |
1 files changed, 26 insertions, 57 deletions
diff --git a/gnu/system/locale.scm b/gnu/system/locale.scm index 533a45e149..8466d5b07d 100644 --- a/gnu/system/locale.scm +++ b/gnu/system/locale.scm @@ -85,20 +85,6 @@ or #f on failure." (_ #f))) -(define* (localedef-command locale - #:key (libc (canonical-package glibc))) - "Return a gexp that runs 'localedef' from LIBC to build LOCALE." - #~(begin - (format #t "building locale '~a'...~%" - #$(locale-definition-name locale)) - (zero? (system* (string-append #+libc "/bin/localedef") - "--no-archive" "--prefix" #$output - "-i" #$(locale-definition-source locale) - "-f" #$(locale-definition-charset locale) - (string-append #$output "/" #$(version-major+minor - (package-version libc)) - "/" #$(locale-definition-name locale)))))) - (define* (single-locale-directory locales #:key (libc (canonical-package glibc))) "Return a directory containing all of LOCALES for LIBC compiled. @@ -110,17 +96,29 @@ of LIBC." (version-major+minor (package-version libc))) (define build - #~(begin - (mkdir #$output) - - (mkdir (string-append #$output "/" #$version)) - - ;; 'localedef' executes 'gzip' to access compressed locale sources. - (setenv "PATH" (string-append #$gzip "/bin")) - - (exit - (and #$@(map (cut localedef-command <> #:libc libc) - locales))))) + (with-imported-modules (source-module-closure + '((gnu build locale))) + #~(begin + (use-modules (gnu build locale)) + + (mkdir #$output) + (mkdir (string-append #$output "/" #$version)) + + ;; 'localedef' executes 'gzip' to access compressed locale sources. + (setenv "PATH" + (string-append #$gzip "/bin:" #$libc "/bin")) + + (setvbuf (current-output-port) 'line) + (setvbuf (current-error-port) 'line) + (for-each (lambda (locale codeset name) + (build-locale locale + #:codeset codeset + #:name name + #:directory + (string-append #$output "/" #$version))) + '#$(map locale-definition-source locales) + '#$(map locale-definition-charset locales) + '#$(map locale-definition-name locales))))) (computed-file (string-append "locale-" version) build)) @@ -216,45 +214,16 @@ pairs such as (\"oc_FR.UTF-8\" . \"UTF-8\"). Each pair corresponds to a locale supported by GLIBC." (define build (with-imported-modules (source-module-closure - '((guix build gnu-build-system))) + '((guix build gnu-build-system) + (gnu build locale))) #~(begin (use-modules (guix build gnu-build-system) - (srfi srfi-1) - (ice-9 rdelim) - (ice-9 match) - (ice-9 regex) + (gnu build locale) (ice-9 pretty-print)) (define unpack (assq-ref %standard-phases 'unpack)) - (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)))))))) (setenv "PATH" (string-append #+(file-append tar "/bin") ":" |