guix-commits
[Top][All Lists]
Advanced

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

01/01: installer: Run 'guix system init' with the right locale.


From: guix-commits
Subject: 01/01: installer: Run 'guix system init' with the right locale.
Date: Mon, 22 Apr 2019 18:34:57 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 7611074f677f1c3cfe5da426f387eeda1b6ad825
Author: Ludovic Courtès <address@hidden>
Date:   Tue Apr 23 00:08:54 2019 +0200

    installer: Run 'guix system init' with the right locale.
    
    * gnu/installer/utils.scm (run-shell-command): Add #:locale and honor it.
    * gnu/installer/newt/final.scm (run-install-shell): Add 'locale'
    parameter; pass it to 'install-system'.
    (run-final-page): Obtain locale from RESULT; pass it to 'run-install-shell'.
    * gnu/installer/final.scm (install-system): Add 'locale' parameter; pass
    it to 'run-shell-command'.
---
 gnu/installer/final.scm      |  8 +++++---
 gnu/installer/newt/final.scm |  9 +++++----
 gnu/installer/utils.scm      | 14 +++++++++++++-
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm
index e1c62f5..07946f7 100644
--- a/gnu/installer/final.scm
+++ b/gnu/installer/final.scm
@@ -24,13 +24,15 @@
   #:use-module (guix build utils)
   #:export (install-system))
 
-(define (install-system)
+(define (install-system locale)
   "Start COW-STORE service on target directory and launch guix install command
-in a subshell."
+in a subshell.  LOCALE must be the locale name under which that command will
+run, or #f."
   (let ((install-command
          (format #f "guix system init ~a ~a"
                  (%installer-configuration-file)
                  (%installer-target-dir))))
     (mkdir-p (%installer-target-dir))
     (start-service 'cow-store (list (%installer-target-dir)))
-    (false-if-exception (run-shell-command install-command))))
+    (false-if-exception (run-shell-command install-command
+                                           #:locale locale))))
diff --git a/gnu/installer/newt/final.scm b/gnu/installer/newt/final.scm
index 645c1e8..f492c5d 100644
--- a/gnu/installer/newt/final.scm
+++ b/gnu/installer/newt/final.scm
@@ -65,22 +65,23 @@ press the button to reboot.")))
    (G_ "The final system installation step failed.  You can retry the \
 last step, or restart the installer.")))
 
-(define (run-install-shell)
+(define (run-install-shell locale)
   (clear-screen)
   (newt-suspend)
-  (let ((install-ok? (install-system)))
+  (let ((install-ok? (install-system locale)))
     (newt-resume)
     install-ok?))
 
 (define (run-final-page result prev-steps)
-  (let* ((configuration (format-configuration prev-steps result))
+  (let* ((configuration   (format-configuration prev-steps result))
          (user-partitions (result-step result 'partition))
+         (locale          (result-step result 'locale))
          (install-ok?
           (with-mounted-partitions
            user-partitions
            (configuration->file configuration)
            (run-config-display-page)
-           (run-install-shell))))
+           (run-install-shell locale))))
     (if install-ok?
         (run-install-success-page)
         (run-install-failed-page))))
diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm
index e91f90a..2567227 100644
--- a/gnu/installer/utils.scm
+++ b/gnu/installer/utils.scm
@@ -54,9 +54,21 @@ number. If no percentage is found, return #f"
     (and result
          (string->number (match:substring result 1)))))
 
-(define (run-shell-command command)
+(define* (run-shell-command command #:key locale)
+  "Run COMMAND, a string, with Bash, and in the given LOCALE."
   (call-with-temporary-output-file
    (lambda (file port)
+     (when locale
+       (let ((supported? (false-if-exception
+                          (setlocale LC_ALL locale))))
+         ;; If LOCALE is not supported, then set LANGUAGE, which might at
+         ;; least give us translated messages.
+         (if supported?
+             (format port "export LC_ALL=\"~a\"~%" locale)
+             (format port "export LANGUAGE=\"~a\"~%"
+                     (string-take locale
+                                  (string-index locale #\_))))))
+
      (format port "~a~%" command)
      ;; (format port "exit~%")
      (close port)



reply via email to

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