From: Lilah Tascheter via Guix-patches <guix-patches@gnu.org>
To: 72457@debbugs.gnu.org
Cc: Lilah Tascheter <lilah@lunabee.space>,
Christopher Baines <guix@cbaines.net>,
Josselin Poiret <dev@jpoiret.xyz>,
Ludovic Court??s <ludo@gnu.org>,
Mathieu Othacehe <othacehe@gnu.org>,
Simon Tournier <zimon.toutoune@gmail.com>,
Tobias Geerinckx-Rice <me@tobias.gr>
Subject: [bug#72457] [PATCH 01/15] guix: scripts: Rewrite reinstall-bootloader to use provenance data.
Date: Sat, 3 Aug 2024 22:55:21 -0500 [thread overview]
Message-ID: <6d8a2015a9e54642e3ecf0f7d1d95300496cbbde.1722741997.git.lilah@lunabee.space> (raw)
In-Reply-To: <cover.1722741997.git.lilah@lunabee.space>
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))))
\f
;;;
@@ -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
next prev parent reply other threads:[~2024-08-04 3:57 UTC|newest]
Thread overview: 114+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-04 3:50 [bug#72457] [PATCH 00/15] Rewrite bootloader subsystem Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` Lilah Tascheter via Guix-patches [this message]
2024-08-04 3:55 ` [bug#72457] [PATCH 02/15] gnu: Add bootloader target infastructure Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` [bug#72457] [PATCH 03/15] guix: scripts: Remove unused code Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` [bug#72457] [PATCH 04/15] gnu: Core bootloader changes Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` [bug#72457] [PATCH 05/15] gnu: system: Remove useless boot parameters Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` [bug#72457] [PATCH 06/15] gnu: bootloader: Add raspberry pi bootloader Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` [bug#72457] [PATCH 07/15] gnu: system: Fix bootloader crypto device recognition Lilah Tascheter via Guix-patches
2024-08-04 9:22 ` Tomas Volf
2024-08-04 3:55 ` [bug#72457] [PATCH 08/15] gnu: packages: Add pesign Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` [bug#72457] [PATCH 09/15] gnu: packages: Add ukify Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` [bug#72457] [PATCH 10/15] gnu: packages: Add systemd-stub Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` [bug#72457] [PATCH 11/15] gnu: bootloaders: Add uki-efi-bootloader Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` [bug#72457] [PATCH 12/15] gnu: system: Update examples Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` [bug#72457] [PATCH 13/15] doc: Update bootloader documentation Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` [bug#72457] [PATCH 14/15] gnu: tests: Update tests to new targets system Lilah Tascheter via Guix-patches
2024-08-04 3:55 ` [bug#72457] [PATCH 15/15] teams: Add bootloading team Lilah Tascheter via Guix-patches
2024-08-04 8:53 ` [bug#72457] [PATCH 00/15] Rewrite bootloader subsystem Sergey Trofimov
2024-08-04 9:19 ` Sergey Trofimov
2024-08-04 18:05 ` [bug#72457] [PATCH v2 " Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 01/15] guix: scripts: Rewrite reinstall-bootloader to use provenance data Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 02/15] gnu: Add bootloader target infastructure Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 03/15] guix: scripts: Remove unused code Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 04/15] gnu: Core bootloader changes Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 05/15] gnu: system: Remove useless boot parameters Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 06/15] gnu: bootloader: Add raspberry pi bootloader Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 07/15] gnu: system: Fix bootloader crypto device recognition Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 08/15] gnu: packages: Add pesign Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 09/15] gnu: packages: Add ukify Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 10/15] gnu: packages: Add systemd-stub Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 11/15] gnu: bootloaders: Add uki-efi-bootloader Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 12/15] gnu: system: Update examples Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 13/15] doc: Update bootloader documentation Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 14/15] gnu: tests: Update tests to new targets system Lilah Tascheter via Guix-patches
2024-08-04 18:06 ` [bug#72457] [PATCH v2 15/15] teams: Add bootloading team Lilah Tascheter via Guix-patches
2024-08-04 19:52 ` [bug#72457] [PATCH v2 00/15] Rewrite bootloader subsystem Sergey Trofimov
2024-08-04 20:31 ` [bug#72457] [PATCH v3 " Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 01/15] guix: scripts: Rewrite reinstall-bootloader to use provenance data Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 02/15] gnu: Add bootloader target infastructure Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 03/15] guix: scripts: Remove unused code Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 04/15] gnu: Core bootloader changes Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 05/15] gnu: system: Remove useless boot parameters Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 06/15] gnu: bootloader: Add raspberry pi bootloader Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 07/15] gnu: system: Fix bootloader crypto device recognition Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 08/15] gnu: packages: Add pesign Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 09/15] gnu: packages: Add ukify Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 10/15] gnu: packages: Add systemd-stub Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 11/15] gnu: bootloaders: Add uki-efi-bootloader Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 12/15] gnu: system: Update examples Lilah Tascheter via Guix-patches
2024-08-04 20:31 ` [bug#72457] [PATCH v3 13/15] doc: Update bootloader documentation Lilah Tascheter via Guix-patches
2024-08-04 20:32 ` [bug#72457] [PATCH v3 14/15] gnu: tests: Update tests to new targets system Lilah Tascheter via Guix-patches
2024-08-04 20:32 ` [bug#72457] [PATCH v3 15/15] teams: Add bootloading team Lilah Tascheter via Guix-patches
2024-08-05 7:00 ` [bug#72457] [PATCH v3 00/15] Rewrite bootloader subsystem Sergey Trofimov
2024-08-06 2:44 ` [bug#72457] [PATCH v4 " Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 01/15] guix: scripts: Rewrite reinstall-bootloader to use provenance data Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 02/15] gnu: Add bootloader target infastructure Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 03/15] guix: scripts: Remove unused code Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 04/15] gnu: Core bootloader changes Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 05/15] gnu: system: Remove useless boot parameters Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 06/15] gnu: bootloader: Add raspberry pi bootloader Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 07/15] gnu: system: Fix bootloader crypto device recognition Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 08/15] gnu: packages: Add pesign Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 09/15] gnu: packages: Add ukify Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 10/15] gnu: packages: Add systemd-stub Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 11/15] gnu: bootloaders: Add uki-efi-bootloader Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 12/15] gnu: system: Update examples Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 13/15] doc: Update bootloader documentation Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 14/15] gnu: tests: Update tests to new targets system Lilah Tascheter via Guix-patches
2024-08-06 2:44 ` [bug#72457] [PATCH v4 15/15] teams: Add bootloading team Lilah Tascheter via Guix-patches
2024-08-06 6:13 ` [bug#72457] [PATCH v4 00/15] Rewrite bootloader subsystem Sergey Trofimov
2024-08-07 0:11 ` [bug#72457] [PATCH v5 " Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 01/15] guix: scripts: Rewrite reinstall-bootloader to use provenance data Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 02/15] gnu: Add bootloader target infastructure Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 03/15] guix: scripts: Remove unused code Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 04/15] gnu: Core bootloader changes Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 05/15] gnu: system: Remove useless boot parameters Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 06/15] gnu: bootloader: Add raspberry pi bootloader Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 07/15] gnu: system: Fix bootloader crypto device recognition Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 08/15] gnu: packages: Add pesign Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 09/15] gnu: packages: Add ukify Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 10/15] gnu: packages: Add systemd-stub Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 11/15] gnu: bootloaders: Add uki-efi-bootloader Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 12/15] gnu: system: Update examples Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 13/15] doc: Update bootloader documentation Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 14/15] gnu: tests: Update tests to new targets system Lilah Tascheter via Guix-patches
2024-08-07 0:11 ` [bug#72457] [PATCH v5 15/15] teams: Add bootloading team Lilah Tascheter via Guix-patches
2024-08-07 4:52 ` [bug#72457] [PATCH v5 00/15] Rewrite bootloader subsystem Sergey Trofimov
2024-09-06 22:15 ` guix-patches--- via
2024-09-07 5:48 ` Sergey Trofimov
2024-09-07 7:15 ` guix-patches--- via
2024-09-12 18:08 ` [bug#72457] [PATCH v5 01/15] guix: scripts: Rewrite reinstall-bootloader to use provenance data Herman Rimm via Guix-patches via
2024-09-13 7:56 ` Herman Rimm via Guix-patches via
2024-09-15 9:11 ` [bug#72457] [PATCH v5 00/15] Rewrite bootloader subsystem Herman Rimm via Guix-patches via
2024-09-17 22:20 ` Lilah Tascheter via Guix-patches
2024-09-19 15:35 ` Herman Rimm via Guix-patches via
2024-09-19 17:38 ` Herman Rimm via Guix-patches via
2024-09-20 4:44 ` Lilah Tascheter via Guix-patches
2024-09-20 4:56 ` Lilah Tascheter via Guix-patches
2024-09-24 18:29 ` [bug#72457] [PATCH v6 00/12] " Herman Rimm via Guix-patches via
2024-09-24 18:29 ` [bug#72457] [PATCH v6 01/12] gnu: bootloader: Remove obsolete bootloader fields Herman Rimm via Guix-patches via
2024-09-24 18:29 ` [bug#72457] [PATCH v6 02/12] gnu: bootloader: grub: Rewrite entirely Herman Rimm via Guix-patches via
2024-09-24 18:29 ` [bug#72457] [PATCH v6 03/12] gnu: bootloader: Update bootloader-configuration targets field Herman Rimm via Guix-patches via
2024-09-24 18:29 ` [bug#72457] [PATCH v6 04/12] gnu: Core bootloader changes Herman Rimm via Guix-patches via
2024-09-24 18:29 ` [bug#72457] [PATCH v6 05/12] gnu: system: image: Reduce subprocedure indentation Herman Rimm via Guix-patches via
2024-09-24 18:29 ` [bug#72457] [PATCH v6 06/12] gnu: bootloader: depthcharge: Rewrite completely Herman Rimm via Guix-patches via
2024-09-24 18:29 ` [bug#72457] [PATCH v6 07/12] gnu: bootloader: extlinux: " Herman Rimm via Guix-patches via
2024-09-24 18:29 ` [bug#72457] [PATCH v6 08/12] gnu: bootloader: u-boot: " Herman Rimm via Guix-patches via
2024-09-24 18:29 ` [bug#72457] [PATCH v6 09/12] gnu: bootloader: Add Raspberry Pi bootloader Herman Rimm via Guix-patches via
2024-09-24 18:29 ` [bug#72457] [PATCH v6 10/12] gnu: tests: Update tests to new targets system Herman Rimm via Guix-patches via
2024-09-24 18:29 ` [bug#72457] [PATCH v6 11/12] gnu: system: Update examples Herman Rimm via Guix-patches via
2024-09-24 18:29 ` [bug#72457] [PATCH v6 12/12] doc: Update bootloader documentation Herman Rimm via Guix-patches via
2024-10-18 10:36 ` [bug#72457] A question about this amano.kenji via Guix-patches via
2024-10-19 1:38 ` [bug#72457] What I mentioned above is verified boot amano.kenji via Guix-patches via
2024-10-21 8:32 ` [bug#72457] After further research amano.kenji via Guix-patches via
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6d8a2015a9e54642e3ecf0f7d1d95300496cbbde.1722741997.git.lilah@lunabee.space \
--to=guix-patches@gnu.org \
--cc=72457@debbugs.gnu.org \
--cc=dev@jpoiret.xyz \
--cc=guix@cbaines.net \
--cc=lilah@lunabee.space \
--cc=ludo@gnu.org \
--cc=me@tobias.gr \
--cc=othacehe@gnu.org \
--cc=zimon.toutoune@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).