guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/19: git-download: Set locale to deal with Unicode in git metadata.


From: guix-commits
Subject: 01/19: git-download: Set locale to deal with Unicode in git metadata.
Date: Wed, 20 Apr 2022 18:09:58 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 8852f911ff506dd50b714274ba0e2143f0285f78
Author: Attila Lendvai <attila@lendvai.name>
AuthorDate: Tue Apr 19 20:09:55 2022 +0200

    git-download: Set locale to deal with Unicode in git metadata.
    
    Without this the git-fetch GEXP is run in an environment that uses ASCII
    character encoding when strings are crossing the Guile - C boundary.  It 
means
    that e.g. tag names that have Unicode chars in them will cause problems,
    e.g. when walking and deleting the .git directory.
    
    An example in the wild: https://github.com/klauspost/pgzip/tags
    
    Fixes <https://issues.guix.gnu.org/54893>.
    
    * guix/git-download.scm (git-fetch): Call 'setenv' and 'setlocale' to
    set it to en_US.utf8.
    * gnu/packages/commencement.scm (glibc-utf8-locales-final): Make public.
    Add 'properties' field.
    
    Co-authored-by: Ludovic Courtès <ludo@gnu.org>
---
 gnu/packages/commencement.scm |  4 +++-
 guix/git-download.scm         | 13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index e8b47fbeab..1fed8bcd6e 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -3613,7 +3613,7 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a 
\"$@\"~%"
   (with-boot4 (hidden-package
                (package-with-bootstrap-guile guile-3.0/fixed))))
 
-(define glibc-utf8-locales-final
+(define-public glibc-utf8-locales-final
   ;; Now that we have GUILE-FINAL, build the UTF-8 locales.  They are needed
   ;; by the build processes afterwards so their 'scm_to_locale_string' works
   ;; with the full range of Unicode codepoints (remember
@@ -3621,6 +3621,8 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a 
\"$@\"~%"
   ;; function.)
   (package
     (inherit glibc-utf8-locales)
+    (properties `((hidden? . #t)
+                  ,@(package-properties glibc-utf8-locales)))
     (native-inputs
      `(("glibc" ,glibc-final)
        ("gzip" ,(with-boot4 gzip))))))
diff --git a/guix/git-download.scm b/guix/git-download.scm
index 5e624b9ae9..a1566bed4d 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -104,6 +104,12 @@ HASH-ALGO (a symbol).  Use NAME as the file name, or a 
generic name if #f."
   (define gnutls
     (module-ref (resolve-interface '(gnu packages tls)) 'gnutls))
 
+  (define glibc-locales
+    ;; Note: pick the '-final' variant to avoid circular dependency on
+    ;; i586-gnu, where 'glibc-utf8-locales' indirectly depends on Git.
+    (module-ref (resolve-interface '(gnu packages commencement))
+                'glibc-utf8-locales-final))
+
   (define modules
     (delete '(guix config)
             (source-module-closure '((guix build git)
@@ -125,6 +131,13 @@ HASH-ALGO (a symbol).  Use NAME as the file name, or a 
generic name if #f."
             (define recursive?
               (call-with-input-string (getenv "git recursive?") read))
 
+            ;; Let Guile interpret file names as UTF-8, otherwise
+            ;; 'delete-file-recursively' might fail to delete all of
+            ;; '.git'--see <https://issues.guix.gnu.org/54893>.
+            (setenv "GUIX_LOCPATH"
+                    #+(file-append glibc-locales "/lib/locale"))
+            (setlocale LC_ALL "en_US.utf8")
+
             ;; The 'git submodule' commands expects Coreutils, sed,
             ;; grep, etc. to be in $PATH.
             (set-path-environment-variable "PATH" '("bin")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]