[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#72457] [PATCH 01/15] guix: scripts: Rewrite reinstall-bootloader to
From: |
Lilah Tascheter |
Subject: |
[bug#72457] [PATCH 01/15] guix: scripts: Rewrite reinstall-bootloader to use provenance data. |
Date: |
Sat, 3 Aug 2024 22:55:21 -0500 |
The current implementation is broken anyway. Multiple bootloaders share
a name (including both versions of extlinux) and
bootloader-configuration data is significant to bootloader installation.
It shouldn't be just faked.
Rely on the provenance service instead, which while not always present,
should be for the vast majority of systems.
* guix/scripts/system.scm (reinstall-bootloader): Rename to...
(install-bootloader-from-provenance): ...this, and rewrite to extract
bootloader-configuration data from system provenance.
(switch-to-system-generation, process-command): Use
install-bootloader-from-provenance.
Change-Id: I5713a43ad4f9f32a129d980db06d70de16b03f27
---
guix/scripts/system.scm | 75 ++++++++++++++---------------------------
1 file changed, 25 insertions(+), 50 deletions(-)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 0f7d864e06..bb7b5d37bf 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -88,6 +88,7 @@ (define-module (guix scripts system)
#:use-module (srfi srfi-37)
#:use-module (ice-9 format)
#:use-module (ice-9 match)
+ #:use-module (ice-9 receive)
#:use-module (rnrs bytevectors)
#:export (guix-system
read-operating-system
@@ -377,60 +378,33 @@ (define (switch-to-system-generation store spec)
(activate (string-append generation "/activate")))
(if number
(begin
- (reinstall-bootloader store number)
+ (install-bootloader-from-provenance store number)
(switch-to-generation* %system-profile number)
(unless-file-not-found (primitive-load activate)))
(leave (G_ "cannot switch to system generation '~a'~%") spec))))
-(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-bootloader-name params)))
-
-(define (reinstall-bootloader store number)
- "Re-install bootloader for existing system profile generation NUMBER.
-STORE is an open connection to the store."
+(define (install-bootloader-from-provenance store number)
+ "Re-install an old bootloader using provenance data for system profile
+generation NUMBER with store STORE."
(let* ((generation (generation-file-name %system-profile number))
- ;; Detect the bootloader used in %system-profile.
- (bootloader (lookup-bootloader-by-name (system-bootloader-name)))
-
- ;; Use the detected bootloader with default configuration.
- ;; It will be enough to allow the system to boot.
- (bootloader-config (bootloader-configuration
- (bootloader bootloader)))
-
- ;; Make the specified system generation the default entry.
- (chosen-alternative (generation->boot-alternative
- %system-profile number))
- (params (boot-alternative-parameters chosen-alternative))
- (locale (boot-parameters-locale params))
- (store-crypto-devices (boot-parameters-store-crypto-devices params))
- (store-directory-prefix
- (boot-parameters-store-directory-prefix params))
- (old-generations
- (delv number (reverse (generation-numbers %system-profile))))
- (previous-boot-alternatives (profile->boot-alternatives
- %system-profile old-generations))
- (entries (list (boot-parameters->menu-entry params)))
- (old-entries (map boot-parameters->menu-entry
- (map boot-alternative-parameters
- previous-boot-alternatives))))
- (run-with-store store
- (mlet* %store-monad
- ((bootcfg (lower-object
- ((bootloader-configuration-file-generator bootloader)
- bootloader-config entries
- #:locale locale
- #:store-crypto-devices store-crypto-devices
- #:store-directory-prefix store-directory-prefix
- #:old-entries old-entries)))
- (drvs -> (list bootcfg)))
- (mbegin %store-monad
- (built-derivations drvs)
- ;; Only install bootloader configuration file.
- (install-bootloader local-eval bootloader-config bootcfg
- #:run-installer? #f))))))
+ (os (receive (_ os) (system-provenance generation)
+ (and=> os read-operating-system)))
+ (bootloader-config (operating-system-bootloader os))
+ (bootloader (bootloader-configuration-bootloader bootloader-config))
+ (numbers (delv number (reverse (generation-numbers %system-profile))))
+ (old (profile->boot-alternatives %system-profile numbers)))
+ (if os
+ (run-with-store store
+ (mlet* %store-monad
+ ((bootcfg (lower-object (operating-system-bootcfg os old)))
+ (drvs -> (list bootcfg)))
+ (mbegin %store-monad
+ (built-derivations drvs)
+ ;; Only install bootloader configuration file.
+ (install-bootloader local-eval bootloader-config bootcfg
+ #:run-installer? #f))))
+ (leave (G_ "cannot rollback to provenanceless generation '~a'~%")
+ number))))
;;;
@@ -1416,7 +1390,8 @@ (define (process-command command args opts)
(x (leave (G_ "wrong number of arguments~%"))))))
(with-store* store
(delete-matching-generations store %system-profile pattern)
- (reinstall-bootloader store (generation-number %system-profile)))))
+ (install-bootloader-from-provenance store
+ (generation-number %system-profile)))))
((switch-generation)
(let ((pattern (match args
((pattern) pattern)
--
2.45.2
- [bug#72457] [PATCH 00/15] Rewrite bootloader subsystem., Lilah Tascheter, 2024/08/03
- [bug#72457] [PATCH 05/15] gnu: system: Remove useless boot parameters., Lilah Tascheter, 2024/08/03
- [bug#72457] [PATCH 07/15] gnu: system: Fix bootloader crypto device recognition., Lilah Tascheter, 2024/08/03
- [bug#72457] [PATCH 01/15] guix: scripts: Rewrite reinstall-bootloader to use provenance data.,
Lilah Tascheter <=
- [bug#72457] [PATCH 03/15] guix: scripts: Remove unused code., Lilah Tascheter, 2024/08/03
- [bug#72457] [PATCH 02/15] gnu: Add bootloader target infastructure., Lilah Tascheter, 2024/08/03
- [bug#72457] [PATCH 04/15] gnu: Core bootloader changes., Lilah Tascheter, 2024/08/03
- [bug#72457] [PATCH 08/15] gnu: packages: Add pesign., Lilah Tascheter, 2024/08/03
- [bug#72457] [PATCH 09/15] gnu: packages: Add ukify., Lilah Tascheter, 2024/08/03
- [bug#72457] [PATCH 10/15] gnu: packages: Add systemd-stub., Lilah Tascheter, 2024/08/03
- [bug#72457] [PATCH 06/15] gnu: bootloader: Add raspberry pi bootloader., Lilah Tascheter, 2024/08/03
- [bug#72457] [PATCH 11/15] gnu: bootloaders: Add uki-efi-bootloader., Lilah Tascheter, 2024/08/03
- [bug#72457] [PATCH 14/15] gnu: tests: Update tests to new targets system., Lilah Tascheter, 2024/08/03
- [bug#72457] [PATCH 15/15] teams: Add bootloading team., Lilah Tascheter, 2024/08/03