GNU bug report logs -
#22572
Handling of system 'locale' field needs improvement
Previous Next
Reported by: Mark H Weaver <mhw <at> netris.org>
Date: Sat, 6 Feb 2016 14:23:01 UTC
Severity: normal
Done: ludo <at> gnu.org (Ludovic Courtès)
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 22572 in the body.
You can then email your comments to 22572 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guix <at> gnu.org
:
bug#22572
; Package
guix
.
(Sat, 06 Feb 2016 14:23:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Mark H Weaver <mhw <at> netris.org>
:
New bug report received and forwarded. Copy sent to
bug-guix <at> gnu.org
.
(Sat, 06 Feb 2016 14:23:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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
Information forwarded
to
bug-guix <at> gnu.org
:
bug#22572
; Package
guix
.
(Sun, 07 Feb 2016 21:20:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 22572 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Mark H Weaver <mhw <at> netris.org> 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’t always work (the locale name is supposed
to use the normalized name, like “utf8”, whereas the real name is, say,
“UTF-8”), but it should cover 90% of the use cases.
[Message part 2 (text/x-patch, inline)]
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 locale for the machine
using the @code{locale} field of the @code{operating-system} declaration
(@pxref{operating-system Reference, @code{locale}}).
-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.
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))
- (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)))
(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 © 2014, 2015 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo <at> gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -33,6 +33,7 @@
locale-definition-source
locale-definition-charset
+ locale-name->definition
locale-directory
%default-locale-libcs
@@ -52,6 +53,22 @@
(charset locale-definition-charset ;string--e.g., "UTF-8"
(default "UTF-8")))
+(define %not-dot
+ (char-set-complement (char-set #\.)))
+
+(define (locale-name->definition name)
+ "Return a <locale-definition> corresponding to NAME, guessing the charset,
+or #f on failure."
+ (match (string-tokenize name %not-dot)
+ ((source charset)
+ (locale-definition (name name)
+ (source source)
+ (charset (if (string-ci=? 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."
[Message part 3 (text/plain, inline)]
Thanks,
Ludo’.
Reply sent
to
ludo <at> gnu.org (Ludovic Courtès)
:
You have taken responsibility.
(Wed, 10 Feb 2016 14:21:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Mark H Weaver <mhw <at> netris.org>
:
bug acknowledged by developer.
(Wed, 10 Feb 2016 14:21:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 22572-done <at> debbugs.gnu.org (full text, mbox):
ludo <at> gnu.org (Ludovic Courtès) skribis:
> Mark H Weaver <mhw <at> netris.org> 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’t always work (the locale name is supposed
> to use the normalized name, like “utf8”, whereas the real name is, say,
> “UTF-8”), but it should cover 90% of the use cases.
I pushed an improved version of the patch as f5582b2.
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 10 Mar 2016 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 49 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.