From c69a1c27ee3f1966d1c4b83a87a4f93356a7bb81 Mon Sep 17 00:00:00 2001 From: Miguel Ángel Arruga Vivas Date: Sat, 24 Oct 2020 17:48:28 +0200 Subject: system: Fix grub keymap with store in btrfs subvolume. * gnu/bootloader/grub.scm (grub-configuration-file) [keyboard-layout-config]: Use normalize-file. --- gnu/bootloader/grub.scm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gnu/bootloader') diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 611580a350..f1479024e6 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -421,11 +421,12 @@ set lang=~a~%" locale)))) (bootloader-configuration-bootloader config))) (keymap* (and layout (keyboard-layout-file layout #:grub grub))) + (entry (first all-entries)) + (device (menu-entry-device entry)) + (mount-point (menu-entry-device-mount-point entry)) (keymap (and keymap* - (if store-directory-prefix - #~(string-append #$store-directory-prefix - #$keymap*) - keymap*)))) + (normalize-file keymap* mount-point + store-directory-prefix)))) #~(when #$keymap (format port "\ insmod keylayouts -- cgit 1.4.1 From 222a630e9e5aecc740476c64925ef78f961a6b91 Mon Sep 17 00:00:00 2001 From: Miguel Ángel Arruga Vivas Date: Sun, 25 Oct 2020 10:13:46 +0100 Subject: system: Fix dependency for grub.cfg generation. * gnu/bootloader/grub.scm (eye-candy)[font-file]: Use the bootloader package provided with the configuration. --- gnu/bootloader/grub.scm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'gnu/bootloader') diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index f1479024e6..5508319d3b 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -171,9 +171,11 @@ fi~%" (symbol->string (assoc-ref colors 'bg))))) (define font-file - (normalize-file (file-append grub "/share/grub/unicode.pf2") - store-mount-point - store-directory-prefix)) + (let* ((bootloader (bootloader-configuration-bootloader config)) + (grub (bootloader-package bootloader))) + (normalize-file (file-append grub "/share/grub/unicode.pf2") + store-mount-point + store-directory-prefix))) (define image (normalize-file (grub-background-image config) -- cgit 1.4.1 From f445bc65764ffad2ae9f3b382ddb8feb4eeea2fb Mon Sep 17 00:00:00 2001 From: Miguel Ángel Arruga Vivas Date: Sat, 24 Oct 2020 20:36:21 +0200 Subject: 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(-) (limited to 'gnu/bootloader') diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 5508319d3b..0899fab61f 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)) -- cgit 1.4.1 From b0afa3c5f6fc3dc84779be64d03cdff4ab295a33 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Wed, 11 Nov 2020 14:48:54 -0500 Subject: bootloader: grub: Skip install-grub-efi when producing a disk image. Fixes . Every bootloader should try their best to install themselves using only the MOUNT-POINT and otherwise do nothing. This requirement comes from the necessity to call INSTALL-GRUB when installing the (non-EFI) GRUB bootloader, which needs to populate the root file system with extra modules that cannot be fit in the core.img file, limited in size to 491520 bytes (by the i386-pc format required for legacy BIOS compatibility). As introducing bootloader knowledge at the level of the image code is undesirable, every bootloader should be adapted to support this fall-back for their installation procedure (TODO). * gnu/bootloader/grub.scm (install-grub-efi)[efi-dir]: Skip when the EFI-DIR argument is set to #f. --- gnu/bootloader/grub.scm | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'gnu/bootloader') diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index 0899fab61f..af7b7561ff 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -573,21 +573,24 @@ fi~%")))) (define install-grub-efi #~(lambda (bootloader efi-dir mount-point) - ;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the - ;; system whose root is mounted at MOUNT-POINT. - (let ((grub-install (string-append bootloader "/sbin/grub-install")) - (install-dir (string-append mount-point "/boot")) - ;; When installing Guix, it's common to mount EFI-DIR below - ;; MOUNT-POINT rather than /boot/efi on the live image. - (target-esp (if (file-exists? (string-append mount-point efi-dir)) - (string-append mount-point efi-dir) - efi-dir))) - ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or - ;; root partition. - (setenv "GRUB_ENABLE_CRYPTODISK" "y") - (invoke/quiet grub-install "--boot-directory" install-dir - "--bootloader-id=Guix" - "--efi-directory" target-esp)))) + ;; There is nothing useful to do when called in the context of a disk + ;; image generation. + (when efi-dir + ;; Install GRUB onto the EFI partition mounted at EFI-DIR, for the + ;; system whose root is mounted at MOUNT-POINT. + (let ((grub-install (string-append bootloader "/sbin/grub-install")) + (install-dir (string-append mount-point "/boot")) + ;; When installing Guix, it's common to mount EFI-DIR below + ;; MOUNT-POINT rather than /boot/efi on the live image. + (target-esp (if (file-exists? (string-append mount-point efi-dir)) + (string-append mount-point efi-dir) + efi-dir))) + ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or + ;; root partition. + (setenv "GRUB_ENABLE_CRYPTODISK" "y") + (invoke/quiet grub-install "--boot-directory" install-dir + "--bootloader-id=Guix" + "--efi-directory" target-esp))))) (define (install-grub-efi-netboot subdir) "Define a grub-efi-netboot bootloader installer for installation in SUBDIR, -- cgit 1.4.1