Split system->boot-parameters out of profile->boot-alternatives.

* guix/scripts/system.scm
  (profile->boot-alternatives)[system->boot-parameters]: Rename, process
  system and epoch, and move to...
  (generation->boot-parameters): ...here.
  (reinstall-bootloader): Use procedure above.

Change-Id: If31eeb4cef4f5a107a0ee5ad3f117bf38629ac38
This commit is contained in:
Felix Lechner 2024-09-21 12:23:22 +02:00 committed by Ryan Schanzenbacher
parent 8356f8c2ba
commit 4b2cfd9794
Signed by: ryan77627
GPG key ID: 81B0E222A3E2308E

View file

@ -328,26 +328,25 @@ (define-syntax-rule (unless-file-not-found exp)
#f #f
(apply throw args))))) (apply throw args)))))
(define (generation->boot-parameters profile number)
"Return the 'boot-parameters' for the generation of PROFILE specified
by NUMBER."
(unless-file-not-found
(let* ((system (generation-file-name profile number))
(params (read-boot-parameters-file system))
(epoch (stat:mtime (lstat system)))
(text (boot-parameters-label params)))
(boot-parameters
(inherit params)
(label (decorated-boot-label text number epoch))))))
(define* (profile->boot-alternatives #:optional (profile %system-profile) (define* (profile->boot-alternatives #:optional (profile %system-profile)
(numbers (numbers
(reverse (generation-numbers profile)))) (reverse (generation-numbers profile))))
"Return a list of 'boot-parameters' for the generations of PROFILE specified "Return a list of 'boot-parameters' for the generations of PROFILE specified
by NUMBERS, which is a list of generation numbers. The list is ordered from by NUMBERS, which is a list of generation numbers. The list is ordered from
the most recent to the oldest profiles." the most recent to the oldest profiles."
(define (system->boot-parameters system number epoch) (filter-map (cut generation->boot-parameters profile <>) numbers))
(unless-file-not-found
(let* ((params (read-boot-parameters-file system))
(text (boot-parameters-label params)))
(boot-parameters
(inherit params)
(label (decorated-boot-label text number epoch))))))
(let* ((systems (map (cut generation-file-name profile <>)
numbers))
(times (map (lambda (system)
(unless-file-not-found
(stat:mtime (lstat system))))
systems)))
(filter-map system->boot-parameters systems numbers times)))
;;; ;;;
@ -395,8 +394,7 @@ (define (reinstall-bootloader store number)
(bootloader bootloader))) (bootloader bootloader)))
;; Make the specified system generation the default entry. ;; Make the specified system generation the default entry.
(params (first (profile->boot-alternatives %system-profile (params (generation->boot-parameters %system-profile number))
(list number))))
(locale (boot-parameters-locale params)) (locale (boot-parameters-locale params))
(store-crypto-devices (boot-parameters-store-crypto-devices params)) (store-crypto-devices (boot-parameters-store-crypto-devices params))
(store-directory-prefix (store-directory-prefix