guix-commits
[Top][All Lists]
Advanced

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

06/06: installer: Install the locale before mounting the cow-store.


From: guix-commits
Subject: 06/06: installer: Install the locale before mounting the cow-store.
Date: Thu, 30 Dec 2021 05:38:23 -0500 (EST)

mothacehe pushed a commit to branch wip-harden-installer
in repository guix.

commit edf808ddb3cdca818c34c133d268ddeae60ab3c6
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Thu Dec 30 11:33:37 2021 +0100

    installer: Install the locale before mounting the cow-store.
    
    Fixes: <https://issues.guix.gnu.org/52831>.
    
    Make sure to install the en_US.utf8 fallback locale if the selected locale 
is
    not supported.
    
    * gnu/installer/final.scm (install-locale): New procedure.
    (install-system): Call it.
---
 gnu/installer/final.scm | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm
index bef5f9fd52..276af908f7 100644
--- a/gnu/installer/final.scm
+++ b/gnu/installer/final.scm
@@ -119,6 +119,28 @@ it can interact with the rest of the system."
     (match (waitpid pid)
       ((_ . status) status))))
 
+(define (install-locale locale)
+  "Install the given LOCALE or the en_US.utf8 locale as a fallback."
+  (let ((supported? (false-if-exception
+                     (setlocale LC_ALL locale))))
+    (if supported?
+        (begin
+          (syslog "install supported locale ~a~%." locale)
+          (setenv "LC_ALL" locale))
+        (begin
+          ;; If the selected locale is not supported, install a default UTF-8
+          ;; locale. This is required to copy some files with UTF-8
+          ;; characters, in the nss-certs package notably. Set LANGUAGE
+          ;; anyways, to have translated messages if possible.
+          (syslog "~a locale is not supported, installating en_US.utf8 \
+locale instead.~%" locale)
+          (setlocale LC_ALL "en_US.utf8")
+          (setenv "LC_ALL" "en_US.utf8")
+          (setenv "LANGUAGE"
+                  (string-take locale
+                               (or (string-index locale #\_)
+                                   (string-length locale))))))))
+
 (define* (install-system locale #:key (users '()))
   "Create /etc/shadow and /etc/passwd on the installation target for USERS.
 Start COW-STORE service on target directory and launch guix install command in
@@ -169,6 +191,10 @@ or #f.  Return #t on success and #f on failure."
        (lambda ()
          (dynamic-wind
            (lambda ()
+             ;; Install the locale before mounting the cow-store, otherwise
+             ;; the loaded cow-store locale files will prevent umounting.
+             (install-locale locale)
+
              ;; Save the database, so that it can be restored once the
              ;; cow-store is umounted.
              (copy-file database-file saved-database)



reply via email to

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