From patchwork Thu Jun 6 14:59:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 14249 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 64A32170BB; Thu, 6 Jun 2019 16:00:10 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 19919170B9 for ; Thu, 6 Jun 2019 16:00:09 +0100 (BST) Received: from localhost ([127.0.0.1]:33581 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYts8-0006Ci-LH for patchwork@mira.cbaines.net; Thu, 06 Jun 2019 11:00:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYts4-0006CK-TK for guix-patches@gnu.org; Thu, 06 Jun 2019 11:00:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYts3-0005pM-KF for guix-patches@gnu.org; Thu, 06 Jun 2019 11:00:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36867) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hYts3-0005p8-HK for guix-patches@gnu.org; Thu, 06 Jun 2019 11:00:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hYts3-0004xk-ED for guix-patches@gnu.org; Thu, 06 Jun 2019 11:00:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#36116] [PATCH 2/2] gnu: glibc-locales: Install symlinks using the normalized codeset. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 06 Jun 2019 15:00:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36116 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 36116@debbugs.gnu.org Received: via spool by 36116-submit@debbugs.gnu.org id=B36116.155983319519024 (code B ref 36116); Thu, 06 Jun 2019 15:00:03 +0000 Received: (at 36116) by debbugs.gnu.org; 6 Jun 2019 14:59:55 +0000 Received: from localhost ([127.0.0.1]:50410 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hYtro-0004wf-2i for submit@debbugs.gnu.org; Thu, 06 Jun 2019 10:59:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47210) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hYtrl-0004wG-Ef for 36116@debbugs.gnu.org; Thu, 06 Jun 2019 10:59:45 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:46829) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYtrg-0005PQ-88; Thu, 06 Jun 2019 10:59:40 -0400 Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=44982 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hYtrf-0002cb-OH; Thu, 06 Jun 2019 10:59:40 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Thu, 6 Jun 2019 16:59:27 +0200 Message-Id: <20190606145927.17035-2-ludo@gnu.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190606145927.17035-1-ludo@gnu.org> References: <20190606145927.17035-1-ludo@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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 Fixes . Reported by Jack Hill and Giovanni Biscuolo * gnu/build/locale.scm (locale->name+codeset): New file. * gnu/packages/base.scm (make-glibc-locales): Add #:modules and #:imported-modules. Add a 'symlink-normalized-codesets' phase. --- gnu/build/locale.scm | 9 +++++++++ gnu/packages/base.scm | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/gnu/build/locale.scm b/gnu/build/locale.scm index c75a2e9dc5..412759a320 100644 --- a/gnu/build/locale.scm +++ b/gnu/build/locale.scm @@ -24,6 +24,7 @@ #:use-module (ice-9 regex) #:export (build-locale normalize-codeset + locale->name+codeset read-supported-locales)) (define locale-rx @@ -84,3 +85,11 @@ discarded." (invoke localedef "--no-archive" "--prefix" directory "-i" locale "-f" codeset (string-append directory "/" name))) + +(define (locale->name+codeset locale) + "Split a locale name such as \"aa_ER@saaho.UTF-8\" into two values: the +language/territory/modifier part, and the codeset." + (match (string-rindex locale #\.) + (#f (values locale #f)) + (dot (values (string-take locale dot) + (string-drop locale (+ dot 1)))))) diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm index a941a8f8eb..15f35009a9 100644 --- a/gnu/packages/base.scm +++ b/gnu/packages/base.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès +;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès ;;; Copyright © 2014, 2019 Andreas Enge ;;; Copyright © 2012 Nikita Karetnikov ;;; Copyright © 2014, 2015, 2016, 2018 Mark H Weaver @@ -1050,12 +1050,47 @@ to the @code{share/locale} sub-directory of this package.") (let ((args `(#:tests? #f #:strip-binaries? #f ,@(package-arguments glibc)))) (substitute-keyword-arguments args + ((#:modules modules '((guix build utils) + (guix build gnu-build-system))) + `((srfi srfi-11) + (gnu build locale) + ,@modules)) + ((#:imported-modules modules '()) + `((gnu build locale) + ,@%gnu-build-system-modules)) ((#:phases phases) `(modify-phases ,phases (replace 'build (lambda _ (invoke "make" "localedata/install-locales" "-j" (number->string (parallel-job-count))))) + (add-after 'build 'symlink-normalized-codesets + (lambda* (#:key outputs #:allow-other-keys) + ;; The above phase does not install locales with names using + ;; the "normalized codeset." Thus, create symlinks like: + ;; en_US.utf8 -> en_US.UTF-8 + (define (locale-directory? file stat) + (and (file-is-directory? file) + (string-index (basename file) #\_) + (string-rindex (basename file) #\.))) + + (let* ((out (assoc-ref outputs "out")) + (locales (find-files out locale-directory? + #:directories? #t))) + (for-each (lambda (directory) + (let*-values (((base) + (basename directory)) + ((name codeset) + (locale->name+codeset base)) + ((normalized) + (normalize-codeset codeset))) + (unless (string=? codeset normalized) + (symlink base + (string-append (dirname directory) + "/" name "." + normalized))))) + locales) + #t))) (delete 'install) (delete 'move-static-libs))) ((#:configure-flags flags)