unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#44075] [PATCH] gnu: Add make-glibc-locales-collection.
@ 2020-10-19  6:47 Efraim Flashner
  2020-10-19 13:17 ` Miguel Ángel Arruga Vivas
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Efraim Flashner @ 2020-10-19  6:47 UTC (permalink / raw)
  To: 44075; +Cc: Efraim Flashner

* 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..41d3aaf865 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")))))
+             ,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





^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-01-07 12:01 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).