From 8852f911ff506dd50b714274ba0e2143f0285f78 Mon Sep 17 00:00:00 2001 From: Attila Lendvai Date: Tue, 19 Apr 2022 20:09:55 +0200 Subject: git-download: Set locale to deal with Unicode in git metadata. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 . * 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 --- guix/git-download.scm | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'guix/git-download.scm') 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 . + (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") -- cgit v1.2.3