Subject: [bug#67824] [PATCH core-updates v2 1/9] packages: Remove reference to ‘glibc-utf8-locales’ in ‘patch-and-repack’.

From: Ludovic Courtès <[email-masked]>
Date: Mon, 18 Dec 2023 17:30:12 +0100

This is a followup to 1cebc334a77030c0c94955981652f4df7608c9e3.

* guix/packages.scm (%standard-patch-inputs): Remove “locales” entry.
(patch-and-repack): Remove ‘locales’ variable.
[build]: Remove reference to ‘locales’.  Use “C.UTF-8” unconditionally.

Change-Id: I54219b232880e05534599fbba8738cc00fb5d568
---
 guix/packages.scm | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/guix/packages.scm b/guix/packages.scm
index 930b1a3b0e..4b0c478ff4 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -866,13 +866,7 @@ (define (%standard-patch-inputs system)
       ("gzip"  ,(ref '(gnu packages compression) 'gzip))
       ("lzip"  ,(ref '(gnu packages compression) 'lzip))
       ("unzip" ,(ref '(gnu packages compression) 'unzip))
-      ("patch" ,(ref '(gnu packages base) 'patch))
-      ("locales"
-       ,(parameterize ((%current-target-system #f)
-                       (%current-system system))
-          (canonical
-           ((module-ref (resolve-interface '(gnu packages base))
-                        'libc-utf8-locales-for-target))))))))
+      ("patch" ,(ref '(gnu packages base) 'patch)))))
 
 (define (default-guile)
   "Return the default Guile package used to run the build code of
@@ -955,7 +949,6 @@ (define* (patch-and-repack source patches
         (lzip    (lookup-input "lzip"))
         (xz      (lookup-input "xz"))
         (patch   (lookup-input "patch"))
-        (locales (lookup-input "locales"))
         (comp    (and=> (compressor source-file-name) lookup-input))
         (patches (map instantiate-patch patches)))
     (define build
@@ -1017,15 +1010,17 @@ (define* (patch-and-repack source patches
             ;; Encoding/decoding errors shouldn't be silent.
             (fluid-set! %default-port-conversion-strategy 'error)
 
-            (when #+locales
-              ;; First of all, install a UTF-8 locale so that UTF-8 file names
-              ;; are correctly interpreted.  During bootstrap, LOCALES is #f.
-              (setenv "LOCPATH"
-                      (string-append #+locales "/lib/locale/"
-                                     #+(and locales
-                                            (version-major+minor
-                                             (package-version locales)))))
-              (setlocale LC_ALL "en_US.utf8"))
+            ;; First of all, install a UTF-8 locale so that UTF-8 file names
+            ;; are correctly interpreted.  During bootstrap, locales are
+            ;; missing.
+            (let ((locale "C.UTF-8"))
+              (catch 'system-error
+                (lambda ()
+                  (setlocale LC_ALL locale))
+                (lambda args
+                  (format (current-error-port)
+                          "failed to install '~a' locale: ~a~%"
+                          locale (system-error-errno args)))))
 
             (setenv "PATH"
                     (string-append #+xz "/bin"
-- 
2.41.0