From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Locale of build environments Date: Fri, 27 Feb 2015 11:36:52 +0100 Message-ID: <87mw3ztzcr.fsf@gnu.org> References: <20150210201452.GA15529@debian> <87h9urt50j.fsf@netris.org> <87mw4iq3uz.fsf_-_@gnu.org> <87bnkgw9fn.fsf@gnu.org> <87y4nk6xv1.fsf@netris.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRIHy-0000ab-Oq for guix-devel@gnu.org; Fri, 27 Feb 2015 05:37:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YRIHv-0004F6-CR for guix-devel@gnu.org; Fri, 27 Feb 2015 05:36:58 -0500 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:49755) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRIHv-0004F0-9H for guix-devel@gnu.org; Fri, 27 Feb 2015 05:36:55 -0500 In-Reply-To: <87y4nk6xv1.fsf@netris.org> (Mark H. Weaver's message of "Thu, 26 Feb 2015 18:45:22 -0500") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Mark H Weaver Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mark H Weaver skribis: > ludo@gnu.org (Ludovic Court=C3=A8s) writes: > >> Commit 5335c56 adds an =E2=80=98install-locale=E2=80=99 phase to gnu-bui= ld-system and >> the next one adds glibc-utf8-locale to the implicit inputs. >> >> During bootstrap, locales aren=E2=80=99t available so we=E2=80=99re stil= l 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=E2=80=93i.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=E2=80=99s not strictly necessary but it=E2=80=99s probabl= y a good idea. Like this? --=-=-= Content-Type: text/x-patch Content-Disposition: inline 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) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >> The remain thing that needs to be done is =E2=80=98graft-derivation=E2= =80=99. > > Okay, I'll work on it. I also want to optimize grafting. Excellent. Thanks for your feedback! Ludo=E2=80=99. --=-=-=--