From patchwork Sun Aug 4 03:13:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lilah Tascheter X-Patchwork-Id: 66646 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id F077027BBEB; Sun, 4 Aug 2024 04:17:47 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A09A327BBEC for ; Sun, 4 Aug 2024 04:17:42 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1saRjx-0003mV-G4; Sat, 03 Aug 2024 23:17:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1saRjn-0003km-79 for guix-patches@gnu.org; Sat, 03 Aug 2024 23:16:51 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1saRjl-0002RT-IH; Sat, 03 Aug 2024 23:16:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=qwGZKiXieyigE1Z6gQ2W21+mcjAALtB7u2ZYs2VSv4E=; b=JMHfMoq7Ft/NY37vDRkNqQwZIbFf63A18T26LVcj/Tz1l0Hk3q/Bt7rLzUsZqkioihjRP3uO83WXQA6mPcD3CqHjTMLSUWg/YOpVNOUVg1ycI+ulxV9GfLpold1c3Iqf2nllThu/y2XQE0Hv8HFW0t5DT2YwJljYTsZwNF46m2KC2Nvv4CkAOEL86Ubd0aoDuP3/cF4O7G3e3vs9s061Ptni/wuv5J7nHwPlcvbNS6PkbIH1LxjxIDt6T+N2h/CQ+WHuh0yChE51X0oB24gGZmjUjUu2X0HvvUyHhlXDMthLaDj1KPCWkUx9+hDpjgg7zzOPAzPfIHB9r0EQrP7WSA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1saRk4-0007pA-PR; Sat, 03 Aug 2024 23:17:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69343] [PATCH v3 12/12] Encapsulate to retain generation, system-path and epoch. Resent-From: Lilah Tascheter Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sun, 04 Aug 2024 03:17:08 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69343 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69343@debbugs.gnu.org Cc: Felix Lechner , Christopher Baines , Josselin Poiret , Ludovic Court??s , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic Court??s , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 69343-submit@debbugs.gnu.org id=B69343.172274142229942 (code B ref 69343); Sun, 04 Aug 2024 03:17:08 +0000 Received: (at 69343) by debbugs.gnu.org; 4 Aug 2024 03:17:02 +0000 Received: from localhost ([127.0.0.1]:55037 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1saRjx-0007mc-Ot for submit@debbugs.gnu.org; Sat, 03 Aug 2024 23:17:02 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:56606) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1saRjv-0007m6-Hj for 69343@debbugs.gnu.org; Sat, 03 Aug 2024 23:17:00 -0400 DKIM-Signature: a=rsa-sha256; b=odvQ/3TZNBWJWPETPFKX8H9JoeOVd+QfA7ZLfcVJk3zsM+319FkrIhyndA8feBBv0Br4vv83oM6ZN0fjCydl0PmCQkKimj/kUXKj1kjIeAqxqyL8OkOafuaIAM1Avdc/fB9CVnlsDViiOdg6+j8JZG37VVi6kBpE3HN2vrUFihqYmPpdzbwICK1pS2Dtqeu7xS4TOE02sh8KozV1h2EIwLalqKo+ApMTQ8S6OhndTvimq7UW8ZvtDgoiSo3n5SCdjKEF0nSZjJy7A4JcreW3SpaRPWknQ+gBYoR4UOXCx5TeqsAbysjOHycP0NdN0cQTznxR8LcL53FSMgnOKIQcXQ==; s=purelymail2; d=lunabee.space; v=1; bh=RUHmSuhS5uGJenfJXJKaEJCl2J6PvkMjfkqxRW4ZKHI=; h=Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=Y2TFPijtjktrmsFyWkzw+S9QsO2mFSUvVdMlzt5B/cX8FP8MNJEG3OaDCaM8SRftBnKvZnLu5aMiQQ6g2Ud4DT/pk/CCB5s6QHpprdHhoxdMu5Vhadlwr8LIshBIrXrLWRV900P+w5uLJLbP/R1ErBdhp7EdB+RyKllaYJ4isLmP7ovtSNHBZaGXw+nzDkcxTH/SFKxmXeNwzM/T+jjDz7R6WOvw6uqaVNgxzCWiLRLYsN+t4vW3aqX+oHLK9U9BQfiBNp3EYvxyWWPBaBpdV6vyQpPxyqWVkQrjbDgmOrDam1CaXGL9Vj7nZozsuIdh2SHTBQjHJ3vGtkTYb6EAQA==; s=purelymail2; d=purelymail.com; v=1; bh=RUHmSuhS5uGJenfJXJKaEJCl2J6PvkMjfkqxRW4ZKHI=; h=Feedback-ID:Received:From:To:Subject:Date; Feedback-ID: 8937:2070:null:purelymail X-Pm-Original-To: 69343@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -2124817350; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Sun, 04 Aug 2024 03:15:42 +0000 (UTC) Date: Sat, 3 Aug 2024 22:13:34 -0500 Message-ID: <7d781027c78bdea5fdb3f1c9c9ec432b9606d2b5.1722741214.git.lilah@lunabee.space> In-Reply-To: References: MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by Purelymail X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Lilah Tascheter via Guix-patches From: Lilah Tascheter Reply-To: Lilah Tascheter Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From: Felix Lechner * gnu/system/boot.scm (): New record. * gnu/machine/ssh.scm (machine->boot-alternatives): Return a boot-alternative encapsulating previous return value. (with-roll-back, roll-back-managed-host): Get parameters from boot-alternatives. * guix/scripts/system.scm (generation->boot-parameters): Rename to... (generation->boot-alternative): ...this. Return a boot-alternative encapsulating previous return value. (profile->boot-alternatives): Rename uses as above. (reinstall-bootloader, perform-action): Get parameters from boot-alternatives. Change-Id: Iaef0b0a3fa9240ca8315a9699bcf4a7bfe908e33 --- gnu/machine/ssh.scm | 32 ++++++++++++++++++++------------ gnu/system/boot.scm | 14 ++++++++++++++ guix/scripts/system.scm | 32 +++++++++++++++++++++----------- 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index fa1066b27b..8dd8c342a0 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -416,8 +416,8 @@ (define not-config? (_ #f))) (define (machine->boot-alternatives machine) - "Monadic procedure returning a list of 'boot-parameters' for the generations -of MACHINE's system profile, ordered from most recent to oldest." + "Monadic procedure returning a list of records for the +generations of MACHINE's system profile, ordered from most recent to oldest." (define remote-exp (with-extensions (list guile-gcrypt) (with-imported-modules `(((guix config) => ,(make-config.scm)) @@ -458,13 +458,18 @@ (define (machine->boot-alternatives machine) read-boot-parameters)) (root (boot-parameters-root-device params)) (text (boot-parameters-label params)) - (version (boot-parameters-version params))) - (boot-parameters - (inherit params) - (label (decorated-boot-label text generation epoch)) - (kernel-arguments - (append (bootable-kernel-arguments system-path root version) - (boot-parameters-kernel-arguments params)))))))) + (version (boot-parameters-version params)) + (parameters (boot-parameters + (inherit params) + (label (decorated-boot-label text generation epoch)) + (kernel-arguments + (append (bootable-kernel-arguments system-path root version) + (boot-parameters-kernel-arguments params)))))) + (boot-alternative + (generation generation) + (system-path system-path) + (epoch epoch) + (parameters parameters)))))) remote-results)))) (define-syntax-rule (with-roll-back should-roll-back? mbody ...) @@ -508,7 +513,8 @@ (define (deploy-managed-host machine) (%current-target-system #f)) (let* ((os (machine-operating-system machine)) (eval (cut machine-remote-eval machine <>)) - (menu-entries (map boot-parameters->menu-entry boot-alternatives)) + (menu-entries (map boot-parameters->menu-entry + (map boot-alternative-parameters boot-alternatives))) (bootloader-configuration (operating-system-bootloader os)) (bootcfg (operating-system-bootcfg os menu-entries))) (define-syntax-rule (eval/error-handling condition handler ...) @@ -582,13 +588,15 @@ (define (roll-back-managed-host machine) (mlet* %store-monad ((boot-alternatives (machine->boot-alternatives machine)) (_ -> (if (< (length boot-alternatives) 2) (raise roll-back-failure))) - (parameters (second boot-alternatives)) + (chosen-alternative (second boot-alternatives)) + (parameters (boot-alternative-parameters chosen-alternative)) (entries -> (list (boot-parameters->menu-entry parameters))) (locale -> (boot-parameters-locale parameters)) (crypto-dev -> (boot-parameters-store-crypto-devices parameters)) (store-dir -> (boot-parameters-store-directory-prefix parameters)) (old-entries -> (map boot-parameters->menu-entry - (drop boot-alternatives 2))) + (map boot-alternative-parameters + (drop boot-alternatives 2)))) (bootloader -> (operating-system-bootloader (machine-operating-system machine))) (bootcfg (lower-object diff --git a/gnu/system/boot.scm b/gnu/system/boot.scm index b1302b8786..833caef496 100644 --- a/gnu/system/boot.scm +++ b/gnu/system/boot.scm @@ -71,6 +71,13 @@ (define-module (gnu system boot) read-boot-parameters-file bootable-kernel-arguments + boot-alternative + boot-alternative? + boot-alternative-generation + boot-alternative-system-path + boot-alternative-epoch + boot-alternative-parameters + epoch->date-string decorated-boot-label boot-parameters->menu-entry @@ -299,6 +306,13 @@ (define* (bootable-kernel-arguments system root-device version) #~(string-append (if #$version>0? "gnu.load=" "--load=") #$system "/boot"))))) +(define-record-type* + boot-alternative make-boot-alternative boot-alternative? + (generation boot-alternative-generation) + (system-path boot-alternative-system-path) + (epoch boot-alternative-epoch) + (parameters boot-alternative-parameters)) + (define (epoch->date-string epoch) "Return a string representing the date for EPOCH seconds." (let ((time (make-time time-utc 0 epoch))) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 0c69f6d90b..0f7d864e06 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -328,26 +328,31 @@ (define-syntax-rule (unless-file-not-found exp) #f (apply throw args))))) -(define (generation->boot-parameters profile number) - "Return the 'boot-parameters' for the generation of PROFILE specified +(define (generation->boot-alternative profile number) + "Return the 'boot-alternative' 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)))))) + (text (boot-parameters-label params)) + (parameters (boot-parameters + (inherit params) + (label (decorated-boot-label text number epoch))))) + (boot-alternative + (generation number) + (system-path system) + (epoch epoch) + (parameters parameters))))) (define* (profile->boot-alternatives #:optional (profile %system-profile) (numbers (reverse (generation-numbers profile)))) - "Return a list of 'boot-parameters' for the generations of PROFILE specified + "Return a list of 'boot-alternative' for the generations of PROFILE specified by NUMBERS, which is a list of generation numbers. The list is ordered from the most recent to the oldest profiles." (filter-map (lambda (number) - (generation->boot-parameters profile number)) + (generation->boot-alternative profile number)) numbers)) @@ -396,7 +401,9 @@ (define (reinstall-bootloader store number) (bootloader bootloader))) ;; Make the specified system generation the default entry. - (params (generation->boot-parameters %system-profile number)) + (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 @@ -407,7 +414,8 @@ (define (reinstall-bootloader store number) %system-profile old-generations)) (entries (list (boot-parameters->menu-entry params))) (old-entries (map boot-parameters->menu-entry - previous-boot-alternatives))) + (map boot-alternative-parameters + previous-boot-alternatives)))) (run-with-store store (mlet* %store-monad ((bootcfg (lower-object @@ -824,7 +832,9 @@ (define* (perform-action action image os (if (eq? action 'init) '() - (map boot-parameters->menu-entry (profile->boot-alternatives)))))) + (map boot-parameters->menu-entry + (map boot-alternative-parameters + (profile->boot-alternatives))))))) (when (eq? action 'reconfigure) (maybe-suggest-running-guix-pull)