GNU bug report logs - #26339
[PATCH 00/18] wip: Support non grub bootloaders.

Previous Next

Package: guix-patches;

Reported by: Mathieu Othacehe <m.othacehe <at> gmail.com>

Date: Sun, 2 Apr 2017 13:51:01 UTC

Severity: important

Tags: patch

Done: Mathieu Othacehe <m.othacehe <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #417 received at 26339 <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <m.othacehe <at> gmail.com>
To: 26339 <at> debbugs.gnu.org
Cc: Mathieu Othacehe <m.othacehe <at> gmail.com>
Subject: [PATCH v4 6/7] scripts: system: Adapt "switch-generation" to new
 bootloader API.
Date: Sun, 14 May 2017 09:48:02 +0200
* guix/scripts/system.scm (reinstall-grub): Rename to
  reinstall-bootloader. Read boot-device and boot-type from parameters file to
  be able to restore the correct bootloader on specified device.
  Factorize bootloader installation code by calling install-bootloader.
 (system-bootloader-name): New procedure.
 (switch-to-system-generation): Adapt.
---
 guix/scripts/system.scm | 61 +++++++++++++++++++++++++++----------------------
 1 file changed, 34 insertions(+), 27 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index a40d026ec..01070ce6e 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -412,49 +412,56 @@ connection to the store."
 ;;;
 (define (switch-to-system-generation store spec)
   "Switch the system profile to the generation specified by SPEC, and
-re-install grub with a grub configuration file that uses the specified system
+re-install bootloader with a configuration file that uses the specified system
 generation as its default entry.  STORE is an open connection to the store."
   (let ((number (relative-generation-spec->number %system-profile spec)))
     (if number
         (begin
-          (reinstall-grub store number)
+          (reinstall-bootloader store number)
           (switch-to-generation* %system-profile number))
         (leave (G_ "cannot switch to system generation '~a'~%") spec))))
 
-(define (reinstall-grub store number)
-  "Re-install grub for existing system profile generation NUMBER.  STORE is an
-open connection to the store."
+(define* (system-bootloader-name #:optional (system %system-profile))
+  "Return the bootloader name stored in SYSTEM's \"parameters\" file."
+  (let ((params (unless-file-not-found
+                 (read-boot-parameters-file system))))
+    (boot-parameters-boot-name params)))
+
+(define (reinstall-bootloader store number)
+  "Re-install bootloader for existing system profile generation NUMBER.
+STORE is an open connection to the store."
   (let* ((generation (generation-file-name %system-profile number))
          (params (unless-file-not-found
                   (read-boot-parameters-file generation)))
-         (root-device (boot-parameters-root-device params))
          ;; We don't currently keep track of past menu entries' details.  The
          ;; default values will allow the system to boot, even if they differ
          ;; from the actual past values for this generation's entry.
-         (grub-config (grub-configuration (device root-device)))
+         (bootloader (lookup-bootloader-by-name (system-bootloader-name)))
+         (bootloader-config (bootloader-configuration
+                             (bootloader bootloader)))
          ;; Make the specified system generation the default entry.
          (entries (profile-boot-parameters %system-profile (list number)))
          (old-generations (delv number (generation-numbers %system-profile)))
-         (old-entries (profile-boot-parameters %system-profile old-generations))
-         (grub.cfg (run-with-store store
-                     (grub-configuration-file grub-config
-                                              entries
-                                              #:old-entries old-entries))))
-    (show-what-to-build store (list grub.cfg))
-    (build-derivations store (list grub.cfg))
-    ;; This is basically the same as install-grub*, but for now we avoid
-    ;; re-installing the GRUB boot loader itself onto a device, mainly because
-    ;; we don't in general have access to the same version of the GRUB package
-    ;; which was used when installing this other system generation.
-    (let* ((grub.cfg-path (derivation->output-path grub.cfg))
-           (gc-root (string-append %gc-roots-directory "/grub.cfg"))
-           (temp-gc-root (string-append gc-root ".new")))
-      (switch-symlinks temp-gc-root grub.cfg-path)
-      (unless (false-if-exception (install-grub-config grub.cfg-path "/"))
-        (delete-file temp-gc-root)
-        (leave (G_ "failed to re-install GRUB configuration file: '~a'~%")
-               grub.cfg-path))
-      (rename-file temp-gc-root gc-root))))
+         (old-entries (profile-boot-parameters
+                       %system-profile old-generations)))
+    (run-with-store store
+      (mlet* %store-monad
+          ((bootcfg ((bootloader-configuration-file-generator bootloader)
+                     bootloader-config entries
+                     #:old-entries old-entries))
+           (bootcfg-file -> (bootloader-configuration-file bootloader))
+           (target -> "/")
+           (drvs -> (list bootcfg)))
+        (mbegin %store-monad
+          (show-what-to-build* drvs)
+          (built-derivations drvs)
+          ;; PARAMS file may not contain a suitable BOOT-DEVICE. If BOOT-DEVICE
+          ;; is #f do not run BOOTLOADER-INSTALLER during bootloader installation.
+          (install-bootloader #f
+                              #:bootcfg bootcfg
+                              #:bootcfg-file bootcfg-file
+                              #:device #f
+                              #:target target))))))
 
 
 ;;;
-- 
2.13.0





This bug report was last modified 7 years and 209 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.