guix-commits
[Top][All Lists]
Advanced

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

branch master updated: system: Generate grub locale directory for grub.c


From: guix-commits
Subject: branch master updated: system: Generate grub locale directory for grub.cfg.
Date: Sat, 31 Oct 2020 20:36:06 -0400

This is an automated email from the git hooks/post-receive script.

m1gu3l pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new f445bc6  system: Generate grub locale directory for grub.cfg.
f445bc6 is described below

commit f445bc65764ffad2ae9f3b382ddb8feb4eeea2fb
Author: Miguel Ángel Arruga Vivas <rosen644835@gmail.com>
AuthorDate: Sat Oct 24 20:36:21 2020 +0200

    system: Generate grub locale directory for grub.cfg.
    
    * gnu/bootloader/grub.scm (grub-locale-directory): New function.
    (grub-configuration-file)[locale-config]: Use grub-locale-directory and
    avoid the extra search when eye-candy have performed it.
---
 gnu/bootloader/grub.scm | 55 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 44 insertions(+), 11 deletions(-)

diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 5508319..0899fab 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -142,6 +142,24 @@ file with the resolution provided in CONFIG."
             (image->png image #:width width #:height height))
            (_ #f)))))
 
+(define (grub-locale-directory grub)
+  "Generate a directory with the locales from GRUB."
+  (define builder
+    #~(begin
+        (use-modules (ice-9 ftw))
+        (let ((locale (string-append #$grub "/share/locale"))
+              (out    #$output))
+          (mkdir out)
+          (chdir out)
+          (for-each (lambda (lang)
+                      (let ((file (string-append locale "/" lang
+                                                 "/LC_MESSAGES/grub.mo"))
+                            (dest (string-append lang ".mo")))
+                        (when (file-exists? file)
+                          (copy-file file dest))))
+                    (scandir locale)))))
+  (computed-file "grub-locales" builder))
+
 (define* (eye-candy config store-device store-mount-point
                     #:key store-directory-prefix port)
   "Return a gexp that writes to PORT (a port-valued gexp) the 'grub.cfg' part
@@ -404,18 +422,33 @@ menuentry ~s {
                  #:port #~port)))
 
   (define locale-config
-    #~(let ((locale #$(and locale
-                           (locale-definition-source
-                            (locale-name->definition locale)))))
-        (when locale
-          (format port "\
+    (let* ((entry (first all-entries))
+           (device (menu-entry-device entry))
+           (mount-point (menu-entry-device-mount-point entry))
+           (bootloader (bootloader-configuration-bootloader config))
+           (grub (bootloader-package bootloader)))
+      #~(let ((locale #$(and locale
+                             (locale-definition-source
+                              (locale-name->definition locale))))
+              (locales #$(and locale
+                              (normalize-file (grub-locale-directory grub)
+                                              mount-point
+                                              store-directory-prefix))))
+          (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))))
+~asearch --file --set ~a/en@quot.mo
+set locale_dir=~a
+set lang=~a~%"
+                    ;; Skip the search if there is an image, as it has already
+                    ;; been performed by eye-candy and traversing the store is
+                    ;; an expensive operation.
+                    #$(if (grub-theme-image (bootloader-theme config))
+                          "# "
+                          "")
+                    locales
+                    locales
+                    locale)))))
 
   (define keyboard-layout-config
     (let* ((layout (bootloader-configuration-keyboard-layout config))



reply via email to

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