From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id SAe+BkrCkF+ICAAA0tVLHw (envelope-from ) for ; Wed, 21 Oct 2020 23:20:42 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id EDNvAkrCkF+bRgAAB5/wlQ (envelope-from ) for ; Wed, 21 Oct 2020 23:20:42 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 07FD59402A5 for ; Wed, 21 Oct 2020 23:20:40 +0000 (UTC) Received: from localhost ([::1]:53520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVNPK-0007tL-MD for larch@yhetil.org; Wed, 21 Oct 2020 19:20:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVNOl-0007hK-M0 for guix-patches@gnu.org; Wed, 21 Oct 2020 19:20:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39324) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kVNOj-0007Ne-On for guix-patches@gnu.org; Wed, 21 Oct 2020 19:20:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kVNOj-00005Y-Iy for guix-patches@gnu.org; Wed, 21 Oct 2020 19:20:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#44075] [PATCH] gnu: Add make-glibc-locales-collection. Resent-From: Miguel =?UTF-8?Q?=C3=81ngel?= Arruga Vivas Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 21 Oct 2020 23:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44075 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Efraim Flashner Cc: 44075@debbugs.gnu.org Received: via spool by 44075-submit@debbugs.gnu.org id=B44075.160332237132756 (code B ref 44075); Wed, 21 Oct 2020 23:20:01 +0000 Received: (at 44075) by debbugs.gnu.org; 21 Oct 2020 23:19:31 +0000 Received: from localhost ([127.0.0.1]:50870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVNOF-0008WG-6x for submit@debbugs.gnu.org; Wed, 21 Oct 2020 19:19:31 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38296) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kVNOD-0008W2-Db for 44075@debbugs.gnu.org; Wed, 21 Oct 2020 19:19:30 -0400 Received: by mail-wm1-f65.google.com with SMTP id l15so47145wmi.3 for <44075@debbugs.gnu.org>; Wed, 21 Oct 2020 16:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=cJ3T56q86WJh4iPMi8g+SZkxOUq3V+372P9AQKwaLks=; b=HmDkN0r7b1A8Z+Elgr9iBmcBb7J0mnzgPPBOgKuRfn8CYrvFUj+REjDAn2KNjsn0Gp UKnYdxkwY2cULIX22MQih/ltaxP4pm2cYgEVbl/65XK0qw9yN4w9kPSRNmLMFPcBbF2Q 0IJ46m/wpL+S8X9UieV1TKVTHvc2DdZvY776Uij6LtUreA1P25IdRbNfVckpa9Tfh8av 7Vl1F2I6PihTYOznIolalnp8/g/ucLhOR1WY3KoEgJVX3IQzgnrbeqv3hLJjr+o85wNV ATHfcAEn/TSlQA9L4Q4ufXIpDhyk/6iZ9b4EgVyw2qMT0RoJo7kM4QQQNH8LR5q8SXGP iIzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=cJ3T56q86WJh4iPMi8g+SZkxOUq3V+372P9AQKwaLks=; b=VfQDIBSLac02oRAD745LKKltQRc/xwH9nV1hEwyviCsDU0CZU4+b5YgWKWWAt+zsvB KkOmNF0hNSpT7KSUIiGLfnGRRFVStWom6I6lrSnkOsT1JUOaDNwDXlO6K6nDSlPBz0sw dKS+l7isnkdgA/1GuG6aF/0OKxtaS8yAJsTIBiSuVfpGDoF2jc2hhcw5EoCkkiB1W+jX FrYaG4iyh9kIi6S6RR+vH3+eqsZ29W9XWDWgaeMkaBBtlsJNpB/0rbaWrUhSd4ThQU+N kY38aaN45kMQasQ744Yx3bvzAk70f9HvYG1yHq9570rAOxbj6QDA6N5OUg2IiiS4+6ER X/GA== X-Gm-Message-State: AOAM5321A3QVyY5oZPwY4qK70FWvAJeCUIMJyWHcYVrfqbpaUdxWDwla V9psbGMQYcGQku0SWCUAzSil/qMohMT7+g== X-Google-Smtp-Source: ABdhPJz2Q02VWGQD9ziCvvBCn+k473UH5Wt42LN7u217Rl0yTDGldkEQyrSIQZtX0iWb/kdfCW9nYQ== X-Received: by 2002:a1c:9cd8:: with SMTP id f207mr5445019wme.76.1603322363182; Wed, 21 Oct 2020 16:19:23 -0700 (PDT) Received: from unfall (218.139.134.37.dynamic.jazztel.es. [37.134.139.218]) by smtp.gmail.com with ESMTPSA id q2sm6415672wrw.40.2020.10.21.16.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2020 16:19:21 -0700 (PDT) From: Miguel =?UTF-8?Q?=C3=81ngel?= Arruga Vivas References: <20201019064739.4736-1-efraim@flashner.co.il> <87tuuqnym5.fsf@gmail.com> <20201019140236.GF9117@E5400> <87mu0im7r4.fsf@gmail.com> <20201021070155.GQ9117@E5400> Date: Thu, 22 Oct 2020 01:18:16 +0200 In-Reply-To: <20201021070155.GQ9117@E5400> (Efraim Flashner's message of "Wed, 21 Oct 2020 10:01:55 +0300") Message-ID: <87blgvjhhj.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: 0.2 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -0.8 (/) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=HmDkN0r7; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -2.01 X-TUID: YMXoYhpkwveN --=-=-= Content-Type: text/plain Hello, Efraim Flashner writes: > Your patch was what got me to actually send mine to guix-patches :) Thanks. :-) > That is a good point. I'll change it to something actually useful, > mentioning that there's a convention but that people often get it wrong. Great, the more knowledge, the easier to overcome that common misunderstanding. :-) > I agree it should be renamed to en-us. I have some bikeshedding to think > about for en-us-glibc-locales vs glibc-locales-en-us. And I'll also test > out one for glibc-locales-guile-tests. I meant the ISO-8859-1, the locale creation should be en_EN.iso88591, the locale name can be en_EN.88591 too... Although in that case shouldn't be glibc-en-us-locales? I'd like green lights for the bike shed, please. ;-) > I hadn't seen gnu/build/locales.scm. I'll have to see what we can do > about using it. We normally don't allow cross-over from the build side > to the packages side. It is already being used in the build of glibc-locales and I guess it would be harmless to move it to guix build if that is a problem, but I think it can be used as it is right now, even I didn't check yet. In this for-each(gnu/packages/base.scm:1084), for example: ------------------------->8-------------begin---------------------- (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) -------------------------8<--------------end----------------------- I would write something like this in the builder code: ------------------------->8-------------begin---------------------- (define (locale-builder directory) (lambda (locale) (let-values (((name codeset) (locale->name+codeset))) (if codeset (build-locale name #:directory directory #:codeset (normalize-codeset codeset)) (build-locale name #:directory directory #:codeset "utf8"))))) (let ... (for-each (locale-builder localedir) '(,@locales)) ...) -------------------------8<--------------end----------------------- I leave you here the function I was hacking apart (please, do not confuse with working code ;-)) if you want to take any idea other from it: ------------------------->8-------------begin---------------------- (define*-public (make-glibc-selected-locales glibc #:key (suffix "-utf8-locales") (locales %default-locales) (alias %default-alias)) (package (name (string-append (package-name glibc) suffix)) (version (package-version glibc)) (source #f) (build-system trivial-build-system) (arguments `(#:modules ((guix build utils) (gnu build locale)) #:builder (begin (use-modules (guix build utils) (gnu build locale)) ;; Print the common alias for locale (define (print-locale-alias locale) (let-values (((name codeset) (locale->name+codeset))) (if codeset (or (string-equal codeset (normalize-codeset codeset)) (format #t "~a.~a ~a.~a~%" name codeset name (normalize-codeset codeset))) (format #t "~a.UTF-8 ~a.utf8" name name)))) ;; Generate a function that builds the locale into directory. (define (locale-builder directory) (lambda (locale) (let-values (((name codeset) (locale->name+codeset))) (if codeset (build-locale name #:directory directory #:codeset (normalize-codeset codeset)) (build-locale name #:directory directory #:codeset "utf8"))))) ;; Do the job. (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))) (alias (string-append localedir "/locale.alias")) (locales '(,@locales))) ;; 'localedef' needs 'gzip'. (setenv "PATH" (string-append libc "/bin:" gzip "/bin")) (mkdir-p localedir) ;; Generate each locale provided. (for-each (locale-builder localedir) locales) ;; Generate alias file. (with-output-to-file alias (lambda () (format #t "~a~%" "# Aliases for common codeset names.") (for-each print-locale-alias locales) (format #t "~a~%" "# Other aliases.") (for-each (lambda (line) (format #t "~a~%" line)) '(,@alias))))))) (native-inputs `(("glibc" ,glibc) ("gzip" ,gzip))) (synopsis "Configured sample of locales") (description "TODO.") (home-page (package-home-page glibc)) (license (package-license glibc)))) -------------------------8<--------------end----------------------- Happy hacking, Miguel --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAEBCgAdFiEEiIeExBRZrMuD5+hMY0xuiXn6vsIFAl+QwbgACgkQY0xuiXn6 vsIAwwv/V+iIDRtlXgmgrhnCHBkNBV8gIadbxLQxZnc1so/psQbcGDThb1whjL4J EsAEpGvzSD5XFmahmv2vaRcoTAaeCKgYpWH/NXyXuzop00dteXctvq302WhEUB35 qVobkwJrff/Qfw+xvoHYyz+cGWLTQdKnD+v8D2RYyRxDjj528CSpOI8cDtTU2oSV 8KbzSnEtCPfLHRjyj96ZNzDPtLpbq0ROIFV2G9qqNahXE5pEDi10Bu8iiAnwn95e GTXCSARMrtrSQtg81wnOS+A8UgpTpGiN6el3fjOVuolx64n6aZJYJQze2s64Wmtc 3z1jMFXhdvKzhdU5vjnBG9FWXc7FMZv36ry/QLh/CQpGVDp75yng9PcTzZw8IwEB k6rJNJGz7hG4uuzQdS0OjrMNX7XhNMUGlRHkeUSm1bLGS/HymiRQG3EeLU24o85O 3xrOyI4SZspr9e3opINLUMNu0no5N0tOrhDnQhBe9OK9xGclpM2oiQ4z901nAMNh 9JZfbd7K =X5L6 -----END PGP SIGNATURE----- --=-=-=--