From patchwork Fri Sep 20 04:16:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lilah Tascheter X-Patchwork-Id: 68150 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 290AC27BBEA; Fri, 20 Sep 2024 05:18:20 +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 689C427BBE2 for ; Fri, 20 Sep 2024 05:18:19 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1srV5g-0008EI-1W; Fri, 20 Sep 2024 00:17:56 -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 1srV5b-0008Ct-BM for guix-patches@gnu.org; Fri, 20 Sep 2024 00:17:52 -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 1srV5b-0006HB-2V; Fri, 20 Sep 2024 00:17:51 -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=CVCi42lFimSRcTBveBAN2e7asJDrqVnuPKZEwLFRcJE=; b=PUC+BIvBVLhJLaguTGnyTVAI+tlFM+zBCFBPCeqR/pPYD4fIj2/OK3p23Ro6bqeqP0dqjlvVbWUKVzSdSPvsfUe/vHGqS7rRsTsHRr3njHYLciv+cpWbPGdMlLrWQViAU6+T1zVWqJLSk/T5lgyn21+W/EMBtK3CTxv90iubnDylIsYXj+QOcy6TAiWAcqCBs1ZrjWsLo9fbg8EvNbSc3u0tXfSr0Jv2IjvhQh+BTBwItG1lkBoJ/Fb2I02yxmkkyNt6A0G6qPZV4igiPq8NRv2yWUApv48FI8IrwgSyD0dSxv4GtGZWQgy0zVwfnRaq6VoykOu5n/JXT8uWVpRT4w==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1srV5s-0005V9-Gw; Fri, 20 Sep 2024 00:18:08 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69343] [PATCH v4 11/11] 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: Fri, 20 Sep 2024 04:18: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: Herman Rimm , 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.172680588621103 (code B ref 69343); Fri, 20 Sep 2024 04:18:08 +0000 Received: (at 69343) by debbugs.gnu.org; 20 Sep 2024 04:18:06 +0000 Received: from localhost ([127.0.0.1]:33785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1srV5p-0005Tu-3B for submit@debbugs.gnu.org; Fri, 20 Sep 2024 00:18:06 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:52048) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1srV5k-0005S7-LB for 69343@debbugs.gnu.org; Fri, 20 Sep 2024 00:18:01 -0400 DKIM-Signature: a=rsa-sha256; b=DibIcuQEXQw7YTzXyFPqPopKEUwmgrll1ZZCjnacTamT2mBRszLQYeNtIzdwamPFcaGAXRAUFG/8rei1WalRFz0WN7pONEXN3UeIoMYbz0cPeUmiwhbrzHpPkJMlQUmnnZsaHlROh4UnwYjSc5N1WaFLx1lm6QFyzS8/Fqm96N3D+8hBxH2vbHXvFGq+fwA4UXY+2AAxxMX6PcLAyFvUbPoIz1jgmv9UWuEPqUT63qCAyRLxpEYYthC1BfnbNPY9O/W8nJTkMfurapYIGpNHHJiRYzUlBcNjbH5MAMozA73AlDYxo9YBVOE5xD4S7yI7yuYrYcHMNQ+4oHk43zxeDg==; s=purelymail3; d=lunabee.space; v=1; bh=Wdaw++7Zd+Ll/cgrIr/flJd7mddXi3SKccGFa4Iyfic=; h=Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=jjjxJhFB7gvW4QvYIzVy5d73/DU21x1JUnPaRjEO430WssxEqEL6o9DnNm9sKxvO3MhA1/Z/GHQjTyPr7HU9oV5czRujCYX/eLdNdBnlr8ab5s7+gx9RhJl2Pz2/3m6fhGAEvRBCMeVQvY+XuPMstnPWF9rGyagwNz+WJ+pHO+xt+K6oXx28ixrVmcTpsl5XS+FRPpKHDxuiG4JhxnUU8SAx/lcRA8tHL9wVE593QODXnT/CPErM34MLcfjTIvGLsYS935E5H/d8LrZuvFxj5gDu0PQGQubBu89Q6popvRg8bb1qHSRMiDfWeHxm+1a8D5IMe5Rnchj92BxR5QQ+aw==; s=purelymail3; d=purelymail.com; v=1; bh=Wdaw++7Zd+Ll/cgrIr/flJd7mddXi3SKccGFa4Iyfic=; 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 -100958845; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Fri, 20 Sep 2024 04:17:21 +0000 (UTC) Date: Thu, 19 Sep 2024 23:16:05 -0500 Message-ID: <5440f547c4fd458acdc327afeded9a6067e98124.1726805765.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 | 29 ++++++++++++++++++----------- gnu/system/boot.scm | 14 ++++++++++++++ guix/scripts/system.scm | 32 +++++++++++++++++++++----------- 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index 37806a2e1b..ca0f3483a4 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)) @@ -459,13 +459,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 ...) @@ -509,7 +514,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 ...) @@ -583,7 +589,8 @@ (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)) diff --git a/gnu/system/boot.scm b/gnu/system/boot.scm index 82ca353cb3..c29e48d607 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)