From patchwork Mon Oct 19 06:47:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 24685 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 724A227BBEE; Mon, 19 Oct 2020 07:49:08 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 06E9C27BBED for ; Mon, 19 Oct 2020 07:49:08 +0100 (BST) Received: from localhost ([::1]:35750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUOyh-0008Vh-33 for patchwork@mira.cbaines.net; Mon, 19 Oct 2020 02:49:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUOyc-0008VZ-GC for guix-patches@gnu.org; Mon, 19 Oct 2020 02:49:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56413) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUOyc-0002Kl-5z for guix-patches@gnu.org; Mon, 19 Oct 2020 02:49:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kUOyc-0000kK-47 for guix-patches@gnu.org; Mon, 19 Oct 2020 02:49:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#44075] [PATCH] gnu: Add make-glibc-locales-collection. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 19 Oct 2020 06:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 44075 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 44075@debbugs.gnu.org Cc: Efraim Flashner X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16030900982806 (code B ref -1); Mon, 19 Oct 2020 06:49:01 +0000 Received: (at submit) by debbugs.gnu.org; 19 Oct 2020 06:48:18 +0000 Received: from localhost ([127.0.0.1]:39726 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kUOxu-0000jC-2s for submit@debbugs.gnu.org; Mon, 19 Oct 2020 02:48:18 -0400 Received: from lists.gnu.org ([209.51.188.17]:52736) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kUOxs-0000j5-Hq for submit@debbugs.gnu.org; Mon, 19 Oct 2020 02:48:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUOxs-0008Rs-8O for guix-patches@gnu.org; Mon, 19 Oct 2020 02:48:16 -0400 Received: from flashner.co.il ([178.62.234.194]:34268) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUOxq-00025P-GF for guix-patches@gnu.org; Mon, 19 Oct 2020 02:48:15 -0400 Received: from localhost (unknown [141.226.13.8]) by flashner.co.il (Postfix) with ESMTPSA id 74D4C4001D; Mon, 19 Oct 2020 06:48:12 +0000 (UTC) From: Efraim Flashner Date: Mon, 19 Oct 2020 09:47:39 +0300 Message-Id: <20201019064739.4736-1-efraim@flashner.co.il> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Received-SPF: pass client-ip=178.62.234.194; envelope-from=efraim@flashner.co.il; helo=flashner.co.il X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 02:48:12 X-ACL-Warn: Detected OS = ??? X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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))