Mark H Weaver <m...@netris.org> skribis: > l...@gnu.org (Ludovic Courtès) writes: > >> Commit 5335c56 adds an ‘install-locale’ phase to gnu-build-system and >> the next one adds glibc-utf8-locale to the implicit inputs. >> >> During bootstrap, locales aren’t available so we’re still running on the >> C locale, which is fine in practice because we only get to deal with >> ASCII file names at that point and do not need UTF-8 for tests or >> anything. >> >> Commit 9cca706 adjust patch-and-repack to use UTF-8 as well when >> possible–i.e., not during bootstrap. > > Thanks! > > However, there's a missing piece: I think we should set LANG to the > chosen locale, otherwise the top-level guile builder will be the only > process that uses UTF-8. What do you think?
Yes, why not. It’s not strictly necessary but it’s probably a good idea. Like this?
diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm index c3cc3ce..a2bd9d4 100644 --- a/guix/build/gnu-build-system.scm +++ b/guix/build/gnu-build-system.scm @@ -106,8 +106,12 @@ chance to be set." (catch 'system-error (lambda () (setlocale locale-category locale) - (format (current-error-port) "using '~a' locale for category ~a~%" - locale locale-category) + + ;; While we're at it, pass it to sub-processes. + (setenv (locale-category->string locale-category) locale) + + (format (current-error-port) "using '~a' locale for category ~s~%" + locale (locale-category->string locale-category)) #t) (lambda args ;; This is known to fail for instance in early bootstrap where locales diff --git a/guix/build/utils.scm b/guix/build/utils.scm index f24ed47..f43451b 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -21,6 +21,7 @@ (define-module (guix build utils) #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) + #:use-module (srfi srfi-60) #:use-module (ice-9 ftw) #:use-module (ice-9 match) #:use-module (ice-9 regex) @@ -65,7 +66,9 @@ patch-/usr/bin/file fold-port-matches remove-store-references - wrap-program)) + wrap-program + + locale-category->string)) ;;; @@ -909,6 +912,27 @@ the previous wrapper." (symlink wrapper prog-tmp) (rename-file prog-tmp prog))) + +;;; +;;; Locales. +;;; + +(define (locale-category->string category) + "Return the name of locale category CATEGORY, one of the 'LC_' constants. +If CATEGORY is a bitwise or of several 'LC_' constants, an approximation is +returned." + (letrec-syntax ((convert (syntax-rules () + ((_) + (number->string category)) + ((_ first rest ...) + (if (= first category) + (symbol->string 'first) + (convert rest ...)))))) + (convert LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE + LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY + LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE + LC_TIME))) + ;;; Local Variables: ;;; eval: (put 'call-with-output-file/atomic 'scheme-indent-function 1) ;;; eval: (put 'call-with-ascii-input-file 'scheme-indent-function 1)
>> The remain thing that needs to be done is ‘graft-derivation’. > > Okay, I'll work on it. I also want to optimize grafting. Excellent. Thanks for your feedback! Ludo’.