diff mbox series

[bug#35394,1/1,v4] Grub i18n

Message ID 87ft6k7sn2.fsf@gmail.com
State Accepted
Headers show
Series [bug#35394,1/1,v4] Grub i18n | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job

Commit Message

Miguel Ángel Arruga Vivas Oct. 11, 2020, 2:18 p.m. UTC
Hi,

This is the latest version of the patch, that could be applied to
master.

They have been reduced to one patch, and as on previous versions of this
series of patches only the grub messages are translated, not the menu
entries generated by guix (yet).

WDYT?

Best regards,
Miguel
--

Comments

Ludovic Courtès Oct. 17, 2020, 4:32 p.m. UTC | #1
Hi Miguel,

Miguel Ángel Arruga Vivas <rosen644835@gmail.com> skribis:

> This is the latest version of the patch, that could be applied to
> master.
>
> They have been reduced to one patch, and as on previous versions of this
> series of patches only the grub messages are translated, not the menu
> entries generated by guix (yet).

Sounds good.  I think the way you split patches in v3 was fine too (the
added test was also a nice bonus), so I actually have a slight
preference for v3.

>>From 885a7c167faafa295b0f3edaae1ee456eacf1e63 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?=
>  <rosen644835@gmail.com>
> Date: Sat, 2 Nov 2019 18:18:45 +0100
> Subject: [PATCH] system: Use locale information in grub.cfg.
>
> * gnu/bootloader/grub.scm (define-module): Add new dependency.
> (grub-configuration-file): Add locale keyword.
> (grub-configuration-file)[locale-config]: New variable with generated
> locale configuration when locale parameter has been provided.
> [builder]: Add locale-config.
> * gnu/machine/ssh.scm (roll-back-managed-host): Use locale information
> from boot-parameters.
> * gnu/system.scm (define-module)[export]: Add boot-parameters-locale.
> (<boot-parameters>)[locale]: New field.
> [boot-parameters-locale]: New accessor.
> (read-boot-parameters): Read locale field.
> (operating-system-boot-parameters): Provide operating-system locale to
> oboot-parameters record.
> (operating-system-boot-parameters-file): Likewise.
> (operating-system-bootcfg): Provide locale information to the bootloader.
> * guix/system/script.scm (reinstall-bootloader): Likewise.

This (and v3) LGTM!  We’ll have to do another round of testing before
1.2.

¡Gracias!

Ludo’.
diff mbox series

Patch

From 885a7c167faafa295b0f3edaae1ee456eacf1e63 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?=
 <rosen644835@gmail.com>
Date: Sat, 2 Nov 2019 18:18:45 +0100
Subject: [PATCH] system: Use locale information in grub.cfg.

* gnu/bootloader/grub.scm (define-module): Add new dependency.
(grub-configuration-file): Add locale keyword.
(grub-configuration-file)[locale-config]: New variable with generated
locale configuration when locale parameter has been provided.
[builder]: Add locale-config.
* gnu/machine/ssh.scm (roll-back-managed-host): Use locale information
from boot-parameters.
* gnu/system.scm (define-module)[export]: Add boot-parameters-locale.
(<boot-parameters>)[locale]: New field.
[boot-parameters-locale]: New accessor.
(read-boot-parameters): Read locale field.
(operating-system-boot-parameters): Provide operating-system locale to
oboot-parameters record.
(operating-system-boot-parameters-file): Likewise.
(operating-system-bootcfg): Provide locale information to the bootloader.
* guix/system/script.scm (reinstall-bootloader): Likewise.
---
 gnu/bootloader/grub.scm | 18 ++++++++++++++++++
 gnu/machine/ssh.scm     |  3 +++
 gnu/system.scm          | 13 +++++++++++++
 guix/scripts/system.scm |  2 ++
 4 files changed, 36 insertions(+)

diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 516a7d48c8..611580a350 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -4,6 +4,7 @@ 
 ;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
 ;;; Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2019, 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2019 Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2020 Stefan <stefan-guix@vodafonemail.de>
 ;;;
@@ -33,6 +34,7 @@ 
   #:use-module (gnu system uuid)
   #:use-module (gnu system file-systems)
   #:use-module (gnu system keyboard)
+  #:use-module (gnu system locale)
   #:use-module (gnu packages bootloaders)
   #:autoload   (gnu packages gtk) (guile-cairo guile-rsvg)
   #:autoload   (gnu packages xorg) (xkeyboard-config)
@@ -334,6 +336,7 @@  code."
 
 (define* (grub-configuration-file config entries
                                   #:key
+                                  (locale #f)
                                   (system (%current-system))
                                   (old-entries '())
                                   store-directory-prefix)
@@ -398,6 +401,20 @@  menuentry ~s {
                  #:store-directory-prefix store-directory-prefix
                  #:port #~port)))
 
+  (define locale-config
+    #~(let ((locale #$(and locale
+                           (locale-definition-source
+                            (locale-name->definition locale)))))
+        (when locale
+          (format port "\
+# Localization configuration.
+if search --file --set boot_partition /grub/grub.cfg; then
+    set locale_dir=(${boot_partition})/grub/locale
+else
+    set locale_dir=/boot/grub/locale
+fi
+set lang=~a~%" locale))))
+
   (define keyboard-layout-config
     (let* ((layout (bootloader-configuration-keyboard-layout config))
            (grub   (bootloader-package
@@ -422,6 +439,7 @@  keymap ~a~%" #$keymap))))
 # will be lost upon reconfiguration.
 ")
           #$(sugar)
+          #$locale-config
           #$keyboard-layout-config
           (format port "
 set default=~a
diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm
index 35b42add48..72ba6bfacf 100644
--- a/gnu/machine/ssh.scm
+++ b/gnu/machine/ssh.scm
@@ -484,11 +484,14 @@  an environment type of 'managed-host."
                                             (drop boot-parameters 2)))
                        (bootloader -> (operating-system-bootloader
                                        (machine-operating-system machine)))
+                       (locale -> (boot-parameters-locale
+                                   (second boot-parameters)))
                        (bootcfg (lower-object
                                  ((bootloader-configuration-file-generator
                                    (bootloader-configuration-bootloader
                                     bootloader))
                                   bootloader entries
+                                  #:locale locale
                                   #:old-entries old-entries)))
                        (remote-result (machine-remote-eval machine remote-exp)))
     (when (eqv? 'error remote-result)
diff --git a/gnu/system.scm b/gnu/system.scm
index ab1b0ff3de..32e0eeaf17 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -5,6 +5,7 @@ 
 ;;; Copyright © 2016 Chris Marusich <cmmarusich@gmail.com>
 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2019 Meiyo Peng <meiyo.peng@gmail.com>
+;;; Copyright © 2019 Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
 ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org>
 ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2020 Florian Pelz <pelzflorian@pelzflorian.de>
@@ -147,6 +148,7 @@ 
             boot-parameters-kernel-arguments
             boot-parameters-initrd
             boot-parameters-multiboot-modules
+            boot-parameters-locale
             read-boot-parameters
             read-boot-parameters-file
             boot-parameters->menu-entry
@@ -291,6 +293,7 @@  directly by the user."
    boot-parameters-bootloader-menu-entries)
   (store-device     boot-parameters-store-device)
   (store-mount-point boot-parameters-store-mount-point)
+  (locale           boot-parameters-locale)
   (kernel           boot-parameters-kernel)
   (kernel-arguments boot-parameters-kernel-arguments)
   (initrd           boot-parameters-initrd)
@@ -368,6 +371,11 @@  file system labels."
          ((_ args) args)
          (#f       '())))
 
+      (locale
+       (match (assq 'locale rest)
+         ((_ locale) locale)
+         (#f         #f)))
+
       (store-device
        ;; Linux device names like "/dev/sda1" are not suitable GRUB device
        ;; identifiers, so we just filter them out.
@@ -1214,6 +1222,7 @@  a list of <menu-entry>, to populate the \"old entries\" menu."
   (let* ((file-systems    (operating-system-file-systems os))
          (root-fs         (operating-system-root-file-system os))
          (root-device     (file-system-device root-fs))
+         (locale          (operating-system-locale os))
          (params          (operating-system-boot-parameters
                            os root-device
                            #:system-kernel-arguments? #t))
@@ -1225,6 +1234,7 @@  a list of <menu-entry>, to populate the \"old entries\" menu."
        (bootloader-configuration-bootloader bootloader-conf)))
 
     (generate-config-file bootloader-conf (list entry)
+                          #:locale locale
                           #:old-entries old-entries
                           #:store-directory-prefix
 			  (btrfs-store-subvolume-file-name file-systems))))
@@ -1264,6 +1274,7 @@  such as '--root' and '--load' to <boot-parameters>."
   (let* ((initrd          (and (not (operating-system-hurd os))
                                (operating-system-initrd-file os)))
          (store           (operating-system-store-file-system os))
+         (locale          (operating-system-locale os))
          (bootloader      (bootloader-configuration-bootloader
                            (operating-system-bootloader os)))
          (bootloader-name (bootloader-name bootloader))
@@ -1282,6 +1293,7 @@  such as '--root' and '--load' to <boot-parameters>."
      (bootloader-name bootloader-name)
      (bootloader-menu-entries
       (bootloader-configuration-menu-entries (operating-system-bootloader os)))
+     (locale locale)
      (store-device (ensure-not-/dev (file-system-device store)))
      (store-mount-point (file-system-mount-point store)))))
 
@@ -1334,6 +1346,7 @@  being stored into the \"parameters\" file)."
                              (or (and=> (operating-system-bootloader os)
                                         bootloader-configuration-menu-entries)
                                  '())))
+                     (locale #$(boot-parameters-locale params))
                      (store
                       (device
                        #$(device->sexp (boot-parameters-store-device params)))
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 939559e719..9ed5c26483 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -384,6 +384,7 @@  STORE is an open connection to the store."
          ;; Make the specified system generation the default entry.
          (params (first (profile-boot-parameters %system-profile
                                                  (list number))))
+         (locale (boot-parameters-locale params))
          (old-generations
           (delv number (reverse (generation-numbers %system-profile))))
          (old-params (profile-boot-parameters
@@ -396,6 +397,7 @@  STORE is an open connection to the store."
           ((bootcfg (lower-object
                      ((bootloader-configuration-file-generator bootloader)
                       bootloader-config entries
+                      #:locale locale
                       #:old-entries old-entries)))
            (drvs -> (list bootcfg)))
         (mbegin %store-monad
-- 
2.28.0