From unknown Sun Jun 22 20:59:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22572: Handling of system 'locale' field needs improvement Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 06 Feb 2016 14:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22572 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 22572@debbugs.gnu.org X-Debbugs-Original-To: bug-guix@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.14547685539566 (code B ref -1); Sat, 06 Feb 2016 14:23:01 +0000 Received: (at submit) by debbugs.gnu.org; 6 Feb 2016 14:22:33 +0000 Received: from localhost ([127.0.0.1]:35204 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aS3kv-0002UE-93 for submit@debbugs.gnu.org; Sat, 06 Feb 2016 09:22:33 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52776) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aS3ku-0002Ty-1n for submit@debbugs.gnu.org; Sat, 06 Feb 2016 09:22:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aS3ko-0005LQ-8q for submit@debbugs.gnu.org; Sat, 06 Feb 2016 09:22:26 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:51283) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aS3ko-0005LK-5o for submit@debbugs.gnu.org; Sat, 06 Feb 2016 09:22:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aS3kn-000778-8Q for bug-guix@gnu.org; Sat, 06 Feb 2016 09:22:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aS3kj-0005HY-W3 for bug-guix@gnu.org; Sat, 06 Feb 2016 09:22:25 -0500 Received: from world.peace.net ([50.252.239.5]:44525) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aS3kj-0005H4-ST for bug-guix@gnu.org; Sat, 06 Feb 2016 09:22:21 -0500 Received: from [10.1.10.78] (helo=jojen) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1aS3kd-0006Kl-G5; Sat, 06 Feb 2016 09:22:15 -0500 From: Mark H Weaver Date: Sat, 06 Feb 2016 09:22:14 -0500 Message-ID: <87k2mhudex.fsf@netris.org> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Multiple users on #guix have been bitten by the following error message: guix system: error: system locale lacks a definition and even several seasoned developers on #guix didn't know the answer. At minimum, the error message should be improved to point to the relevant documentation. Better yet, the value of the 'locale' field should be automatically added to the default value of 'locale-definitions' if it's not already there. The overwhelming majority of users set their 'locale' and have no interest in 'locale-definitions'. Regards, Mark From unknown Sun Jun 22 20:59:03 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22572: Handling of system 'locale' field needs improvement Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sun, 07 Feb 2016 21:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22572 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Mark H Weaver Cc: 22572@debbugs.gnu.org Received: via spool by 22572-submit@debbugs.gnu.org id=B22572.14548799967597 (code B ref 22572); Sun, 07 Feb 2016 21:20:02 +0000 Received: (at 22572) by debbugs.gnu.org; 7 Feb 2016 21:19:56 +0000 Received: from localhost ([127.0.0.1]:37619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aSWkN-0001yT-Sd for submit@debbugs.gnu.org; Sun, 07 Feb 2016 16:19:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:40866) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aSWkM-0001yH-Oi for 22572@debbugs.gnu.org; Sun, 07 Feb 2016 16:19:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSWkE-0001ip-F5 for 22572@debbugs.gnu.org; Sun, 07 Feb 2016 16:19:49 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:44794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSWkE-0001il-BI; Sun, 07 Feb 2016 16:19:46 -0500 Received: from reverse-83.fdn.fr ([80.67.176.83]:52640 helo=pluto) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aSWkC-000174-SS; Sun, 07 Feb 2016 16:19:45 -0500 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <87k2mhudex.fsf@netris.org> Date: Sun, 07 Feb 2016 22:19:42 +0100 In-Reply-To: <87k2mhudex.fsf@netris.org> (Mark H. Weaver's message of "Sat, 06 Feb 2016 09:22:14 -0500") Message-ID: <871t8orzf5.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.3 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.3 (-----) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mark H Weaver skribis: > Better yet, the value of the 'locale' field should be automatically > added to the default value of 'locale-definitions' if it's not already > there. The overwhelming majority of users set their 'locale' and have > no interest in 'locale-definitions'. What about this? This is not ideal in that it guesses the charset based on the locale name, which won=E2=80=99t always work (the locale name is sup= posed to use the normalized name, like =E2=80=9Cutf8=E2=80=9D, whereas the real n= ame is, say, =E2=80=9CUTF-8=E2=80=9D), but it should cover 90% of the use cases. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable diff --git a/doc/guix.texi b/doc/guix.texi index 66ab384..f35a9fe 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6452,11 +6452,12 @@ Usually, you will want to specify the default local= e for the machine using the @code{locale} field of the @code{operating-system} declaration (@pxref{operating-system Reference, @code{locale}}). =20 -That locale must be among the @dfn{locale definitions} that are known to -the system---and these are specified in the @code{locale-definitions} -slot of @code{operating-system}. The default value includes locale -definitions for some widely used locales, but not for all the available -locales, in order to save space. +The selected locale is automatically added to the @dfn{locale +definitions} known to the system. Additional locale definitions can be +specified in the @code{locale-definitions} slot of +@code{operating-system}. The default value includes locale definitions +for some widely used locales, but not for all the available locales, in +order to save space. =20 If the locale specified in the @code{locale} field is not among the definitions listed in @code{locale-definitions}, @command{guix system} diff --git a/gnu/system.scm b/gnu/system.scm index d4759a0..324d071 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -669,14 +669,25 @@ hardware-related operations as necessary when booting= a Linux container." "Return the directory containing the locales compiled for the definitions listed in OS. The C library expects to find it under /run/current-system/locale." - ;; While we're at it, check whether the locale of OS is defined. - (unless (member (operating-system-locale os) - (map locale-definition-name - (operating-system-locale-definitions os))) - (raise (condition - (&message (message "system locale lacks a definition"))))) + (define name + (operating-system-locale os)) =20 - (locale-directory (operating-system-locale-definitions os) + (define definitions + ;; While we're at it, check whether the locale of OS is defined. + (if (member (operating-system-locale os) + (map locale-definition-name + (operating-system-locale-definitions os))) + (operating-system-locale-definitions os) + (cons (match (locale-name->definition name) + (#f + (raise (condition + (&message + (message (format #f (_ "~a: invalid locale name") + name)))))) + (def def)) + (operating-system-locale-definitions os)))) + + (locale-directory definitions #:libcs (operating-system-locale-libcs os))) =20 (define (kernel->grub-label kernel) diff --git a/gnu/system/locale.scm b/gnu/system/locale.scm index e798827..9d695b3 100644 --- a/gnu/system/locale.scm +++ b/gnu/system/locale.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright =C2=A9 2014, 2015 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2014, 2015, 2016 Ludovic Court=C3=A8s ;;; ;;; This file is part of GNU Guix. ;;; @@ -33,6 +33,7 @@ locale-definition-source locale-definition-charset =20 + locale-name->definition locale-directory =20 %default-locale-libcs @@ -52,6 +53,22 @@ (charset locale-definition-charset ;string--e.g., "UTF-8" (default "UTF-8"))) =20 +(define %not-dot + (char-set-complement (char-set #\.))) + +(define (locale-name->definition name) + "Return a corresponding to NAME, guessing the charse= t, +or #f on failure." + (match (string-tokenize name %not-dot) + ((source charset) + (locale-definition (name name) + (source source) + (charset (if (string-ci=3D? charset "utf8") + "UTF-8" + charset)))) + (_ + #f))) + (define* (localedef-command locale #:key (libc (canonical-package glibc))) "Return a gexp that runs 'localedef' from LIBC to build LOCALE." --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: base64 DQpUaGFua3MsDQpMdWRv4oCZLg0K --=-=-=-- From unknown Sun Jun 22 20:59:03 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Mark H Weaver Subject: bug#22572: closed (Re: bug#22572: Handling of system 'locale' field needs improvement) Message-ID: References: <87k2mclk96.fsf@gnu.org> <87k2mhudex.fsf@netris.org> X-Gnu-PR-Message: they-closed 22572 X-Gnu-PR-Package: guix Reply-To: 22572@debbugs.gnu.org Date: Wed, 10 Feb 2016 14:21:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1455114062-28084-1" This is a multi-part message in MIME format... ------------=_1455114062-28084-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #22572: Handling of system 'locale' field needs improvement which was filed against the guix package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 22572@debbugs.gnu.org. --=20 22572: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D22572 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1455114062-28084-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 22572-done) by debbugs.gnu.org; 10 Feb 2016 14:20:52 +0000 Received: from localhost ([127.0.0.1]:34348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aTVdT-0007IO-Nt for submit@debbugs.gnu.org; Wed, 10 Feb 2016 09:20:51 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45176) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aTVdR-0007I9-UK for 22572-done@debbugs.gnu.org; Wed, 10 Feb 2016 09:20:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTVdI-0005ER-Qz for 22572-done@debbugs.gnu.org; Wed, 10 Feb 2016 09:20:44 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:37085) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTVdI-0005EM-Mu; Wed, 10 Feb 2016 09:20:40 -0500 Received: from reverse-83.fdn.fr ([80.67.176.83]:58492 helo=pluto) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aTVdH-0000dR-KA; Wed, 10 Feb 2016 09:20:40 -0500 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) To: Mark H Weaver Subject: Re: bug#22572: Handling of system 'locale' field needs improvement References: <87k2mhudex.fsf@netris.org> <871t8orzf5.fsf@gnu.org> Date: Wed, 10 Feb 2016 15:20:37 +0100 In-Reply-To: <871t8orzf5.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Sun, 07 Feb 2016 22:19:42 +0100") Message-ID: <87k2mclk96.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.3 (-----) X-Debbugs-Envelope-To: 22572-done Cc: 22572-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.3 (-----) ludo@gnu.org (Ludovic Court=C3=A8s) skribis: > Mark H Weaver skribis: > >> Better yet, the value of the 'locale' field should be automatically >> added to the default value of 'locale-definitions' if it's not already >> there. The overwhelming majority of users set their 'locale' and have >> no interest in 'locale-definitions'. > > What about this? This is not ideal in that it guesses the charset based > on the locale name, which won=E2=80=99t always work (the locale name is s= upposed > to use the normalized name, like =E2=80=9Cutf8=E2=80=9D, whereas the real= name is, say, > =E2=80=9CUTF-8=E2=80=9D), but it should cover 90% of the use cases. I pushed an improved version of the patch as f5582b2. Ludo=E2=80=99. ------------=_1455114062-28084-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 6 Feb 2016 14:22:33 +0000 Received: from localhost ([127.0.0.1]:35204 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aS3kv-0002UE-93 for submit@debbugs.gnu.org; Sat, 06 Feb 2016 09:22:33 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52776) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aS3ku-0002Ty-1n for submit@debbugs.gnu.org; Sat, 06 Feb 2016 09:22:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aS3ko-0005LQ-8q for submit@debbugs.gnu.org; Sat, 06 Feb 2016 09:22:26 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:51283) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aS3ko-0005LK-5o for submit@debbugs.gnu.org; Sat, 06 Feb 2016 09:22:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aS3kn-000778-8Q for bug-guix@gnu.org; Sat, 06 Feb 2016 09:22:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aS3kj-0005HY-W3 for bug-guix@gnu.org; Sat, 06 Feb 2016 09:22:25 -0500 Received: from world.peace.net ([50.252.239.5]:44525) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aS3kj-0005H4-ST for bug-guix@gnu.org; Sat, 06 Feb 2016 09:22:21 -0500 Received: from [10.1.10.78] (helo=jojen) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1aS3kd-0006Kl-G5; Sat, 06 Feb 2016 09:22:15 -0500 From: Mark H Weaver To: bug-guix@gnu.org Subject: Handling of system 'locale' field needs improvement Date: Sat, 06 Feb 2016 09:22:14 -0500 Message-ID: <87k2mhudex.fsf@netris.org> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Multiple users on #guix have been bitten by the following error message: guix system: error: system locale lacks a definition and even several seasoned developers on #guix didn't know the answer. At minimum, the error message should be improved to point to the relevant documentation. Better yet, the value of the 'locale' field should be automatically added to the default value of 'locale-definitions' if it's not already there. The overwhelming majority of users set their 'locale' and have no interest in 'locale-definitions'. Regards, Mark ------------=_1455114062-28084-1--