From: Efraim Flashner <efraim@flashner.co.il>
To: "Miguel Ángel Arruga Vivas" <rosen644835@gmail.com>
Cc: 44075@debbugs.gnu.org
Subject: [bug#44075] [PATCH] gnu: Add make-glibc-locales-collection.
Date: Mon, 19 Oct 2020 17:02:36 +0300 [thread overview]
Message-ID: <20201019140236.GF9117@E5400> (raw)
In-Reply-To: <87tuuqnym5.fsf@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 3051 bytes --]
On Mon, Oct 19, 2020 at 03:17:54PM +0200, Miguel Ángel Arruga Vivas wrote:
> Hi Efraim,
>
> I've been taking a look into your patch. One issue are the comments
> about utf8 and UTF-8, as the issue is already explained in
> make-glibc[-utf8]-locales.
Thanks for taking a look. For the utf8 vs UTF-8 there are a couple of
comments in the code:
The above phase does not install locales with names using
the "normalized codeset." Thus, create symlinks like:
en_US.utf8 -> en_US.UTF-8
and also:
For backward compatibility with Guix
<= 0.8.3, add "xx_YY.UTF-8".
When I check on one of my Debian boxes:
$localectl list-locales
C.UTF-8
en_US.utf8
I've learned that 'C.UTF-8' isn't from upstream, Debian has a patch for
it. Having written this patch a week or so ago and returning to it I
can't tell you which is the correct one. I think it's best to offer both
so it's not confusing which is correct. That works for the logic for
accepting either in the list of locales, but I'm concerned that skipping
the symlink to the other one could cause problems.
>
> Other point is:
>
> Efraim Flashner <efraim@flashner.co.il> writes:
> > +(define* (make-glibc-locales-collection
> > + glibc
> > + #:optional (locales
> > + '(list "en_US.utf8" "en_US.ISO-8859-1")))
> > (... Removed for clarity ...)
> > + ,locales)
>
> I would have used list there like (list ,@locales) or '(,@locales), this
> looks a bit odd to my eyes at least. I'd expect this kind of calling code:
>
> (let ((locales '("de_CH.utf8" ... "de_DE.utf8"))
> (my-glibc ...))
> (make-glibc-locales-collection myglibc locales))
>
> Enforcing an extra quotation for no real reason on the calling site, as
> strings are self-evaluating objects, and the use of the symbol list,
> whose meaning depends on other context of execution, doesn't seem
> necessary. Even worse, my example would raise an error as "de_CH.utf8"
> is not a procedure.
My scheme-foo isn't terribly strong, sometimes I just hack at it until
the code does what I want, and this is one of those times. I've changed
it so that locales takes a list and not an item that is a list.
> What do you think about replacing make-glibc-utf8-locales with a call of
> the new function (using that code) ensuring that the generated
> derivation stays the same for that case (i.e. it's optimized for the
> UTF-8 case)?
This is what I originally wanted to do, but there's a glibc-locales
buried in the bootstrap path so it's not so easy to just swap it out. I
can make the change in core-updates. I'll play around with it and see if
I can come out with the same derivation using a different function, but
I'm not expecting it to turn out identical.
>
> Happy hacking!
> Miguel
>
--
Efraim Flashner <efraim@flashner.co.il> אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[-- Attachment #1.2: v2-0001-gnu-Add-make-glibc-locales-collection.patch --]
[-- Type: text/plain, Size: 4646 bytes --]
From 3c2dfe702ad1c62b2f73a1f1036da3bcfa007c15 Mon Sep 17 00:00:00 2001
From: Efraim Flashner <efraim@flashner.co.il>
Date: Thu, 1 Oct 2020 22:50:32 +0300
Subject: [PATCH v2] gnu: Add make-glibc-locales-collection.
* gnu/packages/base.scm (make-glibc-locales-collection): New macro.
(en_us-glibc-locales): New variable.
---
gnu/packages/base.scm | 73 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 72 insertions(+), 1 deletion(-)
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index c83775d8ee..4ea31c2ab6 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -62,7 +62,8 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (glibc
- libiconv-if-needed))
+ libiconv-if-needed
+ make-custom-glibc-locales))
;;; Commentary:
;;;
@@ -1106,6 +1107,69 @@ to the @code{share/locale} sub-directory of this package.")
,(version-major+minor
(package-version glibc)))))))))))
+(define* (make-glibc-locales-collection
+ glibc
+ #:optional (locales
+ (list "en_US.utf8" "en_US.ISO-8859-1")))
+ ;; This list for testing
+ ;(list "el_GR.UTF-8" "en_US.utf8" "he_IL.ISO-8859-8" "ja_JP.EUC-JP" "zh_CN.GB18030" "zh_CN.GBK" "hy_AM.ARMSCII-8")))
+ (package
+ (name "glibc-locales-collection")
+ (version (package-version glibc))
+ (source #f)
+ (build-system trivial-build-system)
+ (arguments
+ `(#:modules ((guix build utils))
+ #:builder
+ (begin
+ (use-modules (guix build utils))
+
+ (let* ((libc (assoc-ref %build-inputs "glibc"))
+ (gzip (assoc-ref %build-inputs "gzip"))
+ (out (assoc-ref %outputs "out"))
+ (localedir (string-append out "/lib/locale/"
+ ,(version-major+minor version))))
+ ;; 'localedef' needs 'gzip'.
+ (setenv "PATH" (string-append libc "/bin:" gzip "/bin"))
+
+ (mkdir-p localedir)
+ (for-each
+ (lambda (locale)
+ (let* ((contains-dot? (string-index locale #\.))
+ (encoding-type (substring locale (1+ contains-dot?)))
+ (raw-locale (substring locale 0 contains-dot?))
+ (utf8? (or (number? (string-contains locale ".utf8"))
+ (number? (string-contains locale ".UTF-8"))))
+ (file (if utf8?
+ (string-append localedir "/" raw-locale ".utf8")
+ (if (string-contains locale ".ISO")
+ (string-append localedir "/" raw-locale)
+ (string-append localedir "/" locale)))))
+
+ (invoke "localedef" "--no-archive"
+ "--prefix" localedir
+ "-i" raw-locale
+ "-f" (if (equal? "utf8" encoding-type)
+ "UTF-8"
+ encoding-type)
+ file)
+
+ ;; Is it utf8 or UTF-8? NO ONE KNOWS!
+ (when utf8?
+ (symlink (string-append raw-locale ".utf8")
+ (string-append localedir "/"
+ raw-locale ".UTF-8")))))
+ (list ,@locales))
+ #t))))
+ (native-inputs `(("glibc" ,glibc)
+ ("gzip" ,gzip)))
+ (synopsis "Customizable collection of locales")
+ (description
+ "This package provides a custom collection of locales useful for
+providing exactly the locales requested when size matters.")
+ (home-page (package-home-page glibc))
+ (license (package-license glibc))))
+
(define-public (make-glibc-utf8-locales glibc)
(package
(name "glibc-utf8-locales")
@@ -1161,6 +1225,13 @@ test environments.")
(define-public glibc-utf8-locales
(make-glibc-utf8-locales glibc))
+(define-public en_us-glibc-locales
+ (package
+ (inherit (make-glibc-locales-collection
+ glibc
+ (list "en_US.utf8" "en_US.ISO-8859-1")))
+ (name "en-us-glibc-locales")))
+
;; Packages provided to ease use of binaries linked against the previous libc.
(define-public glibc-locales-2.29
(package (inherit (make-glibc-locales glibc-2.29))
--
2.28.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-10-19 14:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-19 6:47 [bug#44075] [PATCH] gnu: Add make-glibc-locales-collection Efraim Flashner
2020-10-19 13:17 ` Miguel Ángel Arruga Vivas
2020-10-19 14:02 ` Efraim Flashner [this message]
2020-10-19 17:43 ` Miguel Ángel Arruga Vivas
2020-10-21 7:01 ` Efraim Flashner
2020-10-21 23:18 ` Miguel Ángel Arruga Vivas
2020-10-21 17:09 ` Ludovic Courtès
2020-11-04 16:12 ` Miguel Ángel Arruga Vivas
2020-11-06 15:58 ` Ludovic Courtès
2020-11-18 22:10 ` Ludovic Courtès
2021-01-07 12:00 ` Miguel Ángel Arruga Vivas
2020-12-24 9:38 ` bdju--- via Guix-patches via
2020-12-24 22:04 ` Leo Famulari
2020-12-24 22:05 ` Leo Famulari
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201019140236.GF9117@E5400 \
--to=efraim@flashner.co.il \
--cc=44075@debbugs.gnu.org \
--cc=rosen644835@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.