From: "Ludovic Courtès" <ludo@gnu.org>
To: Efraim Flashner <efraim@flashner.co.il>
Cc: 44075@debbugs.gnu.org
Subject: [bug#44075] [PATCH] gnu: Add make-glibc-locales-collection.
Date: Wed, 21 Oct 2020 19:09:06 +0200 [thread overview]
Message-ID: <878sbz1p71.fsf@gnu.org> (raw)
In-Reply-To: <20201019064739.4736-1-efraim@flashner.co.il> (Efraim Flashner's message of "Mon, 19 Oct 2020 09:47:39 +0300")
[-- Attachment #1: Type: text/plain, Size: 574 bytes --]
Hi!
Efraim Flashner <efraim@flashner.co.il> skribis:
> * gnu/packages/base.scm (make-glibc-locales-collection): New macro.
> (en_us-glibc-locales): New variable.
Cool!
A while back I posted the attached patch, which reuses existing code
from (gnu system locale) and (gnu packages base). I think I used it
just to see how much space all the UTF-8 locales take, compared to all
the locales.
Would it make sense to borrow from that?
At any rate, it’s the kind of package that’ll be more useful if/when we
have parameterized packages.
Ludo’.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 3868 bytes --]
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index c83775d8ee..3fc43b04da 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -53,6 +53,8 @@
#:use-module (gnu packages python)
#:use-module (gnu packages gettext)
#:use-module (guix utils)
+ #:use-module (guix gexp)
+ #:use-module (guix modules)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix git-download)
@@ -62,6 +64,8 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (glibc
+ %default-utf8-locales
+ make-glibc-utf8-locales
libiconv-if-needed))
;;; Commentary:
@@ -1106,7 +1110,12 @@ to the @code{share/locale} sub-directory of this package.")
,(version-major+minor
(package-version glibc)))))))))))
-(define-public (make-glibc-utf8-locales glibc)
+(define %default-utf8-locales
+ '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
+
+(define* (make-glibc-utf8-locales glibc #:optional
+ (locales %default-utf8-locales)
+ (locale-file #f))
(package
(name "glibc-utf8-locales")
(version (package-version glibc))
@@ -1145,10 +1154,17 @@ to the @code{share/locale} sub-directory of this package.")
;; These are the locales commonly used for
;; tests---e.g., in Guile's i18n tests.
- '("de_DE" "el_GR" "en_US" "fr_FR" "tr_TR"))
+ ,(if locale-file
+ `(call-with-input-file
+ (assoc-ref %build-inputs "locale-file")
+ read)
+ `',locales))
#t))))
(native-inputs `(("glibc" ,glibc)
- ("gzip" ,gzip)))
+ ("gzip" ,gzip)
+ ,@(if locale-file
+ `(("locale-file" ,locale-file))
+ '())))
(synopsis "Small sample of UTF-8 locales")
(description
"This package provides a small sample of UTF-8 locales mostly useful in
@@ -1169,6 +1185,40 @@ test environments.")
(package (inherit (make-glibc-utf8-locales glibc-2.29))
(name "glibc-utf8-locales-2.29")))
+(define (glibc-supported-locales libc)
+ ((module-ref (resolve-interface '(gnu system locale)) ;FIXME: hack
+ 'glibc-supported-locales)
+ libc))
+
+(define* (make-glibc-utf8-locales/full #:optional (glibc glibc))
+ (define utf8-locales
+ (computed-file "glibc-supported-utf8-locales.scm"
+ #~(begin
+ (use-modules (srfi srfi-1)
+ (ice-9 match)
+ (ice-9 pretty-print))
+
+ (define locales
+ (call-with-input-file
+ #+(glibc-supported-locales glibc)
+ read))
+
+ (define utf8-locales
+ (filter-map (match-lambda
+ ((name . "UTF-8")
+ (if (string-suffix? ".UTF-8" name)
+ (string-drop-right name 6)
+ name))
+ (_ #f))
+ locales))
+
+ (call-with-output-file #$output
+ (lambda (port)
+ (pretty-print utf8-locales port))))))
+
+ (make-glibc-utf8-locales glibc #:locale-file utf8-locales))
+
+\f
(define-public which
(package
(name "which")
next prev parent reply other threads:[~2020-10-21 17:15 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
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 [this message]
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878sbz1p71.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=44075@debbugs.gnu.org \
--cc=efraim@flashner.co.il \
/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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).