diff options
| author | Miguel Ángel Arruga Vivas <rosen644835@gmail.com> | 2020-10-24 20:36:21 +0200 |
|---|---|---|
| committer | Miguel Ángel Arruga Vivas <rosen644835@gmail.com> | 2020-11-01 01:14:36 +0100 |
| commit | f445bc65764ffad2ae9f3b382ddb8feb4eeea2fb (patch) | |
| tree | 652933e0c5890e3e1a0ddd586b5611c5e42bb6e9 /gnu | |
| parent | 70876b0793765b882f3fae3d8465b68b38e1eeb8 (diff) | |
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.
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/bootloader/grub.scm | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 5508319d3b3..0899fab61fa 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm | |||
| @@ -142,6 +142,24 @@ file with the resolution provided in CONFIG." | |||
| 142 | (image->png image #:width width #:height height)) | 142 | (image->png image #:width width #:height height)) |
| 143 | (_ #f))))) | 143 | (_ #f))))) |
| 144 | 144 | ||
| 145 | (define (grub-locale-directory grub) | ||
| 146 | "Generate a directory with the locales from GRUB." | ||
| 147 | (define builder | ||
| 148 | #~(begin | ||
| 149 | (use-modules (ice-9 ftw)) | ||
| 150 | (let ((locale (string-append #$grub "/share/locale")) | ||
| 151 | (out #$output)) | ||
| 152 | (mkdir out) | ||
| 153 | (chdir out) | ||
| 154 | (for-each (lambda (lang) | ||
| 155 | (let ((file (string-append locale "/" lang | ||
| 156 | "/LC_MESSAGES/grub.mo")) | ||
| 157 | (dest (string-append lang ".mo"))) | ||
| 158 | (when (file-exists? file) | ||
| 159 | (copy-file file dest)))) | ||
| 160 | (scandir locale))))) | ||
| 161 | (computed-file "grub-locales" builder)) | ||
| 162 | |||
| 145 | (define* (eye-candy config store-device store-mount-point | 163 | (define* (eye-candy config store-device store-mount-point |
| 146 | #:key store-directory-prefix port) | 164 | #:key store-directory-prefix port) |
| 147 | "Return a gexp that writes to PORT (a port-valued gexp) the 'grub.cfg' part | 165 | "Return a gexp that writes to PORT (a port-valued gexp) the 'grub.cfg' part |
| @@ -404,18 +422,33 @@ menuentry ~s { | |||
| 404 | #:port #~port))) | 422 | #:port #~port))) |
| 405 | 423 | ||
| 406 | (define locale-config | 424 | (define locale-config |
| 407 | #~(let ((locale #$(and locale | 425 | (let* ((entry (first all-entries)) |
| 408 | (locale-definition-source | 426 | (device (menu-entry-device entry)) |
| 409 | (locale-name->definition locale))))) | 427 | (mount-point (menu-entry-device-mount-point entry)) |
| 410 | (when locale | 428 | (bootloader (bootloader-configuration-bootloader config)) |
| 411 | (format port "\ | 429 | (grub (bootloader-package bootloader))) |
| 430 | #~(let ((locale #$(and locale | ||
| 431 | (locale-definition-source | ||
| 432 | (locale-name->definition locale)))) | ||
| 433 | (locales #$(and locale | ||
| 434 | (normalize-file (grub-locale-directory grub) | ||
| 435 | mount-point | ||
| 436 | store-directory-prefix)))) | ||
| 437 | (when locale | ||
| 438 | (format port "\ | ||
| 412 | # Localization configuration. | 439 | # Localization configuration. |
| 413 | if search --file --set boot_partition /grub/grub.cfg; then | 440 | ~asearch --file --set ~a/en@quot.mo |
| 414 | set locale_dir=(${boot_partition})/grub/locale | 441 | set locale_dir=~a |
| 415 | else | 442 | set lang=~a~%" |
| 416 | set locale_dir=/boot/grub/locale | 443 | ;; Skip the search if there is an image, as it has already |
| 417 | fi | 444 | ;; been performed by eye-candy and traversing the store is |
| 418 | set lang=~a~%" locale)))) | 445 | ;; an expensive operation. |
| 446 | #$(if (grub-theme-image (bootloader-theme config)) | ||
| 447 | "# " | ||
| 448 | "") | ||
| 449 | locales | ||
| 450 | locales | ||
| 451 | locale))))) | ||
| 419 | 452 | ||
| 420 | (define keyboard-layout-config | 453 | (define keyboard-layout-config |
| 421 | (let* ((layout (bootloader-configuration-keyboard-layout config)) | 454 | (let* ((layout (bootloader-configuration-keyboard-layout config)) |
