From 333a12f2eff427986efd0ed660fff7d7bb113839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?= Date: Sat, 24 Oct 2020 20:36:21 +0200 Subject: [PATCH 3/3] gnu: grub: Add output locale. * gnu/bootloader/grub.scm (define-module): Use (guix packages). (grub-configuration-file)[locale-config]: Use grub:locale output. * gnu/packages/bootloaders.scm (grub)[outputs]: Define output "locale". [arguments]: Populate "locale" output with new phase 'install-locale. --- gnu/bootloader/grub.scm | 34 +++++++++++++++++++++++----------- gnu/packages/bootloaders.scm | 17 ++++++++++++++++- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index f1479024e6..fedb609095 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -25,6 +25,7 @@ (define-module (gnu bootloader grub) #:use-module (guix build union) + #:use-module (guix packages) #:use-module (guix records) #:use-module (guix store) #:use-module (guix utils) @@ -402,18 +403,29 @@ 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)) + (bootloader (bootloader-configuration-bootloader config)) + (grub (bootloader-package bootloader)) + (locale-dir (normalize-file #~(format #f "~a" #$grub:locale) + (menu-entry-device-mount-point entry) + store-directory-prefix))) + #~(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)))) +~a +set locale_dir=~a +set lang=~a~%" + ;; We search an auto-generated file because the + ;; locale name might not match the .mo file name. + #$(grub-root-search device + #~(string-append #$locale-dir + "/en@quot.mo")) + #$locale-dir + locale))))) (define keyboard-layout-config (let* ((layout (bootloader-configuration-keyboard-layout config)) diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm index d1de5cea4e..985b7b89eb 100644 --- a/gnu/packages/bootloaders.scm +++ b/gnu/packages/bootloaders.scm @@ -99,6 +99,7 @@ "grub-verifiers-Blocklist-fallout-cleanup.patch" "grub-cross-system-i686.patch")))) (build-system gnu-build-system) + (outputs '("out" "locale")) (arguments `(#:configure-flags ;; Counterintuitively, this *disables* a spurious Python dependency by @@ -148,7 +149,21 @@ (substitute* "Makefile.in" (("test_unset grub_func_test") "test_unset")) - #t))) + #t)) + (add-after 'install 'install-locale + ;; Install mo files with the expected names at boot-time. + (lambda* (#:key outputs #:allow-other-keys) + (let ((locale-out (assoc-ref outputs "locale"))) + (mkdir-p locale-out) + (for-each (lambda (file) + (let ((mo (string-append + (basename file ".gmo") + ".mo"))) + (copy-file file + (string-append locale-out + "/" mo)))) + (find-files "po" "\\.gmo$")) + #t)))) ;; Disable tests on ARM and AARCH64 platforms. #:tests? ,(not (any (cute string-prefix? <> (or (%current-target-system) (%current-system))) -- 2.28.0